API documentation
reset_config()
Resets the config file.
Source code in QDMpy/__init__.py
79 80 81 82 83 84 |
|
QDM
QDM
The QDM class is a container for all data related to a single QDM measurement.
The QDM class contains the light and laser images as well as an ODMR and Fit instances.
See Also
QDMpy._core.odmr.ODMR QDMpy._core.fit.Fit
Source code in QDMpy/_core/qdm.py
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 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
|
__init__(odmr_instance: ODMR, light: np.ndarray, laser: np.ndarray, working_directory: Union[str, os.PathLike], pixel_size: float = 4e-06, model_name: str = 'auto') -> None
Initialize the QDM object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
odmr_instance |
ODMR
|
ODMR instance |
required |
light |
np.ndarray
|
light image |
required |
laser |
np.ndarray
|
laser image |
required |
working_directory |
Union[str, os.PathLike]
|
working directory |
required |
pixel_size |
float
|
pixel size in m |
4e-06
|
model_name |
str
|
model name (Default value = 'auto') If 'auto' the model is chosen based on the mean ODMR data. See Also: QDMpy._core.models.guess_model_name |
'auto'
|
Source code in QDMpy/_core/qdm.py
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 |
|
apply_outlier_mask(outlier: Union[NDArray, None] = None) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
outlier |
Union[NDArray, None]
|
(Default value = None) |
None
|
Source code in QDMpy/_core/qdm.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
b111_induced() -> np.ndarray
property
Returns:
Type | Description |
---|---|
np.ndarray
|
return: numpy.ndarray |
Source code in QDMpy/_core/qdm.py
527 528 529 530 531 532 533 534 535 536 537 |
|
b111_remanent() -> np.ndarray
property
Returns:
Type | Description |
---|---|
np.ndarray
|
return: numpy.ndarray |
Source code in QDMpy/_core/qdm.py
515 516 517 518 519 520 521 522 523 524 525 |
|
bin_data(bin_factor: int) -> None
Bin the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bin_factor |
int
|
return: |
required |
Source code in QDMpy/_core/qdm.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
bin_factor() -> int
property
mirrors the bin_factor of the ODMR instance
Source code in QDMpy/_core/qdm.py
235 236 237 238 |
|
correct_glob_fluorescence(glob_fluo: float) -> None
Corrects the global fluorescence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
glob_fluo |
float
|
global fluorescence correction factor |
required |
Source code in QDMpy/_core/qdm.py
274 275 276 277 278 279 280 281 282 |
|
delta_resonance() -> NDArray
property
Return the difference between low and high freq. resonance of the fit.
Returns:
Type | Description |
---|---|
NDArray
|
numpy.ndarray: negative difference |
NDArray
|
numpy.ndarray: positive difference |
Source code in QDMpy/_core/qdm.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
|
detect_outliers(dtype: str = 'width', method: str = 'LocalOutlierFactor', **outlier_props: Any) -> np.ndarray
Detect outliers in the ODMR data.
The outliers are detected using 'method'. The method can be either 'LocalOutlierFactor' or 'IsolationForest'.
The LocalOutlierFactor is a scikit-learn method. The IsolationForest is a scikit-learn method.
The method arguments can be passed as a keyword argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dtype |
str
|
the data type the method should be used on (Default value = "width") |
'width'
|
method |
str
|
the outlier detection method (Default value = "LocalOutlierFactor") |
'LocalOutlierFactor'
|
**outlier_props |
Any
|
keyword arguments for the outlier detection method |
{}
|
Source code in QDMpy/_core/qdm.py
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 |
|
export_qdmio(path_to_file: Union[os.PathLike, str, None] = None) -> None
Export the data to a QDM.io file. This is a Matlab file named B111dataToPlot.mat. With the following variables:
['negDiff', 'posDiff', 'B111ferro', 'B111para', 'chi2Pos1', 'chi2Pos2', 'chi2Neg1', 'chi2Neg2', 'ledImg', 'laser', 'pixelAlerts']
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_to_file |
Union[os.PathLike, str, None]
|
(Default value = None) |
None
|
Source code in QDMpy/_core/qdm.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
export_qdmpy(path_to_file: Union[os.PathLike, str]) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_to_file |
Union[os.PathLike, str]
|
required |
Source code in QDMpy/_core/qdm.py
481 482 483 484 485 486 487 488 489 490 491 |
|
fit_odmr(refit = False) -> None
Fit the data using the current fit type.
Source code in QDMpy/_core/qdm.py
355 356 357 358 359 360 |
|
from_matlab(matlab_files: Union[os.PathLike[Any], str], dialect: str = 'QDM.io') -> Any
classmethod
Loads QDM data from a Matlab file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matlab_files |
Union[os.PathLike[Any], str]
|
required | |
dialect |
str
|
(Default value = "QDM.io") |
'QDM.io'
|
Source code in QDMpy/_core/qdm.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
from_qdmio(data_folder: Union[os.PathLike[Any], str], model_name: str = 'auto') -> Any
classmethod
Loads QDM data from a Matlab file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_folder |
Union[os.PathLike[Any], str]
|
required | |
model_name |
str
|
(Default value = None) |
'auto'
|
Source code in QDMpy/_core/qdm.py
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 |
|
get_param(param: str, reshape: bool = True) -> NDArray
Get the value of a parameter reshaped to the image dimesions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param |
str
|
required | |
reshape |
bool
|
(Default value = True) |
True
|
Source code in QDMpy/_core/qdm.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
global_factor() -> float
property
Global fluorescence factor used for correction
Source code in QDMpy/_core/qdm.py
284 285 286 287 |
|
idx2rc(idx: Union[int, np.ndarray], ref: str = 'data') -> Tuple[np.ndarray[Any, Any], np.ndarray[Any, Any]]
Convert an index to a rc coordinate of the reference.
If the reference is 'data', the index is relative to the data. If the reference is 'img', the index is relative to the LED/laser image. Only data -> data and img -> img are implemented.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
Union[int, np.ndarray]
|
int or numpy.ndarray [idx] or [idx, idx] |
required |
ref |
str
|
data' or 'img' (Default value = "data") |
'data'
|
Returns:
Type | Description |
---|---|
Tuple[np.ndarray[Any, Any], np.ndarray[Any, Any]]
|
numpy.ndarray ([row], [col]) -> [[y], [x]] |
Source code in QDMpy/_core/qdm.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
model_names() -> str
property
List of available models
Source code in QDMpy/_core/qdm.py
290 291 292 293 |
|
outlier_pdf() -> pd.DataFrame
property
Returns:
Type | Description |
---|---|
pd.DataFrame
|
return: pandas.DataFrame |
Source code in QDMpy/_core/qdm.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
outliers() -> NDArray
property
Returns:
Type | Description |
---|---|
NDArray
|
return: ndarray of boolean |
Source code in QDMpy/_core/qdm.py
94 95 96 97 98 99 100 101 102 103 104 |
|
outliers_idx() -> NDArray
property
Returns:
Type | Description |
---|---|
NDArray
|
Indices are in reference to the binned ODMR data. |
NDArray
|
return: np.array |
Source code in QDMpy/_core/qdm.py
106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
outliers_xy() -> NDArray
property
Returns:
Type | Description |
---|---|
NDArray
|
In reference to the binned ODMR data. |
NDArray
|
return: np.array of shape (n_outlier, 2) |
Source code in QDMpy/_core/qdm.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
rc2idx(rc: np.ndarray, ref: str = 'data') -> NDArray
Convert the xy coordinates to the index of the data.
If the reference is 'data', the index is relative to the data. If the reference is 'img', the index is relative to the LED/laser image. Only data -> data and img -> img are supported.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rc |
np.ndarray
|
numpy.ndarray [[row], [column]] -> [[y], [x]] |
required |
ref |
str
|
str 'data' or 'img' (Default value = "data") |
'data'
|
rc |
np.ndarray
|
np.ndarray: |
required |
Returns:
Type | Description |
---|---|
NDArray
|
numpy.ndarray [idx] |
Source code in QDMpy/_core/qdm.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
|
reset_constraints() -> None
Reset the constraints to the default values.
Source code in QDMpy/_core/qdm.py
351 352 353 |
|
set_constraints(param: str, vmin: Optional[Union[str, None]] = None, vmax: Optional[Union[str, None]] = None, bound_type: Optional[Union[str, None]] = None) -> None
Set the constraints for the fit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param |
str
|
required | |
vmin |
Optional[Union[str, None]]
|
(Default value = None) |
None
|
vmax |
Optional[Union[str, None]]
|
(Default value = None) |
None
|
bound_type |
Optional[Union[str, None]]
|
(Default value = None) |
None
|
Source code in QDMpy/_core/qdm.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
set_model_name(model_name: Union[str, int]) -> None
Set the diamond type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name |
Union[str, int]
|
type of diamond used (int or str) e.g. N15 of 2 as in 2 peaks |
required |
Source code in QDMpy/_core/qdm.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
|
ODMR
ODMR
Source code in QDMpy/_core/odmr.py
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 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
|
__getitem__(item: Union[Sequence[Union[str]], str]) -> NDArray
Return the data of a given polarization, frequency range, pixel or frequency.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Union[Sequence[Union[str]], str]
|
desired return value (Default value = None) currently available: '+' - positive polarization '-' - negative polarization '<' - lower frequency range '>' - higher frequency range 'r' - reshape to 2D image (data_shape) |
required |
Examples:
odmr['+'] -> pos. polarization odmr['+', '<'] -> pos. polarization + low frequency range
Source code in QDMpy/_core/odmr.py
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 |
|
apply_outlier_mask(outlier_mask: Union[NDArray, None] = None, **kwargs: Any) -> None
Apply the outlier mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
outlier_mask |
Union[NDArray, None]
|
np.ndarray: (Default value = None) |
None
|
**kwargs |
Any
|
{}
|
Source code in QDMpy/_core/odmr.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
bin_data(bin_factor: int, **kwargs: Any) -> None
Bin the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bin_factor |
int
|
required | |
**kwargs |
Any
|
{}
|
Source code in QDMpy/_core/odmr.py
508 509 510 511 512 513 514 515 516 517 518 519 |
|
calc_gf_correction(gf: float) -> NDArray
Calculate the global fluorescence correction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gf |
float
|
The global fluorescence factor |
required |
Source code in QDMpy/_core/odmr.py
581 582 583 584 585 586 587 588 589 590 |
|
check_glob_fluorescence(gf_factor: Union[float, None] = None, idx: Union[int, None] = None) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gf_factor |
Union[float, None]
|
(Default value = None) |
None
|
idx |
Union[int, None]
|
(Default value = None) |
None
|
Source code in QDMpy/_core/odmr.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
|
correct_glob_fluorescence(gf_factor: float, **kwargs: Any) -> None
Correct the data for the gradient factor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gf_factor |
float
|
required | |
**kwargs |
Any
|
{}
|
Source code in QDMpy/_core/odmr.py
592 593 594 595 596 597 598 599 600 601 602 603 604 |
|
f_ghz() -> NDArray
property
Returns the frequencies of the ODMR in GHz.
Source code in QDMpy/_core/odmr.py
361 362 363 364 |
|
f_hz() -> NDArray
property
Returns the frequencies of the ODMR in Hz.
Source code in QDMpy/_core/odmr.py
356 357 358 359 |
|
frequencies() -> NDArray
property
Returns:
Type | Description |
---|---|
NDArray
|
return: numpy.ndarray |
Source code in QDMpy/_core/odmr.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
from_qdmio(data_folder: Union[str, os.PathLike]) -> ODMR
classmethod
Loads QDM data from a Matlab file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_folder |
Union[str, os.PathLike]
|
required |
Source code in QDMpy/_core/odmr.py
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 |
|
get_binned_pixel_indices(x: int, y: int) -> Tuple[Sequence[int], Sequence[int]]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
required | |
y |
int
|
required |
Returns:
Type | Description |
---|---|
Tuple[Sequence[int], Sequence[int]]
|
return: numpy.ndarray |
Source code in QDMpy/_core/odmr.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
get_most_divergent_from_mean() -> Tuple[int, int]
Get the most divergent pixel from the mean in data coordinates.
Source code in QDMpy/_core/odmr.py
194 195 196 197 198 |
|
get_norm_factors(data: ArrayLike, method: str = 'max') -> np.ndarray
classmethod
Return the normalization factors for the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ArrayLike
|
data |
required |
method |
str
|
return: (Default value = "max") |
'max'
|
Source code in QDMpy/_core/odmr.py
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 |
|
idx2rc(idx: ArrayLike) -> Tuple[NDArray, NDArray]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
ArrayLike
|
required |
Source code in QDMpy/_core/odmr.py
183 184 185 186 187 188 189 190 191 192 |
|
mean_contrast() -> NDArray
property
Calculate the mean of the minimum of MW sweep for each pixel.
Source code in QDMpy/_core/odmr.py
394 395 396 397 |
|
mean_odmr() -> NDArray
property
Calculate the mean of the data.
Source code in QDMpy/_core/odmr.py
384 385 386 387 |
|
n_freqs() -> int
property
Returns:
Type | Description |
---|---|
int
|
return: int |
Source code in QDMpy/_core/odmr.py
329 330 331 332 333 334 335 336 337 338 339 |
|
n_pixel() -> int
property
Returns:
Type | Description |
---|---|
int
|
return: int |
Source code in QDMpy/_core/odmr.py
317 318 319 320 321 322 323 324 325 326 327 |
|
normalize_data(method: Union[str, None] = None, **kwargs: Any) -> None
Normalize the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
Union[str, None]
|
(Default value = None) |
None
|
**kwargs |
Any
|
{}
|
Source code in QDMpy/_core/odmr.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
raw_contrast() -> NDArray
property
Calculate the minimum of MW sweep for each pixel.
Source code in QDMpy/_core/odmr.py
389 390 391 392 |
|
rc2idx(rc: ArrayLike) -> NDArray
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rc |
ArrayLike
|
required |
Source code in QDMpy/_core/odmr.py
172 173 174 175 176 177 178 179 180 181 |
|
remove_overexposed(**kwargs: Any) -> None
Remove overexposed pixels from the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any
|
{}
|
Source code in QDMpy/_core/odmr.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
reset_data(**kwargs: Any) -> None
Reset the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any
|
{}
|
Source code in QDMpy/_core/odmr.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
|
Fit
Fit
Source code in QDMpy/_core/fit.py
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 |
|
__init__(data: NDArray, frequencies: NDArray, model_name: str = 'auto', constraints: Optional[Dict[str, Any]] = None)
Fit the data to a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
NDArray
|
3D array of the data to fit. |
required |
frequencies |
NDArray
|
1D array of the frequencies. |
required |
model_name |
str
|
Name of the model to fit. (Default value = 'auto')
if 'auto' the model is guessed from the data.
See Also: |
'auto'
|
constraints |
Optional[Dict[str, Any]]
|
Constraints for the fit. (Default value = None) If None, the default constraints from the config.ini file in QDMpy.CONFIG_PATH are used. |
None
|
Source code in QDMpy/_core/fit.py
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 |
|
constraints_changed(constraints: List[float], constraint_types: List[str]) -> bool
Check if the constraints have changed.
Source code in QDMpy/_core/fit.py
243 244 245 246 247 |
|
fit_frange(data: NDArray, freq: NDArray, initial_parameters: NDArray) -> List[NDArray]
Wrapper for the fit_constrained function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
NDArray
|
data for one frequency range, to be fitted. array of size (n_pol, n_pixel, n_freqs) of the ODMR data |
required |
freq |
NDArray
|
array of size (n_freqs) of the frequencies |
required |
initial_parameters |
NDArray
|
initial guess for the fit, an array of size (n_pol * n_pixel, 2 * n_param) of the initial parameters |
required |
Returns:
Name | Type | Description |
---|---|---|
fit_results |
List[NDArray]
|
results consist of: parameters, states, chi_squares, number_iterations, execution_time results: array of size (n_poln_pixel, n_param) of the fitted parameters states: array of size (n_poln_pixel) of the fit states (i.e. did the fit work) chi_squares: array of size (n_poln_pixel) of the chi squares number_iterations: array of size (n_poln_pixel) of the number of iterations execution_time: execution time |
Source code in QDMpy/_core/fit.py
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 |
|
get_constraint_types() -> NDArray
Return the constraint types. :return: np.array
Source code in QDMpy/_core/fit.py
260 261 262 263 264 265 266 |
|
get_constraints_array(n_pixel: int) -> NDArray
Return the constraints as an array (pixel, 2*fitting_parameters). :return: np.array
Source code in QDMpy/_core/fit.py
249 250 251 252 253 254 255 256 257 258 |
|
get_initial_parameter() -> NDArray
Constructs an initial guess for the fit.
Source code in QDMpy/_core/fit.py
338 339 340 341 342 343 344 345 346 347 348 349 |
|
get_param(param: str) -> Union[NDArray, None]
Get the value of a parameter reshaped to the image dimesions.
Source code in QDMpy/_core/fit.py
273 274 275 276 277 278 279 280 281 282 283 284 |
|
guess_model_name(n_spectra = 100, *args, **kwargs) -> str
property
Guess the model name from the data.
Source code in QDMpy/_core/fit.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
initial_parameter() -> NDArray
property
Return the initial parameter.
Source code in QDMpy/_core/fit.py
166 167 168 169 170 171 172 173 |
|
model() -> dict
property
Return the model dictionary.
Source code in QDMpy/_core/fit.py
117 118 119 120 121 122 |
|
model_params() -> dict
property
Return the model parameters.
Source code in QDMpy/_core/fit.py
110 111 112 113 114 115 |
|
model_params_unique() -> List[str]
property
Return a list of unique fitting parameters. :return: list
Source code in QDMpy/_core/fit.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
reshape_result(result: NDArray) -> NDArray
Reshape the results to the original shape of (n_pol, npix, -1)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
NDArray
|
array of size (n_pol * n_pixel, -1) of the fitted parameters |
required |
Returns:
Name | Type | Description |
---|---|---|
result |
NDArray
|
array of size (n_pol, n_pixel, -1) of the fitted parameters |
Source code in QDMpy/_core/fit.py
462 463 464 465 466 467 468 469 470 471 472 473 474 |
|
reshape_results(results: List[NDArray]) -> NDArray
Reshape the results from the fit_constrained function into the correct shape.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results |
List[NDArray]
|
results consist of: parameters, states, chi_squares, number_iterations, execution_time |
required |
Returns:
Name | Type | Description |
---|---|---|
results |
NDArray
|
results consist of: parameters, states, chi_squares, number_iterations, execution_time results: array of size (n_pol, n_pixel, n_param) of the fitted parameters states: array of size (n_pol, n_pixel) of the fit states (i.e. did the fit work) chi_squares: array of size (n_pol, n_pixel) of the chi squares number_iterations: array of size (n_pol, n_pixel) of the number of iterations execution_time: execution time |
Source code in QDMpy/_core/fit.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
|
set_constraints(param: str, vmin: Union[float, None] = None, vmax: Union[float, None] = None, constraint_type: Union[str, None] = None, reset_fit: bool = True)
Set the constraints for the fit.
:param param: str The parameter to set the constraints for. :param vmin: float, optional The minimum value to set the constraints to. The default is None. :param vmax: float, optional The maximum value to set the constraints to. The default is None. :param constraint_type: str optional The bound type to set the constraints to. The default is None. :param reset_fit: bool, optional Whether to reset the fit results. The default is True.
Source code in QDMpy/_core/fit.py
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 |
|
set_free_constraints()
Set the constraints to be free.
Source code in QDMpy/_core/fit.py
231 232 233 234 235 236 |
|
guess_center(data: NDArray, freq: NDArray) -> NDArray
Guess the center frequency of ODMR data.
:param data: np.array data to guess the center frequency from :param freq: np.array frequency range of the data
:return: np.array center frequency of the data
Source code in QDMpy/_core/fit.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
guess_center_freq_single(data: NDArray, freq: NDArray) -> NDArray
Guess the center frequency of a single frequency range.
:param data: np.array data to guess the center frequency from :param freq: np.array frequency range of the data :return: np.array center frequency of the data
Source code in QDMpy/_core/fit.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
guess_contrast(data: NDArray) -> NDArray
Guess the contrast of a ODMR data.
:param data: np.array data to guess the contrast from :return: np.array contrast of the data
Source code in QDMpy/_core/fit.py
477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
guess_width(data: NDArray, f_GHz: NDArray, n_peaks: Optional[int]) -> NDArray
Guess the width of a ODMR resonance peaks.
:param data: np.array data to guess the width from :param f_GHz: np.array frequency range of the data
:return: np.array width of the data
Source code in QDMpy/_core/fit.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
guess_width_single(data: NDArray, freq: NDArray, n_peaks: Optional[int]) -> NDArray
Guess the width of a single frequency range.
:param data: np.array data to guess the width from :param freq: np.array frequency range of the data
:return: np.array width of the data
Raises ValueError if the number of peaks is not 1, 2 or 3.
Source code in QDMpy/_core/fit.py
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 |
|
make_parameter_array(c0: float, n_params: int, p: NDArray, params: Dict[int, List[float]]) -> np.ndarray
Make a parameter array for a given center frequency.
:param c0: float center frequency :param n_params: int number of parameters :param p: np.array parameter array :param params: dict parameter dictionary :return: np.array parameter array
Source code in QDMpy/_core/fit.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
|
normalized_cumsum(data: NDArray) -> NDArray
Calculate the normalized cumulative sum of the data.
Parameters
NDArray
Data to calculate the normalized cumulative sum of.
Returns
NDArray Normalized cumulative sum of the data.
Source code in QDMpy/_core/fit.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
|