Automatic documentation generated from docstrings
Channel
dataclass
Source code in mass2/core/channel.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 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 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
|
plot_hists(col, bin_edges, group_by_col, axis=None, use_good_expr=True, use_expr=pl.lit(True), skip_none=True)
Plots histograms for the given column, grouped by the specified column.
Parameters: - col (str): The column name to plot. - bin_edges (array-like): The edges of the bins for the histogram. - group_by_col (str): The column name to group by. This is required. - axis (matplotlib.Axes, optional): The axis to plot on. If None, a new figure is created.
Source code in mass2/core/channel.py
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 |
|
plot_summaries(use_expr_in=None, downsample=None, log=False)
Plot a summary of the data set, including time series and histograms of key pulse properties.
Parameters: |
|
---|
Source code in mass2/core/channel.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 |
|
with_column_map_step(input_col, output_col, f)
f should take a numpy array and return a numpy array with the same number of elements
Source code in mass2/core/channel.py
361 362 363 364 |
|
with_good_expr_below_nsigma_outlier_resistant(col_nsigma_pairs, replace=False, use_prev_good_expr=True)
always sets lower limit at 0, don't use for values that can be negative
Source code in mass2/core/channel.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
with_good_expr_nsigma_range_outlier_resistant(col_nsigma_pairs, replace=False, use_prev_good_expr=True)
always sets lower limit at 0, don't use for values that can be negative
Source code in mass2/core/channel.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|
with_select_step(col_expr_dict)
This step is meant for interactive exploration, it's basically like the df.select() method, but it's saved as a step.
Source code in mass2/core/channel.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
Channels
dataclass
Source code in mass2/core/channels.py
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 |
|
from_ljh_path_pairs(pulse_noise_pairs, description)
classmethod
Create a :class:Channels
instance from pairs of LJH files.
Args:
pulse_noise_pairs (List[Tuple[str, str]]):
A list of (pulse_path, noise_path)
tuples, where each entry contains
the file path to a pulse LJH file and its corresponding noise LJH file.
description (str):
A human-readable description for the resulting Channels object.
Returns:
Channels:
A Channels object with one :class:Channel
per (pulse_path, noise_path)
pair.
Raises: AssertionError: If two input files correspond to the same channel number.
Notes:
Each channel is created via :meth:Channel.from_ljh
.
The channel number is taken from the LJH file header and used as the key
in the returned Channels mapping.
Examples: >>> pairs = [ ... ("datadir/run0000_ch0000.ljh", "datadir/run0001_ch0000.ljh"), ... ("datadir/run0000_ch0001.ljh", "datadir/run0001_ch0001.ljh"), ... ] >>> channels = Channels.from_ljh_path_pairs(pairs, description="Test run") >>> list(channels.keys()) [0, 1]
Source code in mass2/core/channels.py
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 |
|
plot_hists(col, bin_edges, group_by_col, axis=None, use_expr=None, skip_none=True)
Plots histograms for the given column, grouped by the specified column.
Parameters: - col (str): The column name to plot. - bin_edges (array-like): The edges of the bins for the histogram. - group_by_col (str): The column name to group by. This is required. - axis (matplotlib.Axes, optional): The axis to plot on. If None, a new figure is created.
Source code in mass2/core/channels.py
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 |
|
save_recipes(filename, required_fields=None, drop_debug=True)
Pickle a dictionary (one entry per channel) of Recipe objects.
If you want to save a "recipe", a minimal series of steps required to reproduce the required field(s),
then set required_fields
to be a list/tuple/set of DataFrame column names (or a single column name)
whose production from raw data should be possible.
Parameters: |
|
---|
Returns: |
|
---|
Source code in mass2/core/channels.py
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 |
|
mass2.core.analysis_algorithms - main algorithms used in data analysis
Designed to abstract certain key algorithms out of the class MicrocalDataSet
and be able to run them fast.
Created on Jun 9, 2014
@author: fowlerj
HistogramSmoother
Object that can repeatedly smooth histograms with the same bin count and width to the same Gaussian width. By pre-computing the smoothing kernel for that histogram, we can smooth multiple histograms with the same geometry.
Source code in mass2/core/analysis_algorithms.py
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 |
|
__call__(values)
Return a smoothed histogram of the data vector
Source code in mass2/core/analysis_algorithms.py
210 211 212 213 214 215 216 |
|
__init__(smooth_sigma, limits)
Give the smoothing Gaussian's width as
Source code in mass2/core/analysis_algorithms.py
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 |
|
compute_max_deriv(pulse_data, ignore_leading, spike_reject=True, kernel=None)
Computes the maximum derivative in timeseries
Args: pulse_data: ignore_leading: spike_reject: (default True) kernel: the linear filter against which the signals will be convolved (CONVOLED, not correlated, so reverse the filter as needed). If None, then the default kernel of [+.2 +.1 0 -.1 -.2] will be used. If "SG", then the cubic 5-point Savitzky-Golay filter will be used (see below). Otherwise, kernel needs to be a (short) array which will be converted to a 1xN 2-dimensional np.ndarray. (default None)
Returns:
An np.ndarray, dimension 1: the value of the maximum derivative (units of
When kernel=="SG", then we estimate the derivative by Savitzky-Golay filtering (with 1 point before/3 points after the point in question and fitting polynomial of order 3). Find the right general area by first doing a simple difference.
Source code in mass2/core/analysis_algorithms.py
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 |
|
correct_flux_jumps(vals, mask, flux_quant)
Remove 'flux' jumps' from pretrigger mean.
When using umux readout, if a pulse is recorded that has a very fast rising edge (e.g. a cosmic ray), the readout system will "slip" an integer number of flux quanta. This means that the baseline level returned to after the pulse will different from the pretrigger value by an integer number of flux quanta. This causes that pretrigger mean summary quantity to jump around in a way that causes trouble for the rest of MASS. This function attempts to correct these jumps.
Arguments: vals -- array of values to correct mask -- mask indentifying "good" pulses flux_quant -- size of 1 flux quanta
Returns: Array with values corrected
Source code in mass2/core/analysis_algorithms.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
correct_flux_jumps_original(vals, mask, flux_quant)
Remove 'flux' jumps' from pretrigger mean.
When using umux readout, if a pulse is recorded that has a very fast rising edge (e.g. a cosmic ray), the readout system will "slip" an integer number of flux quanta. This means that the baseline level returned to after the pulse will different from the pretrigger value by an integer number of flux quanta. This causes that pretrigger mean summary quantity to jump around in a way that causes trouble for the rest of MASS. This function attempts to correct these jumps.
Arguments: vals -- array of values to correct mask -- mask indentifying "good" pulses flux_quant -- size of 1 flux quanta
Returns: Array with values corrected
Source code in mass2/core/analysis_algorithms.py
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 |
|
drift_correct(indicator, uncorrected, limit=None)
Compute a drift correction that minimizes the spectral entropy.
Args: indicator: The "x-axis", which indicates the size of the correction. uncorrected: A filtered pulse height vector. Same length as indicator. Assumed to have some gain that is linearly related to indicator. limit: The upper limit of uncorrected values over which entropy is computed (default None).
Generally indicator will be the pretrigger mean of the pulses, but you can experiment with other choices.
The entropy will be computed on corrected values only in the range [0, limit], so limit should be set to a characteristic large value of uncorrected. If limit is None (the default), then in will be compute as 25% larger than the 99%ile point of uncorrected.
The model is that the filtered pulse height PH should be scaled by (1 +
a*PTM) where a is an arbitrary parameter computed here, and PTM is the
difference between each record's pretrigger mean and the median value of all
pretrigger means. (Or replace "pretrigger mean" with whatever quantity you
passed in as
Source code in mass2/core/analysis_algorithms.py
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 |
|
estimateRiseTime(pulse_data, timebase, nPretrig)
Computes the rise time of timeseries
If nPretrig >= 4, then the samples pulse_data[:nPretrig] are averaged to estimate the baseline. Otherwise, the minimum of pulse_data is assumed to be the baseline.
Specifically, take the first and last of the rising points in the range of 10% to 90% of the peak value, interpolate a line between the two, and use its slope to find the time to rise from 0 to the peak.
Args: pulse_data: An np.ndarray of dimension 1 (a single pulse record) or 2 (an array with each row being a pulse record). timebase: The sampling time. nPretrig: The number of samples that are recorded before the trigger.
Returns: An ndarray of dimension 1, giving the rise times.
Source code in mass2/core/analysis_algorithms.py
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 |
|
filter_signal_lowpass(sig, fs, fcut)
Tophat lowpass filter using an FFT
Args: sig - the signal to be filtered fs - the sampling frequency of the signal fcut - the frequency at which to cutoff the signal
Returns: the filtered signal
Source code in mass2/core/analysis_algorithms.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
make_smooth_histogram(values, smooth_sigma, limit, upper_limit=None)
Convert a vector of arbitrary
This is a convenience function using the HistogramSmoother class.
Args: values: The vector of data to be histogrammed. smooth_sigma: The smoothing Gaussian's width (FWHM) limit, upper_limit: The histogram limits are [limit,upper_limit] or [0,limit] if upper_limit is None.
Returns: The smoothed histogram as an array.
Source code in mass2/core/analysis_algorithms.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
nearest_arrivals(reference_times, other_times)
Find the external trigger time immediately before and after each pulse timestamp
Args: pulse_timestamps - 1d array of pulse timestamps whose nearest neighbors need to be found. external_trigger_timestamps - 1d array of possible nearest neighbors.
Returns: (before_times, after_times)
before_times is an ndarray of the same size as pulse_timestamps. before_times[i] contains the difference between the closest lesser time contained in external_trigger_timestamps and pulse_timestamps[i] or inf if there was no earlier time in other_times Note that before_times is always a positive number even though the time difference it represents is negative.
after_times is an ndarray of the same size as pulse_timestamps. after_times[i] contains the difference between pulse_timestamps[i] and the closest greater time contained in other_times or a inf number if there was no later time in external_trigger_timestamps.
Source code in mass2/core/analysis_algorithms.py
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 |
|
time_drift_correct(time, uncorrected, w, sec_per_degree=2000, pulses_per_degree=2000, max_degrees=20, ndeg=None, limit=None)
Compute a time-based drift correction that minimizes the spectral entropy.
Args: time: The "time-axis". Correction will be a low-order polynomial in this. uncorrected: A filtered pulse height vector. Same length as indicator. Assumed to have some gain that is linearly related to indicator. w: the kernel width for the Laplace KDE density estimator sec_per_degree: assign as many as one polynomial degree per this many seconds pulses_per_degree: assign as many as one polynomial degree per this many pulses max_degrees: never use more than this many degrees of Legendre polynomial. n_deg: If not None, use this many degrees, regardless of the values of sec_per_degree, pulses_per_degree, and max_degress. In this case, never downsample. limit: The [lower,upper] limit of uncorrected values over which entropy is computed (default None).
The entropy will be computed on corrected values only in the range [limit[0], limit[1]], so limit should be set to a characteristic large value of uncorrected. If limit is None (the default), then it will be computed as 25%% larger than the 99%%ile point of uncorrected.
Possible improvements in the future: * Use Numba to speed up. * Allow the parameters to be function arguments with defaults: photons per degree of freedom, seconds per degree of freedom, and max degrees of freedom. * Figure out how to span the available time with more than one set of legendre polynomials, so that we can have more than 20 d.o.f. eventually, for long runs.
Source code in mass2/core/analysis_algorithms.py
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 |
|
unwrap_n(data, period, mask, n=3)
Unwrap data that has been restricted to a given period.
The algorithm iterates through each data point and compares it to the average of the previous n data points. It then offsets the data point by the multiple of the period that will minimize the difference from that n-point running average.
For the first n data points, there are not enough preceding points to average n of them, so the algorithm will average fewer points.
This code was written by Thomas Baker; integrated into MASS by Dan Becker. Sped up 300x by @njit.
Parameters: |
|
---|
Source code in mass2/core/analysis_algorithms.py
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 |
|
ColumnAsNumpyMapStep
dataclass
Bases: RecipeStep
This step is meant for interactive exploration, it takes a column and applies a function to it, and makes a new column with the result. It makes it easy to test functions on a column without having to write a whole new step class, while maintaining the benefit of being able to use the step in a Recipe chain, like replaying steps on another channel.
example usage:
def my_function(x): ... return x * 2 step = ColumnAsNumpyMapStep(inputs=["my_column"], output=["my_new_column"], f=my_function) ch2 = ch.with_step(step)
Source code in mass2/core/recipe.py
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 |
|
Recipe
dataclass
Source code in mass2/core/recipe.py
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 |
|
calc_from_df(df)
return a dataframe with all the newly calculated info
Source code in mass2/core/recipe.py
188 189 190 191 192 |
|
trim_dead_ends(required_fields, drop_debug=True)
Create a new Recipe object with all dead-end steps (and optionally also debug info) removed.
The purpose is to replace the fully useful interactive Recipe with a trimmed-down object that can
repeat the current steps as a "recipe" without having the extra information from which the recipe
was first created. In one test, this method reduced the pickle file's size from 3.4 MB per channel
to 30 kB per channel, or a 112x size reduction (with drop_debug=True
).
Dead-end steps are defined as any step that can be omitted without affecting the ability to
compute any of the fields given in required_fields
. The result of this method is to return
a Recipe where any step is remove if it does not contribute to computing any of the required_fields
(i.e., if it is a dead end).
Examples of a dead end are typically steps used to prepare a tentative, intermediate calibration function.
Parameters: |
|
---|
Returns: |
|
---|
Source code in mass2/core/recipe.py
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 |
|
RecipeStep
dataclass
Source code in mass2/core/recipe.py
10 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 |
|
drop_debug()
Return self, or a copy of it with debug information removed
Source code in mass2/core/recipe.py
35 36 37 |
|
SelectStep
dataclass
Bases: RecipeStep
This step is meant for interactive exploration, it's basically like the df.select() method, but it's saved as a step.
Source code in mass2/core/recipe.py
167 168 169 170 171 172 173 174 175 176 177 178 |
|
Classes to create time-domain and Fourier-domain optimal filters.
Filter
dataclass
Bases: ABC
A single optimal filter, possibly with optimal estimators of the Delta-t and of the DC level.
Returns: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
is_arrival_time_safe
abstractmethod
property
Is this an arrival-time-safe filter?
plot(axis=None, **kwargs)
Make a plot of the filter
Parameters: |
|
---|
Source code in mass2/core/optimal_filtering.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
report(std_energy=5898.8)
Report on estimated V/dV for the filter.
Parameters: |
|
---|
Source code in mass2/core/optimal_filtering.py
298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
Filter5Lag
dataclass
Bases: Filter
Represent an optimal filter, specifically one intended for 5-lag convolution with data
The traditional 5-lag filter used by default until 2015.
Returns: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
is_arrival_time_safe
property
Is this an arrival-time-safe filter?
filter_records(x)
Filter one microcalorimeter record or an array of records.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
FilterATS
dataclass
Bases: Filter
Represent an optimal filter according to the arrival-time-safe, single-lag design of 2015.
Returns: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
is_arrival_time_safe
property
Is this an arrival-time-safe filter?
filter_records(x)
Filter one microcalorimeter record or an array of records.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
FilterMaker
dataclass
An object capable of creating optimal filter based on a single signal and noise set.
Parameters: |
|
---|
Notes
-
If both
noise_autocorr
andwhitener
are None, then methodscompute_5lag
andcompute_ats
will both fail, as they require a time-domain characterization of the noise. -
The units of
noise_autocorr
are the square of the units used insignal_model
and/orpeak
. The units ofwhitener
are the inverse of the signal units. Any rescaling of the noise autocorrelation or whitener does not affect any filter values, but only the predicted signal/noise ratios. -
The units of
noise_psd
are square signal units, per Hertz.
Returns: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 |
|
compute_5lag(fmax=None, f_3db=None, cut_pre=0, cut_post=0)
Compute a single filter, with optional low-pass filtering, and with optional zero weights at the pre-trigger or post-trigger end of the filter.
Either or both of fmax
and f_3db
are allowed.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
compute_5lag_noexp(exp_time_seconds, fmax=None, f_3db=None, cut_pre=0, cut_post=0)
Compute a single filter, with optional low-pass filtering, and with optional zero weights at the pre-trigger or post-trigger end of the filter.
Either or both of fmax
and f_3db
are allowed.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
compute_ats(fmax=None, f_3db=None, cut_pre=0, cut_post=0)
Compute a single "arrival-time-safe" filter, with optional low-pass filtering, and with optional zero weights at the pre-trigger or post-trigger end of the filter.
Either or both of fmax
and f_3db
are allowed.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 |
|
compute_constrained_5lag(constraints=None, fmax=None, f_3db=None, cut_pre=0, cut_post=0)
Compute a single constrained optimal filter, with optional low-pass filtering, and with optional zero weights at the pre-trigger or post-trigger end of the filter.
Either or both of fmax
and f_3db
are allowed.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
compute_fourier(fmax=None, f_3db=None, cut_pre=0, cut_post=0)
Compute a single Fourier-domain filter, with optional low-pass filtering, and with optional zero weights at the pre-trigger or post-trigger end of the filter. Fourier domain calculation implicitly assumes periodic boundary conditions.
Either or both of fmax
and f_3db
are allowed.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
|
ToeplitzWhitener
dataclass
An object that can perform approximate noise whitening.
For an ARMA(p,q) noise model, mutliply by (or solve) the matrix W (or its transpose), where W is the Toeplitz approximation to the whitening matrix V. A whitening matrix V means that if R is the ARMA noise covariance matrix, then VRV' = I. While W only approximately satisfies this, it has some handy properties that make it a useful replacement. (In particular, it has the time-transpose property that if you zero-pad the beginning of vector v and shift the remaining elements, then the same is done to Wv.)
The callable function object returns Wv or WM if called with vector v or matrix M. Other methods:
tw.whiten(v)
returns Wv; it is equivalent totw(v)
tw.solveWT(v)
returns inv(W')*vtw.applyWT(v)
returns W'vtw.solveW(v)
returns inv(W)*v
Arguments
theta : np.ndarray The moving-average (MA) process coefficients phi : np.ndarray The autoregressive (AR) process coefficients
Returns: |
|
---|
Raises: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
W(N)
Return the full, approximate whitening matrix.
Normally the full W is large and slow to use. But it's here so you can easily test that W(len(v))*v == whiten(v), and similar.
Source code in mass2/core/optimal_filtering.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
__call__(v)
Return whitened vector (or matrix of column vectors) Wv
Source code in mass2/core/optimal_filtering.py
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 |
|
applyWT(v)
Return vector (or matrix of column vectors) W'v
Source code in mass2/core/optimal_filtering.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
solveW(v)
Return unwhitened vector (or matrix of column vectors) inv(W)*v
Source code in mass2/core/optimal_filtering.py
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 |
|
solveWT(v)
Return vector (or matrix of column vectors) inv(W')*v
Source code in mass2/core/optimal_filtering.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
whiten(v)
Return whitened vector (or matrix of column vectors) Wv
Source code in mass2/core/optimal_filtering.py
65 66 67 |
|
band_limit(modelmatrix, sample_time_sec, fmax, f_3db)
Band-limit the column-vectors in a model matrix with a hard and/or
1-pole low-pass filter. Change the input modelmatrix
in-place.
No effect if both fmax
and f_3db
are None
.
Parameters: |
|
---|
Source code in mass2/core/optimal_filtering.py
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 |
|
bracketR(q, noise)
Return the dot product (q^T R q) for vector and matrix R constructed from
the vector
Source code in mass2/core/optimal_filtering.py
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 |
|