Calibration Module
Calibration analysis module for LAT-SAT cross-spectrum studies.
This module provides classes for fitting calibration parameters (angles and amplitudes) using cross-correlations between Large Aperture Telescope (LAT) and Small Aperture Telescope (SAT) data from CMB observations.
- class BaseSat4LatCross(spec_cross, sat_err, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', libdir_suffix='BaseSat4LatCross', num_sims=100, verbose=False)[source]
Bases:
ABCBase class for LAT-SAT cross-spectrum calibration analyses.
Provides data loading, beam handling, and plotting logic. Subclasses must define:
self.__pnames__ / self.__plabels__
self.theory(theta)
self.lnprior(theta)
- Parameters:
- spec_cross
Cross-spectrum calculation object
- sat_err
Satellite calibration error
- sat_lrange
Satellite ell range for fitting
- lat_lrange
LAT ell range for fitting
- fit_per_split
Whether to fit per split or per frequency
- spectra_selection
Which spectra to include (‘all’, ‘auto_only’, ‘cross_only’)
- libdir
Directory for caching results
- binner
Binning information object
- Lmax
Maximum multipole
- maptags
List of map tags
- freq_groups
Dictionary mapping frequency bases to indices
- freq_bases
List of frequency base names
- mean_spec
Mean spectra from simulations
- std_spec
Standard deviation of spectra
- beam_arr
Beam transfer function array
- __init__(spec_cross, sat_err, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', libdir_suffix='BaseSat4LatCross', num_sims=100, verbose=False)[source]
- abstract theory(theta)[source]
Calculate theoretical model spectrum for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Model spectrum array with shape matching data
- Return type:
- abstract lnprior(theta)[source]
Calculate log prior probability for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Log prior probability
- Return type:
- chisq(theta)[source]
Calculate chi-squared statistic for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Chi-squared value
- Return type:
- ln_likelihood(theta)[source]
Calculate log likelihood for given parameters.
- Parameters:
theta (numpy.ndarray)
- Return type:
- ln_prob(theta)[source]
Calculate log posterior probability for given parameters.
- Parameters:
theta (numpy.ndarray)
- Return type:
- run_mcmc(nwalkers=32, nsamples=2000, rerun=False, fiducial_params=None, fname=None)[source]
- Parameters:
nwalkers (int)
nsamples (int)
rerun (bool)
fiducial_params (numpy.ndarray | None)
fname (str | None)
- Return type:
- getdist_samples(nwalkers, nsamples, rerun=False, fiducial_params=None, label=None)[source]
- Parameters:
nwalkers (int)
nsamples (int)
rerun (bool)
fiducial_params (numpy.ndarray | None)
label (str | None)
- Return type:
getdist.MCSamples
- plot_posteriors(nwalkers, nsamples, rerun=False, label=None, fiducial_params=None)[source]
- Parameters:
nwalkers (int)
nsamples (int)
rerun (bool)
label (str | None)
fiducial_params (numpy.ndarray | None)
- plot_spectra_matrix(theta=None, save_path=None, average_split=False)[source]
Plots the mean data spectra with std deviation and optionally a theory curve in a matrix layout corresponding to all cross-correlations.
- Parameters:
theta (numpy.ndarray | None) – Parameter vector (alphas, beta, A_EB, etc.) for theory overlay.
save_path (str | None) – If given, saves the figure instead of showing.
average_split (bool) – If True, average spectra across splits per frequency.
- Return type:
None
- class Sat4LatCross(spec_cross, sat_err, beta_fid, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', num_sims=100, verbose=False)[source]
Bases:
BaseSat4LatCrossCalibration model fitting for birefringence angle β.
This class implements a calibration analysis that fits calibration angles (alphas) and the cosmic birefringence angle β using EB cross-spectra between LAT and SAT.
- Parameters:
- cl_len
Lensed CMB power spectra dictionary
- __init__(spec_cross, sat_err, beta_fid, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', num_sims=100, verbose=False)[source]
Initialize calibration analysis for birefringence angle fitting.
- Parameters:
spec_cross (SpectraCross) – Cross-spectrum calculation object
sat_err (float) – Satellite calibration error
beta_fid (float) – Fiducial birefringence angle for theory calculation
sat_lrange (Tuple[int | None, int | None]) – Satellite ell range for fitting (lmin, lmax)
lat_lrange (Tuple[int | None, int | None]) – LAT ell range for fitting (lmin, lmax)
fit_per_split (bool) – Whether to fit per split or per frequency
spectra_selection (str) – Which spectra to include (‘all’, ‘auto_only’, ‘cross_only’)
verbose (bool) – Whether to enable verbose output
num_sims (int)
- Return type:
None
- theory(theta)[source]
Compute theoretical EB spectra between all map pairs using the exact birefringence + miscalibration formula:
- C_ell^{E_iB_j} = cos(2α_i+2β)sin(2α_j+2β)C_EE
sin(2α_i+2β)cos(2α_j+2β)C_BB
- Parameters:
theta (numpy.ndarray)
- Return type:
- lnprior(theta)[source]
Calculate log prior probability for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Log prior probability
- Return type:
- class Sat4LatCross_AmplitudeFit(spec_cross, sat_err, temp_model, temp_value, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', sim_idx=None, alpha_lat_prior='gaussian', fix_alpha=False, num_sims=100, verbose=False)[source]
Bases:
BaseSat4LatCrossCalibration model fitting for amplitude parameter A_EB.
This class implements a calibration analysis that fits calibration angles (alphas) and an amplitude parameter A_EB using EB cross-spectra between LAT and SAT.
- Parameters:
- eb_template_unbinned
Unbinned EB template spectrum
- binned_template
Binned EB template spectrum
- cl_len
Lensed CMB power spectra dictionary
- cl_diff_unbinned
Unbinned difference spectrum (EE - BB)/2
- __init__(spec_cross, sat_err, temp_model, temp_value, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', sim_idx=None, alpha_lat_prior='gaussian', fix_alpha=False, num_sims=100, verbose=False)[source]
Initialize calibration analysis for amplitude parameter fitting.
- Parameters:
spec_cross (SpectraCross) – Cross-spectrum calculation object
sat_err (float) – Satellite calibration error
temp_model (str) – Template model (‘iso’ or ‘iso_td’)
temp_value (float) – Template parameter value (beta for ‘iso’, mass for ‘iso_td’)
sat_lrange (Tuple[int | None, int | None]) – Satellite ell range for fitting (lmin, lmax)
lat_lrange (Tuple[int | None, int | None]) – LAT ell range for fitting (lmin, lmax)
fit_per_split (bool) – Whether to fit per split or per frequency
spectra_selection (str) – Which spectra to include (‘all’, ‘auto_only’, ‘cross_only’)
sim_idx (int | None) – Simulation index to use for data (default: 0)
alpha_lat_prior (str) – Prior type for LAT alpha parameters (‘gaussian’ or ‘flat’)
fix_alpha (bool) – Whether to fix alpha parameters (calibration angles) to zero
verbose (bool) – Whether to enable verbose output
num_sims (int)
- Return type:
None
- theory(theta)[source]
Calculate theoretical model spectrum for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Model spectrum array with shape matching data
- Return type:
- lnprior(theta)[source]
Calculate log prior probability for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Log prior probability
- Return type:
Helper Functions
Base Classes
- class BaseSat4LatCross(spec_cross, sat_err, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', libdir_suffix='BaseSat4LatCross', num_sims=100, verbose=False)[source]
Base class for LAT-SAT cross-spectrum calibration analyses.
Provides data loading, beam handling, and plotting logic. Subclasses must define:
self.__pnames__ / self.__plabels__
self.theory(theta)
self.lnprior(theta)
- Parameters:
- spec_cross
Cross-spectrum calculation object
- sat_err
Satellite calibration error
- sat_lrange
Satellite ell range for fitting
- lat_lrange
LAT ell range for fitting
- fit_per_split
Whether to fit per split or per frequency
- spectra_selection
Which spectra to include (‘all’, ‘auto_only’, ‘cross_only’)
- libdir
Directory for caching results
- binner
Binning information object
- Lmax
Maximum multipole
- maptags
List of map tags
- freq_groups
Dictionary mapping frequency bases to indices
- freq_bases
List of frequency base names
- mean_spec
Mean spectra from simulations
- std_spec
Standard deviation of spectra
- beam_arr
Beam transfer function array
- __init__(spec_cross, sat_err, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', libdir_suffix='BaseSat4LatCross', num_sims=100, verbose=False)[source]
- abstract theory(theta)[source]
Calculate theoretical model spectrum for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Model spectrum array with shape matching data
- Return type:
- abstract lnprior(theta)[source]
Calculate log prior probability for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Log prior probability
- Return type:
- _build_likelihood_mask()[source]
Build boolean mask for likelihood evaluation based on ell ranges.
- Returns:
Boolean mask array with shape (n_tags, n_tags, n_bins)
- Return type:
- _calc_mean_std(num_sims=100)[source]
Calculate mean and standard deviation of spectra over simulations.
- Parameters:
num_sims (int) – Number of simulations to use
- Returns:
Tuple of (mean_spectrum, std_spectrum) arrays
- Return type:
- _get_beam_arr()[source]
Calculate beam transfer function array for all map tag combinations.
- Returns:
Beam array with shape (n_tags, n_tags, n_bins)
- Return type:
- chisq(theta)[source]
Calculate chi-squared statistic for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Chi-squared value
- Return type:
- ln_likelihood(theta)[source]
Calculate log likelihood for given parameters.
- Parameters:
theta (numpy.ndarray)
- Return type:
- ln_prob(theta)[source]
Calculate log posterior probability for given parameters.
- Parameters:
theta (numpy.ndarray)
- Return type:
- run_mcmc(nwalkers=32, nsamples=2000, rerun=False, fiducial_params=None, fname=None)[source]
- Parameters:
nwalkers (int)
nsamples (int)
rerun (bool)
fiducial_params (numpy.ndarray | None)
fname (str | None)
- Return type:
- getdist_samples(nwalkers, nsamples, rerun=False, fiducial_params=None, label=None)[source]
- Parameters:
nwalkers (int)
nsamples (int)
rerun (bool)
fiducial_params (numpy.ndarray | None)
label (str | None)
- Return type:
getdist.MCSamples
- plot_posteriors(nwalkers, nsamples, rerun=False, label=None, fiducial_params=None)[source]
- Parameters:
nwalkers (int)
nsamples (int)
rerun (bool)
label (str | None)
fiducial_params (numpy.ndarray | None)
- plot_spectra_matrix(theta=None, save_path=None, average_split=False)[source]
Plots the mean data spectra with std deviation and optionally a theory curve in a matrix layout corresponding to all cross-correlations.
- Parameters:
theta (numpy.ndarray | None) – Parameter vector (alphas, beta, A_EB, etc.) for theory overlay.
save_path (str | None) – If given, saves the figure instead of showing.
average_split (bool) – If True, average spectra across splits per frequency.
- Return type:
None
- _abc_impl = <_abc._abc_data object>
Calibration Classes
- class Sat4LatCross(spec_cross, sat_err, beta_fid, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', num_sims=100, verbose=False)[source]
Bases:
BaseSat4LatCrossCalibration model fitting for birefringence angle β.
This class implements a calibration analysis that fits calibration angles (alphas) and the cosmic birefringence angle β using EB cross-spectra between LAT and SAT.
- Parameters:
- cl_len
Lensed CMB power spectra dictionary
- __init__(spec_cross, sat_err, beta_fid, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', num_sims=100, verbose=False)[source]
Initialize calibration analysis for birefringence angle fitting.
- Parameters:
spec_cross (SpectraCross) – Cross-spectrum calculation object
sat_err (float) – Satellite calibration error
beta_fid (float) – Fiducial birefringence angle for theory calculation
sat_lrange (Tuple[int | None, int | None]) – Satellite ell range for fitting (lmin, lmax)
lat_lrange (Tuple[int | None, int | None]) – LAT ell range for fitting (lmin, lmax)
fit_per_split (bool) – Whether to fit per split or per frequency
spectra_selection (str) – Which spectra to include (‘all’, ‘auto_only’, ‘cross_only’)
verbose (bool) – Whether to enable verbose output
num_sims (int)
- Return type:
None
- theory(theta)[source]
Compute theoretical EB spectra between all map pairs using the exact birefringence + miscalibration formula:
- C_ell^{E_iB_j} = cos(2α_i+2β)sin(2α_j+2β)C_EE
sin(2α_i+2β)cos(2α_j+2β)C_BB
- Parameters:
theta (numpy.ndarray)
- Return type:
- lnprior(theta)[source]
Calculate log prior probability for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Log prior probability
- Return type:
- class Sat4LatCross_AmplitudeFit(spec_cross, sat_err, temp_model, temp_value, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', sim_idx=None, alpha_lat_prior='gaussian', fix_alpha=False, num_sims=100, verbose=False)[source]
Bases:
BaseSat4LatCrossCalibration model fitting for amplitude parameter A_EB.
This class implements a calibration analysis that fits calibration angles (alphas) and an amplitude parameter A_EB using EB cross-spectra between LAT and SAT.
- Parameters:
- eb_template_unbinned
Unbinned EB template spectrum
- binned_template
Binned EB template spectrum
- cl_len
Lensed CMB power spectra dictionary
- cl_diff_unbinned
Unbinned difference spectrum (EE - BB)/2
- __init__(spec_cross, sat_err, temp_model, temp_value, sat_lrange=(None, None), lat_lrange=(None, None), fit_per_split=True, spectra_selection='all', sim_idx=None, alpha_lat_prior='gaussian', fix_alpha=False, num_sims=100, verbose=False)[source]
Initialize calibration analysis for amplitude parameter fitting.
- Parameters:
spec_cross (SpectraCross) – Cross-spectrum calculation object
sat_err (float) – Satellite calibration error
temp_model (str) – Template model (‘iso’ or ‘iso_td’)
temp_value (float) – Template parameter value (beta for ‘iso’, mass for ‘iso_td’)
sat_lrange (Tuple[int | None, int | None]) – Satellite ell range for fitting (lmin, lmax)
lat_lrange (Tuple[int | None, int | None]) – LAT ell range for fitting (lmin, lmax)
fit_per_split (bool) – Whether to fit per split or per frequency
spectra_selection (str) – Which spectra to include (‘all’, ‘auto_only’, ‘cross_only’)
sim_idx (int | None) – Simulation index to use for data (default: 0)
alpha_lat_prior (str) – Prior type for LAT alpha parameters (‘gaussian’ or ‘flat’)
fix_alpha (bool) – Whether to fix alpha parameters (calibration angles) to zero
verbose (bool) – Whether to enable verbose output
num_sims (int)
- Return type:
None
- theory(theta)[source]
Calculate theoretical model spectrum for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Model spectrum array with shape matching data
- Return type:
- lnprior(theta)[source]
Calculate log prior probability for given parameters.
- Parameters:
theta (numpy.ndarray) – Parameter vector
- Returns:
Log prior probability
- Return type: