calibration
The calibration project contains data classes and analysis code for storing the following things:
- Physical properties of the bolometers
This includes the relative pointing offsets of the detectors on the focal plane, their polarization angles and efficiences, their bands, and the fabrication name (physical name) of the detector to which the channel corresponds. It does not include tuning-dependent parameters like time constants or responsivity. This information is stored in a
BolometerPropertiesMap
, indexed by logical bolometer ID, in the Calibration frame. The standard name for this object is “BolometerProperties” and it is created from a composite of other calibration information.The frequency band for a bolometer is often represented by a string name with units. The
BandFormat
class provides some functions for converting numerical bands (in G3Units) to their string representation. A global instance of this class is instantiated, for ensuring consistent band formatting throughout the library code. By default, the band string is formatted with precision 0 (i.e. an integer) in units of GHz; these can be modified by using theset_band_format()
function. Theband_to_string()
andband_to_value()
functions can be used to convert numerical band values to their string representation and vice versa. Theextract_band_string()
andextract_band_value()
functions can be used to extract band information in string or numerical form from other strings. Library code should take care to use these functions wherever possible.In addition, the
.band_string
property of aBolometerProperties
instance returns the string representation of the given bolometer’s frequency band, using the global formatting specification.
API Documentation
Frame Objects
Serializable objects that may be stored as entries in G3Frame
objects.
- class spt3g.calibration.BolometerProperties(arg: BolometerProperties)
- class spt3g.calibration.BolometerProperties()
Bases:
G3FrameObject
Physical bolometer properties, such as detector angular offsets. Does not include tuning-dependent properties of the detectors.
Signature 1: Copy constructor
- Description() str
Long-form human-readable description of the object
- Summary() str
Short (one-line) description of the object
- property band: float
Nominal center of detector observing band in frequency units
- property band_string
String representation of frequency band center
- property band_vstring
String representation of frequency band center, without units name
- property bandwidth: float
Measured bandwidth of detector observing band in frequency units
- property center_frequency: float
Measured center of detector observing band in frequency units
- property coupling: BolometerCouplingType
Optical coupling type
- property physical_name: str
Physical name of the detector (e.g. some polarization at some particular pixel on the wafer)
- property pixel_id: str
Name of the pixel of which this detector is a part
- property pixel_type: str
Name of the pixel type of which this detector is a part
- property pol_angle: float
Polarization angle in angular units
- property pol_efficiency: float
Polarization efficiency (0-1)
- property wafer_id: str
Name of the wafer this detector is on
- property x_offset: float
Horizontal pointing offset relative to boresight in angular units.
- property y_offset: float
Vertical pointing offset relative to boresight in angular units.
- class spt3g.calibration.BolometerPropertiesMap()
- class spt3g.calibration.BolometerPropertiesMap(arg: BolometerPropertiesMap)
- class spt3g.calibration.BolometerPropertiesMap(arg: Iterable)
Bases:
_BolometerPropertiesMapBaseMap
,G3FrameObject
Container for bolometer properties for focal plane, mapping logical bolometer IDs to their physical properties.
Signature 2: Copy constructor
Signature 3: Iterable constructor
- clear()
Remove all items from the mapping.
- copy() BolometerPropertiesMap
Return a shallow copy of the mapping.
- get(key: str, default: object = None) object
Return the value for key if key is in the mapping, else default.
- pop(key: str) BolometerProperties
- pop(key: str, default: object) object
Signature 1: Remove specified key and return the corresponding value. If the key is not found, raise a KeyError
Signature 2: Remove specified key and return the corresponding value. If the key is not found, return the default
- update(items: Iterable = [], **kwargs)
Update mapping from iterable/mapping.
- values() ValuesView
Return an object providing a view on the mappings’s values.
- class spt3g.calibration.PointingProperties(arg: PointingProperties)
- class spt3g.calibration.PointingProperties()
Bases:
G3FrameObject
Pointing model parameters to be used for offline pointing corrections.
Signature 1: Copy constructor
- Description() str
Long-form human-readable description of the object
- Summary() str
Short (one-line) description of the object
- property tiltAngle: float
Orientation of azimuth tilt.
- property tiltHA: float
Azimuth hour angle tilt parameter.
- property tiltLat: float
Azimuth lateral tilt parameter.
- property tiltMag: float
Magnitude of azimuth tilt.
- class spt3g.calibration.PointingPropertiesMap()
- class spt3g.calibration.PointingPropertiesMap(arg: PointingPropertiesMap)
- class spt3g.calibration.PointingPropertiesMap(arg: Iterable)
Bases:
_PointingPropertiesMapBaseMap
,G3FrameObject
Container for pointing model parameters for offline pointing.
Signature 2: Copy constructor
Signature 3: Iterable constructor
- clear()
Remove all items from the mapping.
- copy() PointingPropertiesMap
Return a shallow copy of the mapping.
- get(key: str, default: object = None) object
Return the value for key if key is in the mapping, else default.
- pop(key: str) PointingProperties
- pop(key: str, default: object) object
Signature 1: Remove specified key and return the corresponding value. If the key is not found, raise a KeyError
Signature 2: Remove specified key and return the corresponding value. If the key is not found, return the default
- update(items: Iterable = [], **kwargs)
Update mapping from iterable/mapping.
- values() ValuesView
Return an object providing a view on the mappings’s values.
Class-like Pipeline Modules
Classes that can be added to G3Pipeline
instances, either written as callable objects in Python (see
Callable Objects as Functions) or as G3Module
-derived
classes in C++ (see Writing a module in C++). Aside from adding these into
pipelines using the standard Add()
method, such objects may also be
instantiated outside of pipelines to make use of additional features.
One typical use case is to extract some kind of data from a series of frames:
class ExtractData:
def __init__(self, key="RawTimestreams"):
self.key = key
self.data = []
def __call__(self, frame):
if self.key in frame:
self.data.append(frame[self.key])
# instantiate caching class
extractor = ExtractData()
# use instance in a pipeline
pipe = core.G3Pipeline()
pipe.Add(core.G3Reader, filename="file.g3")
pipe.Add(extractor)
pipe.Run()
# use extracted data in later processing
print(extractor.data)
Another use case may be to call additional methods of a class. For
example, the G3Writer
class can be used as a
context manager, and also report the position of the file pointer after
each frame is written:
with core.G3Writer("file.g3") as writer:
for frame in frames:
writer(frame)
print("Bytes written:", writer.tell())
Class-like modules permit a variety of additional features beyond their standard usage in pipelines.
- class spt3g.calibration.bolopropertiesutils.SplitByBand(
- input='CalTimestreams',
- output_root=None,
- bands=None,
- bpm='BolometerProperties',
- drop_empty=False,
Bases:
SplitByProperty
Take an input G3FrameObject-derivative Map keyed by bolometer name and split it into several based on the bands of the detectors as given by the BolometerProperties key. Return the same type of maps as the one it was handed, e.g. G3TimestreamMap, G3MapInt, etc.
Split the input map given by input into several output maps named output_root + band + GHz (e.g. CalTimestreams150GHz with the default options). If bands is not None, use only the bands in the list (possibly writing empty timestream maps to the frame). Otherwise, creates maps for every band that exists in the input. Setting bpm to a non-default value causes this to get its band mapping from an alternative data source.
- static converter(band_string)[source]
Function for converting the property to its corresponding string name. Returns a string representation of the input argument, or None if the argument is invalid.
Overload this function in subclasses of SplitByProperty to change how attributes are parsed into their string representations.
- class spt3g.calibration.bolopropertiesutils.SplitByPixelType(
- input='CalTimestreams',
- output_root=None,
- types=None,
- bpm='BolometerProperties',
- drop_empty=False,
Bases:
SplitByProperty
Take an input G3FrameObject-derivative Map keyed by bolometer name and split it into several based on the pixel types of the detectors as given by the BolometerProperties key. Return the same type of maps as the one it was handed, e.g. G3TimestreamMap, G3MapInt, etc.
Split the input map given by input into several output maps named output_root + wafer (e.g. CalTimestreamsW172 with the default options). If wafers is not None, use only the wafers in the list (possibly writing empty timestream maps to the frame). Otherwise, creates maps for every wafer that exists in the input. Setting bpm to a non-default value causes this to get its wafer mapping from an alternative data source.
- static converter(pixel_type)[source]
Function for converting the property to its corresponding string name. Returns a string representation of the input argument, or None if the argument is invalid.
Overload this function in subclasses of SplitByProperty to change how attributes are parsed into their string representations.
- class spt3g.calibration.bolopropertiesutils.SplitByProperty(
- input='CalTimestreams',
- property=None,
- property_list=None,
- output_root=None,
- bpm='BolometerProperties',
- drop_empty=False,
Take an input G3FrameObject-derivative Map keyed by bolometer name and split it into several based on the property of the detectors as given by the BolometerProperties key. Return the same type of maps as the one it was handed, e.g. G3TimestreamMap, G3MapInt, etc.
Split the input map given by input into several output maps named output_root + key (e.g. CalTimestreams + str(property)) with the default options).
- Parameters:
input (str) – Key name of the input map to split.
property (str) – Attribute name to extract from the BolometerProperties object. Required.
property_list (list of properties) – Properties to include in the output keys. Entries that are not strings will be converted to strings using the SplitByProperty.converter method. If property_list is not None, use only the names in the list (possibly writing empty timestream maps to the frame). Otherwise, creates maps for every that exists in the input.
output_root (str) – Prefix for the output keys. If None (default), use input as the output root.
bpm (str) – The key name of the BolometerPropertiesMap from which to extract the requested property for splitting the input map.
drop_empty (bool) – If True, drop output maps that don’t contain any bolometers.
- static converter(prop)[source]
Function for converting the property to its corresponding string name. Returns a string representation of the input argument, or None if the argument is invalid.
Overload this function in subclasses of SplitByProperty to change how attributes are parsed into their string representations.
- class spt3g.calibration.bolopropertiesutils.SplitByWafer(
- input='CalTimestreams',
- output_root=None,
- wafers=None,
- bpm='BolometerProperties',
- drop_empty=False,
Bases:
SplitByProperty
Take an input G3FrameObject-derivative Map keyed by bolometer name and split it into several based on the wafers of the detectors as given by the BolometerProperties key. Return the same type of maps as the one it was handed, e.g. G3TimestreamMap, G3MapInt, etc.
Split the input map given by input into several output maps named output_root + wafer (e.g. CalTimestreamsW172 with the default options). If wafers is not None, use only the wafers in the list (possibly writing empty timestream maps to the frame). Otherwise, creates maps for every wafer that exists in the input. Setting bpm to a non-default value causes this to get its wafer mapping from an alternative data source.
- static converter(wafer)[source]
Function for converting the property to its corresponding string name. Returns a string representation of the input argument, or None if the argument is invalid.
Overload this function in subclasses of SplitByProperty to change how attributes are parsed into their string representations.
- class spt3g.calibration.bolopropertiesutils.SplitTimestreamsByBand(
- input='CalTimestreams',
- output_root=None,
- bands=None,
- bpm='BolometerProperties',
- drop_empty=False,
Bases:
SplitByBand
Split the input map given by input into several output maps named output_root + band + GHz (e.g. CalTimestreams150GHz with the default options). If bands is not None, use only the bands in the list (possibly writing empty timestream maps to the frame). Otherwise, creates maps for every band that exists in the input. Setting bpm to a non-default value causes this to get its band mapping from an alternative data source.
- class spt3g.calibration.build_cal_frames.BuildBoloPropertiesMap(
- drop_original_frames=True,
- fiducial_detectors=[],
- bpm_name='NominalBolometerProperties',
- use_bpm_pointing=False,
Build bolometer properties map from raw calibration sub-frames emitted by other processing scripts. Input data are maps of bolo ID to floats or, in the case of names, strings. If multiple instance of each data class appear, the final bolometer properties map will be the median of the input values.
Expects to be passed frames from: - RCW38 Relative Pointing Offset Calibration (Keys: ‘PointingOffsetX’, ‘PointingOffsetY’) - CenA Angle Calibration (Keys: ‘PolarizationAngle’, ‘PolarizationEfficiency’) - Band Calibration (Key: ‘BoloBands’) - Physical Name Data (Key: ‘PhysicalBoloIDs’)
If drop_original_frames is True, will drop all input Calibration frames.
If fiducial_detectors is set, will use the average of the position[s] of whatever detector[s] are specified to center each set of relative offsets encountered (NB: this recentering is done in a Cartesian way). If it is not specified, five detectors near the middle of the focal plane present in every observation given will be chosen automatically and printed to the console.
bpm_name is the name of the key containing the input BolometerPropertiesMap that will be merged into the output map.
If use_bpm_pointing is True, then the pointing information is extracted from the input BolometerPropertiesMap. If False, pointing information must be supplied in an additional input frame.
- class spt3g.calibration.build_cal_frames.BuildPointingProperties(drop_original_frames=True)[source]
Build pointing properties from raw calibration sub-frames emitted by other processing scripts. Input data are floats, including tilt information, and eventually other pointing model values.
Expects to be passed frames from: - Az tilt fit parameters (Keys: ‘tiltAngle’, ‘tiltHA’, ‘tiltLat’, ‘tiltMag’)
If drop_original_frames is True, will drop all input Calibration frames.
- class spt3g.calibration.build_cal_frames.MergeCalibrationFrames(KeysToIgnore=['PointingOffsetX', 'PointingOffsetY'])[source]
Merge the keys from a sequence of calibration frames. Will throw an exception if a key recurs in more than one calibration frame. The merged calibration frame will be emitted before the first non-calibration frame that follows a calibration frame or at the end of processing, whichever comes first. Other non-calibration frames will be ignored.
Ignores keys in the KeysToIgnore list during merging. By default, set to values written by the flux/pointing calibration that are stored to the BolometerPropertiesMap.
Function-like Pipeline Modules
Python functions that can be added to G3Pipeline
instances. Such functions may also be called directly with a G3Frame
object as the first argument, and do not necessarily need to be used in a pipeline. See Python Modules as Functions for more detail.
- spt3g.calibration.build_cal_frames.ExplodeBolometerProperties(frame, bpmname='NominalBolometerProperties')[source]
Take a bolometer properties map (usually the nominal one) and convert it into its constituent keys as though they came from real calibration. This is the inverse of BuildBoloPropertiesMap and mostly is useful when combining hardware map information with real calibration.
Useful Classes
Various Python and C++ classes that are part of the public API.
- class spt3g.calibration.BolometerCouplingType(value: int)
Coupling type for BolometerProperties objects.
- DarkCrossover = spt3g.calibration.BolometerCouplingType.DarkCrossover
- DarkTermination = spt3g.calibration.BolometerCouplingType.DarkTermination
- Loopback = spt3g.calibration.BolometerCouplingType.Loopback
- OffResonance = spt3g.calibration.BolometerCouplingType.OffResonance
- Optical = spt3g.calibration.BolometerCouplingType.Optical
- Resistor = spt3g.calibration.BolometerCouplingType.Resistor
- Unknown = spt3g.calibration.BolometerCouplingType.Unknown
- property name: str
- names: dict
Mapping of enum names to objects.
{'DarkCrossover': spt3g.calibration.BolometerCouplingType.DarkCrossover, 'DarkTermination': spt3g.calibration.BolometerCouplingType.DarkTermination, 'Loopback': spt3g.calibration.BolometerCouplingType.Loopback, 'OffResonance': spt3g.calibration.BolometerCouplingType.OffResonance, 'Optical': spt3g.calibration.BolometerCouplingType.Optical, 'Resistor': spt3g.calibration.BolometerCouplingType.Resistor, 'Unknown': spt3g.calibration.BolometerCouplingType.Unknown}
- property value: int
- values: dict
Mapping of enum values to objects.
{70: spt3g.calibration.BolometerCouplingType.OffResonance, 76: spt3g.calibration.BolometerCouplingType.Loopback, 79: spt3g.calibration.BolometerCouplingType.Optical, 82: spt3g.calibration.BolometerCouplingType.Resistor, 84: spt3g.calibration.BolometerCouplingType.DarkTermination, 85: spt3g.calibration.BolometerCouplingType.Unknown, 88: spt3g.calibration.BolometerCouplingType.DarkCrossover}
Useful Functions
Various Python and C++ functions that are part of the public API.
- spt3g.calibration.bolopropertiesutils.band_to_string(value, include_units=True)[source]
Convert a band value in G3Units to its string representation, using the appropriate precision and units name.
- spt3g.calibration.bolopropertiesutils.band_to_value(string)[source]
Convert a band string to a value in G3Units, or raise a ValueError if no match is found.
- spt3g.calibration.bolopropertiesutils.extract_band_string(string, include_units=True)[source]
Return the band substring from the input string, or None if not found.
- spt3g.calibration.bolopropertiesutils.extract_band_value(string)[source]
Return the band in G3Units extracted from the input string, or None if not found.
- spt3g.calibration.bolopropertiesutils.get_band_units()[source]
Return the units string used for formatting frequency band values.
- spt3g.calibration.bolopropertiesutils.set_band_format(precision, units)[source]
Set the band format precision and units for converting between a quantity in G3Units and its string representation.
- Parameters:
precision (int) – Float formatting precision for the band quantity. If <=0, output will be an integer. If >0, output will be a floating point number with this many decimal places of precision.
units (str) – String name of the G3Units quantity in which to represent the frequency band, e.g. “GHz” or “MHz”. Must correspond to a valid attribute of the core.G3Units namespace.