coscon.toast_helper module

class coscon.toast_helper.AvesBands(data: Dict[str, Union[float, int, str]], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericDictStructure

a class describing the bands of Aves.

data: Dict[str, Union[float, int, str]]
schema: ClassVar[dict] = {<class 'str'>: {'NET': Or(<class 'float'>, <class 'numpy.float64'>), 'alpha': Or(<class 'float'>, <class 'int'>, <class 'numpy.float64'>, <class 'numpy.int64'>), 'bandpass': <class 'str'>, 'bandwidth': Or(<class 'float'>, <class 'int'>, <class 'numpy.float64'>, <class 'numpy.int64'>), 'center': Or(<class 'float'>, <class 'numpy.float64'>), 'fknee': Or(<class 'float'>, <class 'numpy.float64'>), 'fmin': Or(<class 'float'>, <class 'numpy.float64'>), 'fwhm': Or(<class 'float'>, <class 'numpy.float64'>)}}
class coscon.toast_helper.AvesDetectors(data: Dict[str, Optional[Union[str, float, int, np.ndarray]]], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericFocalPlane

a class describing the detectors of Aves.

similar to FakeFocalPlane

data: Dict[str, Optional[Union[str, float, int, np.ndarray]]]
plot(width: float = 20.0, height: float = 20.0, fontname: str = 'TeX Gyre Schola', wire: bool = False, wire_TB: bool = False, wire_connectionstyle: Optional[str] = None)[source]

Plot the detectors in Azimuthal equidistant projection with orientation.

For wire_connectionstyle, use ‘arc3’ to draw straight-line. See more in https://matplotlib.org/stable/gallery/userdemo/connectionstyle_demo.html#sphx-glr-gallery-userdemo-connectionstyle-demo-py

schema: ClassVar[dict] = {<class 'str'>: {'wafer': <class 'str'>, 'pixel': <class 'str'>, 'pixtype': <class 'str'>, 'band': <class 'str'>, 'fwhm': Or(<class 'float'>, <class 'numpy.float64'>), 'pol': And(<class 'str'>, <function <lambda>>), Optional('handed'): Or(None, And(<class 'str'>, <function <lambda>>)), 'orient': And(<class 'str'>, <function <lambda>>), 'quat': And(<class 'numpy.ndarray'>, <function <lambda>>), 'UID': Or(<class 'int'>, <class 'numpy.int64'>)}}
class coscon.toast_helper.AvesHardware(data: Dict[str, dict], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericDictStructure

data: Dict[str, dict]
property dataframe

DataFrame representation of the hardware

property dataframe_with_azimuthal_equidistant_projection_with_orientation

DataFrame representation of the hardware

classmethod from_dataframe(df: pandas.core.frame.DataFrame, validate_schema=True)[source]

Create Hardware from a dataframe representation

reorder_to(pixels: List[int], TB_anti_alignment: bool = False, TB_alternate_anti_alignment: bool = False, validate_schema: bool = False)coscon.toast_helper.AvesHardware[source]

Reorder pixels according its integer assignment

Parameters

TB_anti_alignment (bool) – if True, assume TB pixels ordering BTTBBTTBBT..

else BTBTBTBT…

reorder_to_from_csv(path: pathlib.Path, TB_anti_alignment: bool = False, TB_alternate_anti_alignment: bool = False, validate_schema: bool = False)coscon.toast_helper.AvesHardware[source]

Reorder pixels according its integer assignment

Parameters
  • path (Path) – a csv or txt file that has the pixel numbers per line

  • TB_anti_alignment (bool) – if True, assume TB pixels ordering BTTBBTTBBT..

else BTBTBTBT…

schema: ClassVar[dict] = {<class 'str'>: {'bands': <class 'dict'>, 'detectors': <class 'dict'>, 'pixels': <class 'dict'>, 'telescopes': <class 'dict'>, 'wafers': <class 'dict'>}}
class coscon.toast_helper.AvesPixels(data: Dict[str, Union[float, List[str]]], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericDictStructure

a class describing the pixels of Aves.

data: Dict[str, Union[float, List[str]]]
schema: ClassVar[dict] = {<class 'str'>: {'bands': And(<class 'list'>, <function <lambda>>), 'sizemm': <class 'float'>}}
class coscon.toast_helper.AvesTelescopes(data: Dict[str, Union[float, List[str]]], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericDictStructure

a class describing the telescopes of Aves.

data: Dict[str, Union[float, List[str]]]
schema: ClassVar[dict] = {<class 'str'>: {'platescale': Or(<class 'float'>, <class 'numpy.float64'>), 'wafers': And(<class 'list'>, <function <lambda>>), 'waferspace': Or(<class 'float'>, <class 'numpy.float64'>)}}
class coscon.toast_helper.AvesWafers(data: Dict[str, Optional[Union[float, int, str, List[str]]]], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericDictStructure

a class describing the wafers of Aves.

data: Dict[str, Optional[Union[float, int, str, List[str]]]]
schema: ClassVar[dict] = {<class 'str'>: {'type': <class 'str'>, 'npixel': Or(<class 'int'>, <class 'numpy.int64'>), 'pixels': And(<class 'list'>, <function <lambda>>), Optional('handed'): Or(None, <class 'float'>, <class 'int'>, <class 'numpy.float64'>, <class 'numpy.int64'>), 'position': Or(<class 'int'>, <class 'numpy.int64'>), 'telescope': <class 'str'>}}
class coscon.toast_helper.CrosstalkMatrix(names: np.ndarray[S], data: np.ndarray[np.float64], name: Optional[str] = None, freq: Optional[np.ndarray[np.float64]] = None)[source]

Bases: coscon.toast_helper.GenericMatrix

Crosstalk square matrix where column and row share the same names

compare_plot_diag(others: List[coscon.toast_helper.CrosstalkMatrix])[source]
compare_plot_nearest_neighbor(others: List[coscon.toast_helper.CrosstalkMatrix])[source]
property dataframe
property dataframe_diag_only
property dataframe_nearest_neighbor_only
freq = None
classmethod from_geometric(names: Union[List[str], np.ndarray], r: float = 0.01)CrosstalkMatrix[source]

Generate a crosstalk matrix with coefficients in geometric series.

classmethod from_joshian_matrix(names: Union[List[str], np.ndarray], nearest: float, next_nearest: float, floor: float)CrosstalkMatrix[source]

Generate a crosstalk matrix with structure based on Josh’s simple assumption

classmethod from_unique_matrix(names: Union[List[str], np.ndarray])CrosstalkMatrix[source]

generate a crosstalk matrix with each entry to be unique.

Mainly for debug use to confirm the matrix multiplication is correct.

plot(annot: bool = True, figsize: Optional[Tuple[float, float]] = None, log: bool = True)[source]
to_random_normal()coscon.toast_helper.CrosstalkMatrix[source]

Generate a random normal matrix based on original matrix except for diagonal

with mean and std given by the original matrix.

class coscon.toast_helper.DictValueEqualsKey[source]

Bases: object

A fake dictionary where its values always equal their keys

class coscon.toast_helper.FakeFocalPlane(data: Dict[str, Union[float, np.ndarray]], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericFocalPlane

a class describing the output of fake_focalplane

data: Dict[str, Union[float, np.ndarray]]
plot(width: float = 4.0, height: float = 4.0, outfile: Optional[Path] = None, facecolor: Optional[Dict[str, Union[str, Tuple[float, float, float]]]] = None, polcolor: Optional[Dict[str, Union[str, Tuple[float, float, float]]]] = None)[source]
schema: ClassVar[dict] = {<class 'str'>: {'NET': Or(<class 'float'>, <class 'numpy.float64'>), 'alpha': Or(<class 'float'>, <class 'numpy.float64'>), 'epsilon': Or(<class 'float'>, <class 'numpy.float64'>), 'fknee': Or(<class 'float'>, <class 'numpy.float64'>), 'fmin': Or(<class 'float'>, <class 'numpy.float64'>), 'fwhm_arcmin': Or(<class 'float'>, <class 'numpy.float64'>), 'quat': And(<class 'numpy.ndarray'>, <function <lambda>>), 'rate': Or(<class 'float'>, <class 'numpy.float64'>)}}
class coscon.toast_helper.GenericDictStructure(data: Dict[str, Any], validate_schema: bool = True)[source]

Bases: object

data: Dict[str, Any]
property dataframe

DataFrame representation of the focal plane

This has opposite key-ordering from the dict i.e. self.data[some_key][‘quat’] == self.dataframe[‘quat’][some_key] == self.dataframe.loc[some_key, ‘quat’]

dump(path: Union[Path, str], overwrite: bool = False, compress: bool = None)[source]

Write hardware config to a TOML/YAML/JSON file.

classmethod load(path: Union[Path, str])[source]

Read data from a TOML/YAML/JSON file.

schema: ClassVar[dict] = {}
validate()[source]
validate_schema: bool = True
class coscon.toast_helper.GenericFocalPlane(data: Dict[str, Any], validate_schema: bool = True)[source]

Bases: coscon.toast_helper.GenericDictStructure

property azimuthal_equidistant_projection_with_orientation
data: Dict[str, Any]
property dataframe_with_azimuthal_equidistant_projection_with_orientation
iplot(scale: float = 1.0, height: int = 1000, width: int = 1000) → plotly.graph_objs._figure.Figure[source]
class coscon.toast_helper.GenericMatrix(names: np.ndarray[S], data: np.ndarray[np.float64], name: Optional[str] = None)[source]

Bases: object

Generic matrix that has row names in ASCII.

dump(path: pathlib.Path, compress_level: int = 9)[source]
classmethod load(path: pathlib.Path)[source]
name = None
property names_str

names in list of str

property shape
property size
class coscon.toast_helper.NaiveTod(names: np.ndarray[S], data: np.ndarray[np.float64], name: Optional[str] = None)[source]

Bases: coscon.toast_helper.GenericMatrix

Naive TOD matrix that has all data in contiguous array

apply_crosstalk(crosstalk_matrix: coscon.toast_helper.CrosstalkMatrix)coscon.toast_helper.NaiveTod[source]
property dataframe
class coscon.toast_helper.SQUID(R_TES: Union[float, np.ndarray[np.float64]], r_s: Union[float, np.ndarray[np.float64]], L: Union[float, np.ndarray[np.float64]], L_com: float, C: Optional[np.ndarray[np.float64]] = None, omega: Optional[np.ndarray[np.float64]] = None)[source]

Bases: object

A model of the SQUID readout.

See fig. 4 in Montgomery2020.

Montgomery2020: Montgomery et al., “Performance and Characterization of the SPT-3G Digital Frequency Multiplexed Readout System Using an Improved Noise and Crosstalk Model.”

C: Optional[np.ndarray[np.float64]] = None
L: Union[float, np.ndarray[np.float64]]
L_com: float
R_TES: Union[float, np.ndarray[np.float64]]
dataframe(include_omega: bool = False, include_freq: bool = False) → pandas.core.frame.DataFrame[source]
property freq
omega: Optional[np.ndarray[np.float64]] = None
r_s: Union[float, np.ndarray[np.float64]]
to_crosstalk_matrix(names: Optional[Union[List[str], np.ndarray]] = None)CrosstalkMatrix[source]

Compute the crosstalk matrix using Montgomery2020 approximations

to_crosstalk_matrix_exact(names: Optional[Union[List[str], np.ndarray]] = None)CrosstalkMatrix[source]

Compute the crosstalk matrix using Montgomery2020 formulism without the approximations

to_dict(include_omega: bool = False, include_freq: bool = False) → dict[source]
coscon.toast_helper.fake_focalplane(samplerate: float = 20.0, epsilon: float = 0.0, net: float = 1.0, fmin: float = 0.0, alpha: float = 1.0, fknee: float = 0.05, fwhm: float = 30.0, npix: int = 7, fov: float = 3.0) → Dict[str, Union[float, np.ndarray]][source]

Create a set of fake detectors.

This generates 7 pixels (14 dets) in a hexagon layout at the boresight and with a made up polarization orientation.

This function is copied from TOAST workshop with the following license:

BSD 2-Clause License

Copyright (c) 2019, hpc4cmb All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

coscon.toast_helper.na_to_none(value)[source]

Convert pandas null value to None