config
Module for handling all configuration of scripts.
Config File Fields
General pipeline settings
cfg.root_dir
Root directory for output products.
cfg.tel
Telescope identifier used when constructing the output directory tree.
cfg.pointing_type
Pointing type used to distinguish beam-analysis products. ie. pointing_model, raw, etc.
cfg.append
Optional suffix appended to the output directory name.
cfg.test_append
Optional suffix used when naming directories and jobdb. Mostly used for testing and one-offs.
cfg.copy_fits_test
If True when when test_append is not "" then make a copy of the beam fits.
This will overwrite an existing file.
cfg.single_det
Whether the analysis is operating on single-detector data.
When True,_single_det is appended to the output directory name.
cfg.ctx_path
Path to the sotodlib context.
cfg.preprocess_cfg
Path to the preprocessing configuration used to load and preprocess the data before fitting or mapmaking.
cfg.source_list
List of source names to process. Note that this has the following aliases:
map_source_list: used inmake_source_map.fit_source_list: used infit_source_map.
This distiction is because there are sources we want to map that we do not want to fit in the standard pipeline (ie. TauA).
cfg.start_time
Lower bound on the observation timestamp used when selecting jobs.
If args.lookback is passed then this becomes the current time minus the lookback.
cfg.stop_time
Upper bound on the observation timestamp used when selecting jobs.
If args.lookback is passed then this becomes the current time.
cfg.fwhm_tol
Fractional tolerance between the measured radial FWHM and the
nominal band FWHM. A fit is rejected when: abs(1 - data_fwhm / nominal_fwhm) > fwhm_tol
This is aliased to fwhm_tol_map for map fitting
and fwhm_tol_pointing for pointing fits..
cfg.nominal_fwhm
Mapping from observing band to nominal beam FWHM. These values are used for the initial Gaussian fit, FWHM quality cuts, noise estimation, and stacking diagnostics. These should be in arcmins and should be a dict where each key is a bandname (ie. "f090").
cfg.min_samps
Minimum number of source-flagged samples required for a pointing fit to proceed. It is also used when deciding which detectors have enough source-flagged samples to remain in the fit.
cfg.min_dets
Minimum number of detectors required after cuts.
Mapmaking
cfg.extent
Angular extent of the map region used for beam fitting and stacking. Also used when generating fitted-model and residual diagnostic plots. Should be in arcseconds.
cfg.res
Target pixel resolution used when constructing the common tangent-plane WCS for beam maps and high-resolution profile calculations. Should be in radians.
cfg.mask_size
Angular size of the mask used during mapmaking and beam-model fitting.
When cfg.apply_fscale is enabled, the fitting stage scales this value
according to the observing frequency before converting it to radians.
This is aliased by map_mask_size.
cfg.apply_fscale
Whether beam-mask is adjusted according to observing frequency.
When enabled, the mask is scaled by 90 / frequency_GHz.
cfg.aperature
Aperture size used by the Bessel beam model. The fitting stage
converts this value to a Quantity in meters before passing it
to the Bessel fitting routine.
cfg.buf
Buffer used when estimating the beam center on the original map. In units of pixels.
cfg.buf_cropped
Buffer used when estimating the beam center after the map has been cropped, again in pixels.
cfg.smooth_kern
Angular smoothing scale used when estimating the beam center.
cfg.snr_extent
Angular extent around the estimated beam center excluded when estimating map noise for the initial SNR calculation.
cfg.extent_highres
Angular extent of the high-resolution map used for calculating the final profile and covariance.
cfg.pixsize_highres
Pixel size for the high-resolution final profile.
cfg.search_mask
Mask definition used to search for the source in an initial map.
cfg.del_map
If True delete maps that don't pass cuts in mapmaking.
cfg.cgiters_single
Number of CG iters used when making a single obs ML map.
cfg.cgiters_full
Number of CG iters used when making a full ML map.
cfg.mlpass
Number of passes to run the ML mapmaker for.
cfg.comps
Which comps to mapmake. Should be "T" or "TQU".
cfg.force_zero_cent
Whether map-fitting workflows force the beam center to zero instead of fitting for a recenter.
cfg.n_modes
Number of modes to remove when mapmaking.
cfg.relcal_range
Allowed relative calibration range.
cfg.min_det_secs
Minimum number of detector seconds in the source mask needed to mapmake.
Pointing fits
cfg.forced_ws
Wafer-slot identifiers that are forced to be processed even when they are not present in the observation's source tags. The pointing-fit script uses these values when constructing the set of wafer slots eligible for fitting.
cfg.try_all
If True then try all wafer slots. This will override forced_ws.
cfg.max_dur
Maximum allowed observation duration, in hours, when selecting pointing-fit observations from the observation database.
cfg.nominal_path
Path to the nominal focal-plane pointing model. The pointing-fit script loads this HDF5 file and uses it to obtain nominal detector positions, calculate the UFM radius, and provide nominal pointing information for source masking.
cfg.pointing_mask
Mask definition used when generating source flags with the centered
source flagger. The pointing-fit script passes this configuration to
sotodlib.coords.planets.compute_source_flags to identify samples
containing the astronomical source.
cfg.ds
Downsampling factor applied to the TOD before filtering and fitting.
cfg.hp_fc
High-pass filter cutoff frequency used when filtering the TOD before the pointing fit. It is also passed to fit_tod_pointing as part of the filter configuration.
cfg.lp_fc
Low-pass filter cutoff frequency used when filtering the TOD before the pointing fit. It is also passed to fit_tod_pointing as part of the filter configuration.
cfg.n_med
Multiplier applied to the median detector noise when rejecting unusually noisy detectors within each frequency band.
cfg.n_std
Number of standard deviations used by source-flagging logic. It controls the threshold in the blind and SVD source flaggers.
cfg.block_size
Time/sample block size used by source-flagging logic. It controls the minimum extent and separation of flagged source regions and the buffering applied to source flags.
cfg.trim_samps
Number of samples trimmed from each edge of the downsampled TOD to avoid Fourier-filter ringing.
cfg.min_hits
Minimum number of source hits required for an individual detector fit to be considered acceptable.
cfg.high_hits
Higher hit-count threshold used when identifying a sufficiently well-sampled set of detectors for estimating the center of the array.
cfg.max_chisq
Maximum allowed reduced chi-squared for an individual pointing fit. Detectors with reduced chi-squared above this threshold are marked as bad.
cfg.min_R2
Minimum acceptable R2 value for a pointing fit. Fits below this threshold are excluded from the focal-plane diagnostic plot and treated as bad fits.
cfg.svd_modes
Number of SVD modes used by the SVD-based source flagger. When source filtering is enabled, the same value is also passed to cp.filter_for_sources.
cfg.svd_iters
Number of iterations used by the SVD-based source flagger.
cfg.iter_svd_sub
Whether the SVD-derived common mode is subtracted from the TOD after SVD source identification.
cfg.filter_for_sources
Whether the pointing-fit TOD is additionally filtered using the source flags and SVD modes before fitting.
cfg.source_flag_exp
Expression defining how source flags are combined. The default
expression is (svd + blind) * cent. The pointing-fit script
evaluates this expression using source flags supplied by the SVD,
blind, and centered source flaggers.
cfg.fit_pars
Additional keyword arguments passed directly to fit_tod_pointing.
cfg.pad
Whether the pointing-fit result is padded with detectors that were present in the observation metadata but did not produce a fitted result. When enabled, missing detectors are added with NaN values for floating-point fit fields.
cfg.src_msk
Whether samples identified by the source-flag expression are used to restrict the TOD to the source-crossing region and remove detectors with insufficient source-flagged samples.
Beam-fit configuration
cfg.sym_gauss
Whether the Gaussian beam fit is constrained to be symmetric.
cfg.min_snr
Minimum SNR required for an individual beam map to proceed through the fitting stage.
cfg.bessel_beam
Whether to fit the Bessel-based beam model after the Gaussian fit.
cfg.min_sigma
Minimum allowed beam-model width used when validating and processing fitted Gaussian and Bessel model parameters. Set to a negetive value to use the whole map.
cfg.n_bessel
Number of Bessel terms/components used by the Bessel beam fit.
cfg.n_multipoles
Number of multipoles included in the Bessel beam model. This also controls the number of non-axisymmetric beam modes shown in fitting diagnostics.
cfg.skip_multipoles
Multipoles excluded from the Bessel beam fit.
cfg.bessel_wing_n_sigma
Controls the extent of the Bessel-model wing relative to the fitted beam. When frequency scaling is enabled, the fitting stage scales this value by the same factor used for the beam mask.
cfg.gauss_multipole
If True fit for the multipole expansion of the Gauss fit.
cfg.corr_primary
Error correlation scale of the mirror in mm.
info" "cfg.eps_primary
RMS error of the mirror in um-rms.
Stacking quality cuts
cfg.min_stack_snr
Minimum fitted beam SNR required for an observation to contribute to a stack.
cfg.max_pwv
Maximum allowed PWV/elevation-corrected atmospheric loading.
Fits are retained only when: pwv / sin(elevation) <= max_pwv.
cfg.max_cut_pix_frac
Maximum allowed fraction of pixels masked or removed from a candidate beam map before it is rejected from a stack.
cfg.min_irat
Minimum acceptable inverse-variance median-to-variance ratio. Used to reject maps with poorly behaved or highly structured inverse variance.
cfg.max_cn
Threshold on the logarithm of the correlated/white noise levels used during map-quality selection.
cfg.corr_ratio_cut
Maximum allowed correlated-to-white-noise ratio, subject to the adjustment based on the absolute noise levels.
cfg.miscenter_thresh
Maximum allowed displacement, in pixels, between the estimated beam center and the expected center of the reprojected map.
Noise and diagnostic configuration
cfg.n_lmin
Lower multipole bound used when estimating map noise.
cfg.n_lmax
Upper multipole bound used when estimating map noise.
cfg.log_thresh
Logarithmic threshold used when generating beam-map diagnostic plots.
cfg.empir_cov
Whether to calculate empirical covariance information from the individual beam fits. In the fitting stage, empirical covariance is loaded when more than five contributing fits are available. It also controls whether empirical scatter based summary plots are generated.
cfg.lmax
Maximum multipole used when calculating the beam window function and Bessel profile covariance.
cfg.cov_modes
Number or configuration of covariance modes retained when calculating the Bessel profile covariance.
Split and epoch configuration
cfg.det_split_dir
Directory associated with detector splits. This field is initialized by setup_cfg but is not directly used by the pointing-fit script.
cfg.det_splits
Detector split names to process. Each script automatically adds
"full" to this list when selecting stack-map jobs.
cfg.split_by
Split dimensions used to select stack jobs for fitting.
These can be anything that beam_utils.get_split_vec can
understand.
cfg.metasplits
Metadata split definitions passed to the beam-processing utilities when constructing split vectors.
cfg.epochs
Sequence of (start, end) time ranges over which stack jobs are
constructed or selected. The fitting stage only processes jobs whose
epoch range matches one of these configured ranges.
deep_merge(a, b)
Recursively merge two dictionaries.
Values from b take precedence over values from a. When a key
exists in both dictionaries and both corresponding values are
dictionaries, those dictionaries are merged recursively. All other
values from b replace the corresponding values from a.
Values are deep-copied when inserted into the result, so mutable values
in the input dictionaries are not shared with the returned dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
dict[str, Any]
|
The base dictionary. |
required |
b
|
dict[str, Any]
|
The dictionary whose values take precedence. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A new dictionary containing the recursively merged values. Neither input dictionary is modified. |
Source code in lat_beams/utils/config.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 | |
get_args_cfg()
Parse command-line arguments and load the configuration file.
Run the script with --help for details.
Returns:
| Name | Type | Description |
|---|---|---|
args |
Namespace
|
Parsed command-line arguments. |
cfg |
dict[str, Any]
|
Configuration loaded from the YAML file.
This is loaded recursively, see |
Source code in lat_beams/utils/config.py
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 | |
load_config(start_cfg, cfg_path)
Load a configuration file and recursively merge its base configuration.
The configuration at cfg_path is loaded and merged with
start_cfg. If the loaded configuration contains a base key then
the referenced base configuration is loaded recursively and is merged in.
Values from the more specific configuration take precedence over values from its base configuration.
Note that relative "base" paths are resolved relative to the directory
containing the configuration file that references them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_cfg
|
dict[str, Any]
|
Configuration values that take precedence over values loaded from |
required |
cfg_path
|
str
|
Path to the YAML configuration file to load. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The fully merged configuration. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
YAMLError
|
If a configuration file contains invalid YAML. |
Source code in lat_beams/utils/config.py
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 | |
setup_cfg(args, cfg, replace=None, apply_ds=False)
Apply defaults and command-line overrides to a loaded configuration.
This also lets you rename things. When loading from cfg_str you
don't need to apply any processing, you can just convert directly
to a dict to get the final config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments. |
required |
cfg
|
dict[str, Any]
|
Configuration dictionary to modify. |
required |
replace
|
Optional[dict[str, str]]
|
Mapping of configuration keys to rename. Keys present in |
None
|
apply_ds
|
bool
|
Whether downsampling should be applied when calculating sample-dependent configuration values. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
cfg |
Namespace
|
Configuration converted to an attribute-accessible namespace. |
cfg_str |
str
|
YAML representation of the final configuration. |
Source code in lat_beams/utils/config.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 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 | |
setup_paths(root_dir, project, tel, append='')
Create and return the plot and data directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dir
|
str
|
Root directory under which the project directories are created. |
required |
project
|
str
|
Project name used to construct the directory paths. |
required |
tel
|
str
|
Telescope name used to construct the directory paths. |
required |
append
|
str
|
Additional path component appended to the project/telescope paths. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
plot_dir |
str
|
Path to the plot directory. |
data_dir |
str
|
Path to the data directory. |
Source code in lat_beams/utils/config.py
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 | |