jelli.core.measurement
Measurement
Class to store measurements and constraints on observables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the measurement. |
required |
constraints
|
list[dict]
|
List of constraints on observables. Each constraint is a dictionary with the following keys:
|
required |
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the measurement. |
constraints |
list[dict]
|
List of constraints on observables. Each constraint is a dictionary with the following keys:
|
constrained_observables |
set
|
Set of observables that the measurement constrains |
Methods:
Name | Description |
---|---|
get_all_measurements |
Return all measurements. |
get_all_observables |
Return all observables. |
get_measurements |
Return measurements that constrain the specified observables. |
get_constraints |
Return constraints on the specified observables. |
get_combined_constraints |
Return combined constraints on the specified observables. |
load |
Load measurements from a json file or a directory containing json files |
unload |
Unload measurements. |
clear |
Clear all measurements. |
Examples:
Load measurements from a json file:
>>> Measurement.load('measurements.json')
Get all measurements:
>>> Measurement.get_all_measurements()
{'measurement1': <Measurement object>, 'measurement2': <Measurement object>, ...}
Get all observables:
>>> Measurement.get_all_observables()
{'observable1', 'observable2', ...}
Get measurements that contain the specified observables:
>>> Measurement.get_measurements({'observable1', 'observable2'})
{'measurement1': <Measurement object>, 'measurement2': <Measurement object>, ...}
Get constraints on the specified observables:
>>> Measurement.get_constraints({'observable1', 'observable2'})
{'NormalDistribution': {'observables': ['observable1', 'observable2'], 'observable_indices': [0, 1], 'central_value': [0.0, 0.0], 'standard_deviation': [1.0, 1.0]}, ...}
Get combined constraints on the specified observables:
>>> Measurement.get_combined_constraints({'observable1', 'observable2'})
{'NormalDistribution': {'measurement_name': ['measurement1'], 'observables': ['observable1', 'observable2'], 'observable_indices': [0, 1], 'central_value': [0.0, 0.0], 'standard_deviation': [1.0, 1.0]}, ...}
Unload measurements:
>>> Measurement.unload(['measurement1', 'measurement2'])
Clear all measurements:
>>> Measurement.clear()
Source code in jelli/core/measurement.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
__init__(name, constraints)
Initialize a Measurement object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the measurement. |
required |
constraints
|
list[dict]
|
List of constraints on observables. Each constraint is a dictionary with the following keys:
|
required |
Returns:
Type | Description |
---|---|
None
|
|
Examples:
Initialize a Measurement object:
>>> Measurement('measurement1', [{'type': 'NormalDistribution', 'observables': ['observable1'], 'parameters': {'central_value': 0.0, 'standard_deviation': 1.0}}])
Source code in jelli/core/measurement.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
clear()
classmethod
Clear all measurements.
Returns:
Type | Description |
---|---|
None
|
|
Examples:
Clear all measurements:
>>> Measurement.clear()
Source code in jelli/core/measurement.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
combine_constraints(constraints_list)
Combine the constraints provided in the list of constraints, where each element of the list is a dictionary of constraints on a single observable.
Normal distributions are combined analytically, while other distributions are combined numerically.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
constraints_list
|
list[dict]
|
List of constraints to combine, one constraints dictionary per observable. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing combined constraints. |
Examples:
Combine two constraints on two observables:
>>> Measurement.combine_constraints([
... {'NormalDistribution': {'measurement_name': ['measurement1', 'measurement2'], 'observables': ['observable1', 'observable1'], 'observable_indices': np.array([0, 0]), 'central_value': np.array([1.0, 1.2]), 'standard_deviation': np.array([0.2, 0.3])}},
... {'NormalDistribution': {'measurement_name': ['measurement3', 'measurement4'], 'observables': ['observable2', 'observable2'], 'observable_indices': np.array([1, 1]), 'central_value': np.array([2.0, 2.5]), 'standard_deviation': np.array([0.5, 0.7])}},
... ])
{'NormalDistribution':
{
'measurement_name': array(['measurement1, measurement2', 'measurement3, measurement4']),
'observables': array(['observable1', 'observable2']),
'observable_indices': array([0, 1]),
'central_value': array([1.06153846, 2.16891892]),
'standard_deviation': array([0.16641006, 0.40686674])
},
}
Source code in jelli/core/measurement.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
|
get_all_measurements()
classmethod
Return all measurements.
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing all measurements. |
Examples:
Get all measurements:
>>> Measurement.get_all_measurements()
{'measurement1': <Measurement object>, 'measurement2': <Measurement object>, ...}
Source code in jelli/core/measurement.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
get_all_observables()
classmethod
Return all observables.
Returns:
Type | Description |
---|---|
set
|
Set containing all observables. |
Examples:
Get all observables:
>>> Measurement.get_all_observables()
{'observable1', 'observable2', ...}
Source code in jelli/core/measurement.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
get_combined_constraints(observables)
classmethod
Return combined constraints on the specified observables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
observables
|
list or array[str]
|
Observables to combine constraints for. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing combined constraints on the specified observables. |
Examples:
Get combined constraints on the specified observables:
>>> Measurement.get_combined_constraints(['observable1', 'observable2'])
{'NormalDistribution': {'measurement_name': ['measurement1'], 'observables': ['observable1', 'observable2'], 'observable_indices': [0, 1], 'central_value': [0.0, 0.0], 'standard_deviation': [1.0, 1.0]}, ...}
Source code in jelli/core/measurement.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
|
get_constraints(observables, observables_for_indices=None, distribution_types=None, include_measurements=None, exclude_measurements=None)
classmethod
Return constraints on the specified observables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
observables
|
list or array[str]
|
Observables to constrain. |
required |
observables_for_indices
|
list or array[str]
|
Observables to create indices for. If |
None
|
distribution_types
|
list[str]
|
Types of distributions to include. If |
None
|
include_measurements
|
list[str]
|
A list of measurements to include. If |
None
|
exclude_measurements
|
list[str]
|
A list of measurements to exclude. If |
None
|
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing constraints on the specified observables. |
Examples:
Get constraints on the specified observables:
>>> Measurement.get_constraints(['observable1', 'observable2'])
{'NormalDistribution': {'observables': ['observable1', 'observable2'], 'observable_indices': [0, 1], 'central_value': [0.0, 0.0], 'standard_deviation': [1.0, 1.0]}, ...}
Get constraints on the specified observables with specific distribution types:
>>> Measurement.get_constraints(['observable1', 'observable2'], ['NormalDistribution', 'MultivariateNormalDistribution'])
{'NormalDistribution': {'observables': ['observable1', 'observable2'], 'observable_indices': [0, 1], 'central_value': [0.0, 0.0], 'standard_deviation': [1.0, 1.0]}, 'MultivariateNormalDistribution': {'observables': ['observable1', 'observable2'], 'observable_indices': [0, 1], 'central_value': [0.0, 0.0], 'covariance': [[1.0, 0.0], [0.0, 1.0]], 'inverse_covariance': [[1.0, 0.0], [0.0, 1.0]]}}
Source code in jelli/core/measurement.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
get_measurements(observables, include_measurements=None, exclude_measurements=None)
classmethod
Return measurements that constrain the specified observables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
observables
|
list or array[str]
|
Observables to constrain. |
required |
include_measurements
|
list[str]
|
A list of measurements to include. If |
None
|
exclude_measurements
|
list[str]
|
A list of measurements to exclude. If |
None
|
Returnsxw
dict Dictionary containing measurements that constrain the specified observables.
Examples:
Get measurements that constrain the specified observables:
>>> Measurement.get_measurements(['observable1', 'observable2'])
{'measurement1': <Measurement object>, 'measurement2': <Measurement object>, ...}
Source code in jelli/core/measurement.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
load(path)
classmethod
Load measurements from a json file or a directory containing json files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to a json file or a directory containing json files. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Examples:
Load measurements from a json file:
>>> Measurement.load('./measurements.json')
Load measurements from a directory containing json files:
>>> Measurement.load('./measurements/')
Source code in jelli/core/measurement.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
unload(measurement_names)
classmethod
Unload measurements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
measurement_names
|
list[str]
|
Names of the measurements to unload. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Examples:
Unload measurements:
>>> Measurement.unload(['measurement1', 'measurement2'])
Source code in jelli/core/measurement.py
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|