maps

The maps project defines map projections, along with G3SkyMap subclasses that provide sky maps in those map projections and tools for format/projection conversions of these data types.

In addition, this library contains three pipeline modules (MapBinner, SingleDetectorMapBinner, and SingleDetectorBoresightBinner) to make binned maps from time-ordered data, as well as a module (MapMockObserver) to mock-observe a provided sky map, generating fake time-ordered-data from it corresponding to some stored instrument pointing itinerary. A few other utility pipeline modules (described below) are provided for some map manipulation tasks.

The key data types defined here are:

HealpixSkyMap

Implements Healpix over all or a fraction of the sky, either in nested or ring mode. The underlying sky map data are represented in one of three ways: as a dense 1-D array (full sky), as a locally-dense region surrounded by zeroes (ring mode only), or as a list of non-zero pixels and their values. The second two modes efficiently represent partial-sky maps.

FlatSkyMap

Implements a flat-sky map (similar to a 2D numpy array) in any of the supported projections. The stored map is either a dense 2D array, or a locally dense region (a set of neighboring columns containing non-zero values, each of which contains a single contiguous block of non-zero values).

Map Attributes

The following attributes are common to all G3SkyMap subclasses:

coord_ref

The coordinate system on the sky to which each map pixel is referenced, stored as an instance of the MapCoordReference enum. Currently supported coordinate systems are Equatorial (FK5 J2000), Galactic and Local (telescope azimuth and elevation).

pol_type

The Stokes polarization of the map object, which is an instance of the MapPolType enum, and can have the value T, Q, U or None.

pol_conv

The polarization convention used to encode the Q and U Stokes orientations relative to the coordinate axes. This attribute is an instance of the MapPolConv enum, which can have the value IAU, COSMO or None. Both IAU and COSMO polarization conventions are supported in polarization-aware functions (e.g. FlattenPol), but most default to using the IAU convention. Warnings will be raised when a polarized map is used without a polarization convention set. Use the SetPolConv pipeline module to change the polarization convention between IAU and COSMO for an entire map frame. This will result in flipping the sign of all pixels in the U map as well as the TU and QU weights.

units

The units system in which the map is computed, stored as an instance of the G3TimestreamUnits enum, typically Tcmb.

weighted

A boolean attribute indicating whether the data in the map have been normalized by the inverse of the appropriate Mueller matrix (weighted=False) or not (weighted=True). See more information on map weights below.

File Format Conversions

We support writing maps into FITS files that can be read with other tools (such as DS9), using the fitsio.save_skymap_fits function. FITS files with compatible headers can be read in using the fitsio.load_skymap_fits function.

T, Q, U and corresponding G3SkyMapWeights objects are written to a single file as a sequence of HDUs. FlatSkyMap objects are stored in dense format (see below) to CompImageHDU objects if compression is enabled, and otherwise stored in dense format to standard ImageHDU objects. The latter can be loaded using “old style” fits readers, such as the idlastro fits utilities.

HealpixSkyMap objects are stored in a sequence of BinTableHDU objects, a format that is compatible with the healpy.read_map function. Dense maps (see below) are stored using implicit indexing, and sparse maps are stored using explicit indexing with an additional pixel index column.

Indexing

Values in maps can be set and retrieved using the standard python (or C++) [] operator. Both flat and Healpix maps support a 1-D indexing convention. For flat-sky maps, this 1-D index follows C ordering; for Healpix maps, this is the normal 1-D Healpix pixel number. Flat-sky maps also accept 2-D indices, which have ordering following normal language conventions for 2-D indices ((y, x) in Python, (x, y) in C++).

Note that sky maps do not support numpy-style slicing operations, except for 2-D indexing of flat-sky maps (see below), which makes a copy of the underlying map data. To perform operations with other numpy arrays, use numpy.asarray, which will convert the map to its dense representation (see below) and provides read-write access the map’s internal buffer, which requires no meaningful CPU time or memory.

Sparsity

By default, both Healpix and flat-sky maps are initialized in sparse mode. This imposes a slight performance penalty but will result in the map storing only non-zero portions (with caveats, see details above), substantially reducing RAM usage. Some map operations, in particular casting to numpy arrays, will result in the implicit conversion of the map to dense storage, which can result in sudden increases in RAM usage. The current sparsity mode can be examined or changed with the sparse property (flat sky maps) or the dense, ringsparse, or indexedsparse properties (Healpix maps). Serialization to .g3 files will maintain the current sparsity scheme, as do arithmetic operators where possible. Serialization to .fits files implicitly converts flat sky maps to dense mode, but preserves the sparsity of Healpix maps. The current number of stored pixels can be obtained using the npix_allocated property, and the number of non-zero pixels can be obtained using the npix_nonzero property. Dense maps can be efficiently compactified in memory using the G3SkyMap.compact method, or the CompactMaps pipeline module.

Beyond paying attention to implicit conversions to dense storage and the performance impact of sparse storage (which is small, at least for FlatSkyMap objects), users of this code do not need to worry about the storage mode–all interfaces are identical in all modes.

Masking

Maps containing only boolean data for each pixel are stored as G3SkyMapMask objects. Such mask objects have a .parent attribute which is a shallow clone of the map object with which they are associated (to check for shape compatibility).

Masks are returned when using comparison operators with map objects, e.g. map1 > 5 or map1 == map2. The supported comparison operators are: >, >=, ==, !=, <=, <. Masks can also be combined together using logical operators, e.g. mask3 = mask1 & mask2 or mask1 ^= mask2. The supported comparison operators are: &, &=, |, |=, ^, ^=. Masks can also be checked for equality to other masks using == and != operators.

Mask objects can be clone’ed the same way as maps. A map can be converted to a boolean mask using G3SkyMap.to_mask(), which returns a mask which is True wherever the map is non-zero (optionally excluding nan or inf pixels). A mask can be converted back to a map object using G3SkyMapMask.to_map(), which returns a sparse, unit-less, unweighted, unpolarized map object of the same type as G3SkyMapMask.parent, containing double 1.0 wherever the mask is True.

Masks can also be applied to maps or masks using the appropriate .apply_mask method, with optional inversion; alternatively maps can also be directly multiplied by a compatible mask object. A list of non-zero pixels can be returned using .nonzero() (note that this returns a single vector of pixel positions), and mask contents can be checked using .all(), .any() and .sum(). Mask contents can be inverted in-place using .invert().

Mask objects cannot be accessed using numpy slicing, or converted directly to arrays, because numpy does not represent boolean values as single bits. To be able to use numpy tools with masks, you need to first convert the mask to a dense map using .to_map(). All associated methods of the parent map are accessible as attributes of the mask object in python, e.g. mask.angles_to_pixels() works as one would expect.

Mask Memory Usage

The current implementation of masks is to use a dense std::vector<bool> as the data storage backend, which uses 64x less memory than a dense map (std::vector<double>) of the same dimensions. This implementation is sufficient for FlatSkyMap objects, since these are typically O(50%) full populated in their sparse state; however, the memory savings for HealpixSkyMap objects is not as significant when observing sufficiently small patches of sky. Future work would enable a similar sparse storage backend for masks.

In general, when working with high-resolution maps of any sort, it is important to think carefully about doing the sorts of operations that can balloon memory usage, e.g. taking care to preserve the sparsity of maps by avoiding numpy operations if possible, or using in-place operations to avoid unintentionally creating extra maps or masks in memory.

Statistics

Most numpy.ufunc-like methods are defined for map objects, namely .all(), .any(), .sum(), .mean(), .median(), .var(), .std(), .min(), .max(), .argmin(), .argmax(). All methods take an optional where argument, which can be a compatible G3SkyMapMask object, or size-compatible 1-D numpy array that can be converted into one. In addition, these methods are called under the hood when using the numpy equivalent functions (numpy.all(), etc), in order to preserve the sparsity of the input map. Methods that ignore NaN values are also defined (.nansum(), etc), which behave much like the standard methods, except that calling numpy.nansum() and friends on a map object does not preserve sparsity.

Map values can be tested using .isnan(), .isinf(), .isfinite() methods as well; these return G3SkyMapMask objects.

Map Interpolation

Several interpolation and rebinning utilities are provided. The method G3SkyMap.get_interp_values can be used for extracting map values at arbitrary sky positions using bilinear interpolation. The method G3SkyMap.rebin can be used to downgrade the map resolution in a way that preserves the total power within each map pixel.

The functions healpix_to_flatsky and flatsky_to_healpix functions are provided to reproject maps between flat sky and curved sky systems, with options to use interpolation or rebinning to improve the accuracy of the reprojection.

The more general reproj_map function can also be used to convert between flat sky projections.

Note: The interpolation routine for healpix maps produces results that differ from those of the equivalent healpy.get_interp_val routine. The interpolation routine implemented here is area-preserving in the computation of bilinear weights, whereas the healpy routine is not.

Map Weights

The G3SkyMapWeights class combines the six unique components of the Mueller weight matrix into one object. The individual matrix terms can be accessed using the attributes G3SkyMapWeights.TT, etc, or as keyed elements (e.g. weights['TT']). The full matrix for an individual map pixel can be accessed using the standard [] operator. In python, this returns a symmetric 3x3 numpy array that is a copy of the values in the underlying maps, and in C++ this returns a MuellerMatrix object, with scalar attributes MuellerMatrix.tt, etc that are writable references to elements of the underlying map objects. The G3SkyMapWeights.polarized attribute determines whether the weight structure contains polarization information. For unpolarized weights, only the TT element is set, and the [] operator returns a scalar value in python, and a MuellerMatrix with just the TT element set in C++.

In C++ there is also a StokesVector object that is analogous to the MuellerMatrix object. It has scalar attributes StokesVector.t etc, that are writable references to elements of map objects. Matrix operations on the StokesVector and MuellerMatrix objects are well defined.

Weights are removed from or applied to a set of Stokes T/Q/U maps simultaneously, using the remove_weights or apply_weights functions, or their corresponding pipeline modules.

Map Frames and Pipelines

Maps and associated weights are generally stored in memory and on disk in G3Frames of type G3FrameType.Map, with keys 'T', 'Q', 'U', 'Wpol' defined for polarized maps, and 'T', 'Wunpol' defined for unpolarized maps. Map frames can be checked for validity using the ValidateFrames pipeline module, which raises errors or warnings for missing keys or inconsistent attributes.

Map frames can be manipulated in a pipeline using some memory-efficient pipeline modules. Weights can be applied or removed from their corresponding Stokes maps using the ApplyWeights or RemoveWeights pipeline modules. Maps can be converted to polarized or unpolarized versions using the MakeMapsPolarized and MakeMapsUnpolarized modules. They can also be compactified to their most sparse representation using the CompactMaps module.

Existing maps can be injected into a pipeline using the InjectMaps module, and map stubs can be injected using InjectMapStub or ReplicateMaps. Maps can also be extracted from a pipeline using the ExtractMaps module.

Flat Sky Map Projections

For flat-sky maps, we support the following map projections:

ProjSansonFlamsteed

Sanson-Flamsteed (also called the sinusoidal projection). It has equal-area pixels, defined by multiplying azimuth distances by cos(latitude). Mercator-esque in that lines of constant latitude are transformed to lines of constant y. Distances are not preserved. Also known as “proj 0”.

ProjPlateCarree

The Plate-Carree projection just plots latitude and longitude on a grid: latitude lines are at constant y and equally spaced, while longitude lines are at constant x and equally spaced. Pixels are not equal-area. Also known as “proj 1”. A variant of this projection, called ProjBICEP (or “proj 9”), adjusts the resolution along x to scale with the cosine of the latitude of the center of the map.

ProjOrthographic

The projection of the sphere onto a plane – the sky looks like a circle. Can only show one hemisphere. Lines drawn on the map do not correspond to latitude or longitude. Pixels are not equal-area. Also known as “proj 2”.

ProjStereographic

Another projection of the sphere onto a plane that makes it look like a circle. Differs from an orthographic projection in that it lets you see both hemispheres. Popularized in the form of the UN logo. Lines drawn on the map do not correspond to latitude or longitude. Pixels are not equal-area. Also known as “proj 4”.

ProjLambertAzimuthalEqualArea

Yet another mapping of the sphere to a circle, but this one has equal-area pixels. Largely distance-preserving, which makes it particularly useful for power-spectrum analyses. Also known as “proj 5”.

ProjGnomonic

Another projection of the sphere onto a circle. This one has the property that straight lines correspond to geodesics. Does not have equal-area pixels. Can show less than half a sphere. Also known as a “tangent projection” or “proj 6”.

ProjCylindricalEqualArea

The Lambert cylindrical equal-area projection (CEA) maps the sphere to a rectangle. Has equal-area pixels. Lines of constant x correspond to constant longitude; lines of constant y are constant latitude. Latitudes get closer together (by sin(latitude)) at the poles. Also known as “proj 7”.

Flat Sky Map Manipulation

Flat sky maps have additional functions defined for efficient manipulation in memory.

The FlattenPol pipeline module flattens the Q and U stokes parameters to align with the pixel coordinate grid, which is necessary for computing power spectra in the flat sky approximation.

Small patches can be extracted from and inserted into larger flat sky maps using the FlatSkyMap.extract_patch and FlatSkyMap.insert_patch methods, respectively. Also, maps can be padded and cropped using the FlatSkyMap.reshape method, which keeps the patch centered in the output map. All of these preserve the map pixelization and correspondence to angle on the sky.

As an equivalent and more Pythonic alternative, you can also extract portions of the map using numpy-style slicing operations (e.g. map[45:130,114:182]), which will produce a map with the same contents as the numpy operation but without converting it to a dense map and with all the coordinate information set appropriately (and is equivalent to extract_patch()). This also works with setting, but the coordinates have to match the sub-subcoordinates (as you would have gotten them from getting a slice or extract_patch()). Note that this slicing creates a copy of the underlying data, so in-place operations (e.g. map[45:130,114:182] += 5) will work, but are not necessarily memory efficient.

Map Pointing

This package also provides functions and pipeline modules for creating and manipulating the quaternions necessary for mapmaking. In general, there are two forms of quaternions that are used throughout the code: pointing quaternions and rotation quaternions.

Pointing Quaternions

Pointing quaternions encode the two-dimensional sky coordinate angles in their vector component. These quaternions can be created using the ang_to_quat function, and their sky coordinates extracted using the quat_to_ang function. The various methods of the G3SkyMap classes return or accept pointing quaternions. Note that local (horizon) coordinates have a different parity than sky coordinates (equatorial, galactic); the z vector coordinate encodes -sin(elevation) in local coordinates, but +sin(dec) in sky coordinates.

Rotation Quaternions

Conversion between coordinate systems is done by constructing rotation quaternions. A pointing quaternion q_p can be rotated to a new coordinate system by the rotation quaternion q_r by using quaternion multiplication: q_p_rot = q_r * q_p / q_r. For example, the module FillCoordTransRotations can be used to construct rotation quaternions for rotating detector offset coordinates into local or on-sky coordinate systems. Rotation quaternions can be rotated into Galactic coordinates using the EquatorialToGalacticTransRotations module.

Detector Pointing

Detector pointing timestreams are constructed by first using the offsets_to_quat function to construct the detector offset quaternion in boresight coordinates, then rotating that pointing quaternion onto the sky by applying a rotation quaternion constructed from the boresight pointing timestreams. This is done internally for each detector in each of the mapmaking pipeline modules (MapBinner, MapMockObserver, etc), which all require an input BolometerPropertiesMap object with offsets for each detector, and pre-computed timestreams of boresight rotation quaternions associated with each input Scan frame.

API Documentation

Frame Objects

Serializable objects that may be stored as entries in G3Frame objects.

class spt3g.maps.FlatSkyMap(arg: FlatSkyMap)
class spt3g.maps.FlatSkyMap()
class spt3g.maps.FlatSkyMap(
x_len: int,
y_len: int,
res: float,
weighted: bool = True,
proj: MapProjection = spt3g.maps.MapProjection.ProjNone,
alpha_center: float = 0,
delta_center: float = 0,
coord_ref: MapCoordReference = spt3g.maps.MapCoordReference.Equatorial,
units: G3TimestreamUnits = spt3g.core.G3TimestreamUnits.Tcmb,
pol_type: MapPolType = spt3g.maps.MapPolType.none,
x_res: float = nan,
x_center: float = nan,
y_center: float = nan,
flat_pol: bool = False,
pol_conv: MapPolConv = spt3g.maps.MapPolConv.none,
)
class spt3g.maps.FlatSkyMap(
obj: numpy.ndarray,
res: float,
weighted: bool = True,
proj: MapProjection = spt3g.maps.MapProjection.ProjNone,
alpha_center: float = 0,
delta_center: float = 0,
coord_ref: MapCoordReference = spt3g.maps.MapCoordReference.Equatorial,
units: G3TimestreamUnits = spt3g.core.G3TimestreamUnits.Tcmb,
pol_type: MapPolType = spt3g.maps.MapPolType.none,
x_res: float = nan,
x_center: float = nan,
y_center: float = nan,
flat_pol: bool = False,
pol_conv: MapPolConv = spt3g.maps.MapPolConv.none,
)

Bases: G3SkyMap, G3FrameObject

FlatSkyMap is a G3SkyMap with the extra meta information about the particular flat sky projection included. In practice it behaves (mostly) like a 2d numpy array. The pixels are normally indexed with an 1d pixel index. If you find that you need numpy functionality from a FlatSkyMap, e.g. for slicing across the two dimensions, you can access a numpy representation of the map using np.asarray(m). This does not copy the data, so any changes to the resulting array will affect the data stored in the map. Alternatively, you can use 2d slice indexing directly on the map to access a copy of the data with the coordinate representation intact. The latter method is most efficient for extracting small patches from sparse maps.

Signature 1: Copy constructor

Signature 3: Instantiate an empty flat sky map object

Signature 4: Instantiate a flat sky map object from a numpy array

Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

angle_to_xy(alpha: float, delta: float) DoubleVector
angle_to_xy(
alpha: DoubleVector,
delta: DoubleVector,
) tuple

Signature 1: Compute the flat 2D coordinates of the input sky coordinates

Signature 2: Compute the flat 2D coordinates of the input sky coordinates (vectorized)

array_clone(array: numpy.ndarray) FlatSkyMap

Return a map of the same type, populated with a copy of the input numpy array

extract_patch(
x0: int,
y0: int,
width: int,
height: int,
fill: float = 0,
) FlatSkyMap

Returns a map of shape (width, height) containing a rectangular patch of the parent map. Pixel (width // 2, height // 2) of the output map corresponds to pixel (x0, y0) in the parent map, and the angular location of each pixel on the sky is maintained. Surrounding empty pixels can be optionally filled.

insert_patch(patch: FlatSkyMap, ignore_zeros: bool = False)

Inserts a patch (e.g. as extracted using extract_patch) into the parent map. The coordinate system and angular center of the patch must match that of the parent map. If ignore_zeros is True, zero-valued pixels in the patch are not inserted. This is useful for preserving the sparsity of the parent map.

nonzero_pixels() tuple

Returns a list of the indices of the non-zero pixels in the map and a list of the values of those non-zero pixels.

pixel_to_angle(pixel: int) tuple
pixel_to_angle(x: int, y: int) DoubleVector

Signature 1: Compute the sky coordinates of the given 1D pixel

Signature 2: Compute the sky coordinates of the given 2D pixel (also see xy_to_angle()).

pixel_to_xy(pixel: int) DoubleVector
pixel_to_xy(pixel: UInt64Vector) tuple

Signature 1: Compute the flat 2D coordinates of the input pixel index

Signature 2: Compute the flat 2D coordinates of the input pixel indices (vectorized)

quat_to_xy(quat: Quat) DoubleVector
quat_to_xy(quat: G3VectorQuat) tuple

Signature 1: Compute the flat 2D coordinates of the input quaternion rotation

Signature 2: Compute the flat 2D coordinates of the input quaternion rotations (vectorized)

reshape(width: int, height: int, fill: float = 0) FlatSkyMap

Returns a map of shape (width, height) containing the parent map centered within it. The angular location of each pixel on the sky is maintained. Surrounding empty pixels can be optionally filled.

xy_to_angle(x: float, y: float) DoubleVector
xy_to_angle(
x: DoubleVector,
y: DoubleVector,
) tuple

Signature 1: Compute the sky coordinates of the input flat 2D coordinates

Signature 2: Compute the sky coordinates of the input flat 2D coordinates (vectorized)

xy_to_pixel(x: float, y: float) int
xy_to_pixel(
x: DoubleVector,
y: DoubleVector,
) UInt64Vector

Signature 1: Compute the pixel index of the input flat 2D coordinates

Signature 2: Compute the pixel indices of the input flat 2D coordinates (vectorized)

xy_to_quat(x: float, y: float) Quat
xy_to_quat(
x: DoubleVector,
y: DoubleVector,
) G3VectorQuat

Signature 1: Compute the quaternion rotation of the input flat 2D coordinates

Signature 2: Compute the quaternion rotations of the input flat 2D coordinates (vectorized)

property alpha_center: float

Horizontal axis center position

property delta_center: float

Vertical axis center position

property flat_pol: bool

True if this map has been flattened using flatten_pol.

property proj: MapProjection

Map projection (one of maps.MapProjection)

property res: float

Map resolution in angular units for maps with square pixels

property sparse: bool

True if the map is stored with column and row zero-suppression, False if every pixel is stored. Map sparsity can be changed by setting this to True (or False).

property wcs

astropy.wcs.WCS instance containing projection information

Creates WCS (world coordinate system) information from information in the input FlatSkyMap object.

property x_center: float

Horizontal axis center pixel position

property x_res: float

Resolution in X direction for maps with rectangular pixels

property y_center: float

Vertical axis center pixel position

property y_res: float

Resolution in Y direction for maps with rectangular pixels

class spt3g.maps.G3SkyMapMask(arg: G3SkyMapMask)
class spt3g.maps.G3SkyMapMask(
parent: G3SkyMap,
use_data: bool = False,
zero_nans: bool = False,
zero_infs: bool = False,
)
class spt3g.maps.G3SkyMapMask(
parent: G3SkyMap,
data: Buffer,
zero_nans: bool = False,
zero_infs: bool = False,
)

Bases: G3FrameObject

Boolean mask of a sky map. Set pixels to use to true, pixels to ignore to false. If use_data set in contrast, mask initialized to true where input map is non-zero; otherwise, all elements are initialized to zero. Use zero_nans or zero_infs to exclude nan or inf elements from the mask.

Signature 1: Copy constructor

Signature 2: Instantiate a G3SkyMapMask from a parent G3SkyMap

Signature 3: Instantiate a G3SkyMapMask from a 1D numpy array

Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

all(axis=None, out=None, keepdims=False, *, where=True)

Returns True if all elements evaluate to True.

Refer to numpy.all for full documentation.

See also

numpy.all

equivalent function

any(axis=None, out=None, keepdims=False, *, where=True)

Returns True if any of the elements of a evaluate to True.

Refer to numpy.any for full documentation.

See also

numpy.any

equivalent function

apply_mask(mask: G3SkyMapMask, inverse: bool = False)

Apply a mask in-place to the mask, optionally inverting which pixels are zeroed. If inverse = False, this is equivalent to in-place element-wise logical-and with the mask.

array_clone(
data: Buffer,
zero_nans: bool = False,
zero_infs: bool = False,
) G3SkyMapMask

Return a mask of the same type, populated from the input numpy array

clone(copy_data: bool = True) G3SkyMapMask

Return a mask of the same type, populated with a copy of the data if the argument is true (default), empty otherwise.

compatible(arg: G3SkyMapMask) bool
compatible(arg: G3SkyMap) bool

Signature 1: Returns true if the two masks can be applied to the same map.

Signature 2: Returns true if this mask can be applied to the given map.

invert() G3SkyMapMask

Invert all elements in mask

nonzero() UInt64Vector

Return a list of indices of non-zero pixels in the mask

sum(
axis=None,
dtype=None,
out=None,
keepdims=False,
initial=0,
where=True,
)

Return the sum of the array elements over the given axis.

Refer to numpy.sum for full documentation.

See also

numpy.sum

equivalent function

to_map() G3SkyMap

Create a skymap with data set to the contents of this mask (1.0 where True, 0.0 where False), which can be useful for plotting.

property parent: G3SkyMap

“Parent” map which contains no data, but can be used to retrieve the parameters of the map to which this mask corresponds.

property size: int

Number of pixels in mask

class spt3g.maps.G3SkyMapWeights(arg: G3SkyMapWeights)
class spt3g.maps.G3SkyMapWeights()
class spt3g.maps.G3SkyMapWeights(skymap: G3SkyMap)

Bases: G3FrameObject

Polarized (Mueller matrix) or unpolarized (scalar) map pixel weights.Weights are polarized if the pol_conv attribute of the reference map is set.

Signature 1: Copy constructor

Clone(copy_data=True)
Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

apply_mask(mask: G3SkyMapMask, inverse: bool = False)

Apply a mask in-place to the weights, optionally inverting which pixels are zeroed. If inverse = False, this is equivalent to in-place multiplication by the mask.

clone(copy_data: bool = True) G3SkyMapWeights

Return weights of the same type, populated with a copy of the data if the argument is true (default), empty otherwise.

compact(zero_nans: bool = False)

Convert the map to its default sparse representation, excluding empty pixels, and optionally converting NaN values to zeroes.

compatible(arg: G3SkyMap) bool

Returns true if the input argument is a map with matching dimensions and boundaries on the sky.

cond() G3SkyMap

Return the condition number of the Mueller matrix for each pixel

copy() G3SkyMapWeights

Return a copy of the weights object

det() G3SkyMap

Return the determinant of the Mueller matrix for each pixel

extract_patch(
self: FlatSkyMap,
x0: int,
y0: int,
width: int,
height: int,
fill: float = 0,
) FlatSkyMap

Returns a map of shape (width, height) containing a rectangular patch of the parent map. Pixel (width // 2, height // 2) of the output map corresponds to pixel (x0, y0) in the parent map, and the angular location of each pixel on the sky is maintained. Surrounding empty pixels can be optionally filled.

insert_patch(
self: FlatSkyMap,
patch: FlatSkyMap,
ignore_zeros: bool = False,
) None

Inserts a patch (e.g. as extracted using extract_patch) into the parent map. The coordinate system and angular center of the patch must match that of the parent map. If ignore_zeros is True, zero-valued pixels in the patch are not inserted. This is useful for preserving the sparsity of the parent map.

inv() G3SkyMapWeights

Return the inverse of the Mueller matrix for each pixel

keys()

Return the list of string names of valid weight attributes. For unpolarized weights, this list includes only TT. Otherwise, the list includes all six unique weight attributes in row major order: TT, TQ, TU, QQ, QU, UU.

rebin(scale: int) G3SkyMapWeights

Rebin the weights into larger pixels by summing scale-x-scale blocks of pixels together. Returns a new weights object. Map dimensions must be a multiple of the rebinning scale.

reshape(
self: FlatSkyMap,
width: int,
height: int,
fill: float = 0,
) FlatSkyMap

Returns a map of shape (width, height) containing the parent map centered within it. The angular location of each pixel on the sky is maintained. Surrounding empty pixels can be optionally filled.

property QQ: G3SkyMap

Mueller matrix component map

property QU: G3SkyMap

Mueller matrix component map

property TQ: G3SkyMap

Mueller matrix component map

property TT: G3SkyMap

Mueller matrix component map

property TU: G3SkyMap

Mueller matrix component map

property UU: G3SkyMap

Mueller matrix component map

property congruent: bool

True if all components are internally compatible with each other

property polarized: bool

True if all components are set, False if only the TT component is set

property shape: tuple

Shape of weights

property size: int

Number of pixels in weights

class spt3g.maps.HealpixSkyMap(arg: HealpixSkyMap)
class spt3g.maps.HealpixSkyMap()
class spt3g.maps.HealpixSkyMap(
nside: int,
weighted: bool = True,
nested: bool = False,
coord_ref: MapCoordReference = spt3g.maps.MapCoordReference.Equatorial,
units: G3TimestreamUnits = spt3g.core.G3TimestreamUnits.Tcmb,
pol_type: MapPolType = spt3g.maps.MapPolType.none,
shift_ra: bool = False,
pol_conv: MapPolConv = spt3g.maps.MapPolConv.none,
)
class spt3g.maps.HealpixSkyMap(
index: numpy.ndarray[numpy.int64],
data: numpy.ndarray[numpy.float64],
nside: int,
weighted: bool = True,
nested: bool = False,
coord_ref: MapCoordReference = spt3g.maps.MapCoordReference.Equatorial,
units: G3TimestreamUnits = spt3g.core.G3TimestreamUnits.Tcmb,
pol_type: MapPolType = spt3g.maps.MapPolType.none,
pol_conv: MapPolConv = spt3g.maps.MapPolConv.none,
)
class spt3g.maps.HealpixSkyMap(
data: numpy.ndarray,
weighted: bool = True,
nested: bool = False,
coord_ref: MapCoordReference = spt3g.maps.MapCoordReference.Equatorial,
units: G3TimestreamUnits = spt3g.core.G3TimestreamUnits.Tcmb,
pol_type: MapPolType = spt3g.maps.MapPolType.none,
shift_ra: bool = False,
pol_conv: MapPolConv = spt3g.maps.MapPolConv.none,
)

Bases: G3SkyMap, G3FrameObject

HealpixSkyMap is a G3SkyMap with the extra meta information about the particular Healpix pixelization used. In practice it behaves (mostly) like a 1d numpy array. If you find that you need numpy functionality from a HealpixSkyMap, e.g. for slicing across the array, you can access a numpy representation of the map using np.asarray(m). This does not copy the data, so any changes to the resulting array will affect the data stored in the map.

Signature 1: Copy constructor

Signature 3: Instantiate a HealpixSkyMap with given nside

Signature 4: Instantiate a sparse HealpixSkyMap from existing index and data arrays corresponding to the given nside

Signature 5: Instantiate a dense Healpix map from an existing dense map.

Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

array_clone(array: numpy.ndarray) HealpixSkyMap

Return a map of the same type, populated with a copy of the input numpy array

nonzero_pixels() tuple

Returns a list of the indices of the non-zero pixels in the map and a list of the values of those non-zero pixels.

property dense: bool

True if the map is stored with all elements, False otherwise. If set to True, converts the map to a dense representation.

property indexedsparse: bool

True if the map is stored as a list of non-zero pixels and values. More efficient than ring-sparse for maps with holes or very small filling factors. If set to True, converts the map to this representation.

property nested: bool

True if pixel ordering is nested, False if ring-ordered

property nside: int

Healpix resolution parameter

property res: float

Map resolution in angular units

property ringsparse: bool

True if the map is stored as a dense 2D region using ring ordering (analogous to FlatSkyMap’s sparse mode). Ring-sparsity is efficient for dense blocks on a ring-ordered map (e.g. a continuous sky region), but is inefficient otherwise (e.g. nested pixel ordering or discontinous coverage). If set to True, converts the map to this representation.

property shift_ra: bool

True if the ringsparse representation of the map is stored with the rings centered at ra = 0 deg, rather than ra = 180 deg.

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.maps.HitsBinner(
map_id: str,
stub_map: G3SkyMap,
pointing: str,
timestreams: str,
bolo_properties_name: str = 'BolometerProperties',
map_per_scan: object = False,
)

Bases: G3Module

Bins up pointing for a set of channels into a hits map with properties (projection, etc.) specified by the stub_map argument.

Parameters:
  • map_id (string) – Will be set as the “Id” element of the output frame from this module.

  • stub_map (G3SkyMap) – Template of the map in which to accumulate timestream data. All parameters of the output map (projection, boundaries, pixel size, etc.) are copied from this map, which is not modified.

  • pointing (string (frame object G3TimestreamQuat)) – Name of a frame object containing the boresight pointing quaternion timestream. Must be present in every Scan frame.

  • timestreams (string (frame object G3TimestreamMap)) – Name of a frame object containing the timestreams to be binned into the output map. Must exist in every Scan frame that is to be binned. This key is used only to determine the subset of channels to bin into the hits map.

  • bolo_properties_name (string, optional (frame object BolometerPropertiesMap)) – Name of a bolometer properties map containing detector pointing offsets from boresight. These are usually named “BolometerProperties”, the default, and this parameter only need be set if you wish to use alternative values.

  • map_per_scan (boolean or callable, optional) – Defaults to False. If set to True, will make an output map for every input Scan frame, which can be useful for fine-grained time-domain maps. Can also be set to a Python callable for complex situations. In this case, the callable will be called on each Scan frame and passed the frame as an argument. If it returns True, the map binner will emit a map frame with the data since the last emitted map frame but before the current Scan; if False, the binner will continue accumulating data.

Emits:

frame (G3Frame) – A frame of type Map at the end of processing containing the output map:

Frame (Map) [
    "Id" (spt3g.core.G3String) => "ra0hdec-57.5-150GHz"
    "H" (spt3g.maps.FlatSkyMap) => 2700 x 1500 (45 x 25 deg) ZEA centered
at (1350, 749.5) = (0, -57.5 deg) in equatorial coordinates  (Tcmb)
]

Examples

pipe.Add(
    maps.HitsBinner,
    map_id="150GHz",
    stub_map=map_params,
    timestreams="DeflaggedTimestreams150GHz",
    pointing="OfflineRaDecRotation",
)
class spt3g.maps.MapBinner(
map_id: str,
stub_map: G3SkyMap,
pointing: str,
timestreams: str,
detector_weights: str = '',
bolo_properties_name: str = 'BolometerProperties',
store_weight_map: bool = True,
map_per_scan: object = False,
)

Bases: G3Module

Bins up timestreams into a map with properties (projection, etc.) specified by the stub_map argument.

Parameters:
  • map_id (string) – Will be set as the “Id” element of the output frame from this module.

  • stub_map (G3SkyMap) – Template of the map in which to accumulate timestream data. All parameters of the output map (projection, boundaries, pixel size, etc.) are copied from this map, which is not modified. T-only maps are made if the pol_conv property of stub_map is None; polarized maps are made if it is set to IAU or Cosmo.

  • pointing (string (frame object G3VectorQuat or G3TimestreamQuat)) – Name of a frame object containing the boresight pointing quaternion timestream. Must have the same number of elements as the data in timestreams and be present in every Scan frame.

  • timestreams (string (frame object G3TimestreamMap)) – Name of a frame object containing the timestreams to be binned into the output map. Must exist in every Scan frame, though may be empty if the frame should be ignored. Units in the output map are taken from the units of the detector timestreams.

  • detector_weights (string, optional (frame object G3MapDouble)) – Name of a frame object containing weights to assign data from each detector. This frame object maps detector names (as in timestreams) to a scalar weight. If unset or set to an empty string (“”), detectors will be weighted equally. If set, every detector in timestreams must occur in detector_weights, but detector_weights may contain additional elements not present in timestreams.

  • bolo_properties_name (string, optional (frame object BolometerPropertiesMap)) – Name of a bolometer properties map containing detector pointing offsets from boresight. These are usually named “BolometerProperties”, the default, and this parameter only need be set if you wish to use alternative values.

  • store_weight_map (boolean, optional) – Defaults to True. If set to False, the output weight map will not be stored, though the output maps will still be weighted. It should be set to False if and only if you know what the weights are a priori (e.g. mock observing, where they are the same as the data maps).

  • map_per_scan (boolean or callable, optional) – Defaults to False. If set to True, will make an output map for every input Scan frame, which can be useful for fine-grained time-domain maps. Can also be set to a Python callable for complex situations. In this case, the callable will be called on each Scan frame and passed the frame as an argument. If it returns True, the map binner will emit a map frame with the data since the last emitted map frame but before the current Scan; if False, the binner will continue accumulating data.

Emits:

frame (G3Frame) – A frame of type Map at the end of processing containing the output map:

Frame (Map) [
    "Id" (spt3g.core.G3String) => "ra0hdec-57.5-150GHz"
    "T" (spt3g.maps.FlatSkyMap) => 2700 x 1500 (45 x 25 deg) ZEA centered
at (1350, 749.5) = (0, -57.5 deg) in equatorial coordinates  (Tcmb)
    "Q" (spt3g.maps.FlatSkyMap) => 2700 x 1500 (45 x 25 deg) ZEA centered
at (1350, 749.5) = (0, -57.5 deg) in equatorial coordinates  (Tcmb)
    "U" (spt3g.maps.FlatSkyMap) => 2700 x 1500 (45 x 25 deg) ZEA centered
at (1350, 749.5) = (0, -57.5 deg) in equatorial coordinates  (Tcmb)
    "Wpol" (spt3g.maps.G3SkyMapWeights) => G3SkyMapWeights
]

For unpolarized maps, the “Q” and “U” outputs will be absent and the “Wpol” frame object will be named “Wunpol”.

See also

SingleDetectorMapBinner, SingleDetectorBoresightBinner

MapMockObserver

The inverse of this module. Produces timestreams from an input map.

FlatSkyMap, HealpixSkyMap

Examples

pipe.Add(
    maps.MapBinner,
    map_id="150GHz",
    stub_map=map_params,
    timestreams="DeflaggedTimestreams150GHz",
    pointing="OfflineRaDecRotation",
    detector_weights="TodWeights",
)
class spt3g.maps.MapMockObserver(
pointing: str,
timestreams: str,
band: float,
T: G3SkyMap,
Q: G3SkyMap = None,
U: G3SkyMap = None,
bolo_properties_name: str = 'BolometerProperties',
interp: bool = False,
error_on_zero: bool = True,
)

Bases: G3Module

Creates a new set of timestreams by sampling from an input map.

Parameters:
  • pointing (string (frame object G3TimestreamQuat)) – Name of a frame object containing the boresight pointing quaternion timestream. Used to construct detector pointing with which to sample the input map(s). Must be present in every Scan frame.

  • timestreams (string (frame object G3TimestreamMap)) – Name of a frame object that will contain the output timestreams sampled from the input map(s). Units of the timestreams are taken from the input map. Will be inserted into every Scan frame.

  • band (float) – Frequency band for which the input map was constructed. Only detectors whose band matches this value will be included in the output timestreams.

  • T (frame object G3SkyMap) – The input temperature map to be sampled.

  • Q (frame object G3SkyMap, optional) – Optional Q and U polarization maps to include in the output timestreams, using the polarization angle and efficiency to determine the appropriate coupling to each Stokes component.

  • U (frame object G3SkyMap, optional) – Optional Q and U polarization maps to include in the output timestreams, using the polarization angle and efficiency to determine the appropriate coupling to each Stokes component.

  • bolo_properties_name (string, optional (frame object BolometerPropertiesMap)) – Name of a bolometer properties map containing detector pointing offsets from boresight. These are usually named “BolometerProperties”, the default, and this parameter only need be set if you wish to use alternative values.

  • interp (bool, optional) – If True, use bilinear interpolation to sample the input map(s). If False (default), use the nearest-neighbor pixel value.

  • error_on_zero (bool, optional) – If True (default), complain loudly if the simulation scans across zeroes in the input map or out of the input map boundaries. If False, allow this to happen without comment.

See also

MapBinner

The inverse of this module. Bins timestreams into an output map.

FlatSkyMap, HealpixSkyMap

Examples

pipe.Add(
    maps.MapMockObserver,
    pointing="OfflineRaDecRotation",
    timestreams="CalTimestreams150GHz",
    band=150 * core.G3Units.GHz,
    T=map_frame["T"],
)
class spt3g.maps.MapTODMasker(
pointing: str,
timestreams: str,
mask: G3SkyMapMask,
tod_mask: str = 'FilterMask',
bolo_properties_name: str = 'BolometerProperties',
)

Bases: G3Module

Creates a filter mask <tod_mask> to indicate to later TOD filtering that a detector has passed over a “bad” part of the sky. This is used, for example, to avoid fitting a polynomial to a timestream while the detector is looking at a bright point source. All timestream values for the detectors in <timestreams> are set to be ignored (true in the output <tod_mask>) if they point>. Detector pointing offsets and polarization angles and efficiencies are obtained from the specified BolometerPropertiesMap, which can generally be left at its default value.

class spt3g.maps.MapTODPointing(
pointing: str,
timestreams: str,
stub_map: G3SkyMap,
tod_pointing: str,
bolo_properties_name: str = 'BolometerProperties',
)

Bases: G3Module

Compute pixel pointing for timestreams for a map with properties (projection, etc.) specified by the stub_map argument.

The outputs of this module are identical to internally-calculated quantities in the map maker and can be used for debugging map-making or studying individual-detector pixel coverage. The outputs are not consumed by any stage of the map-making pipeline.

Parameters:
  • pointing (string (frame object G3VectorQuat or G3TimestreamQuat)) – Name of a frame object containing the boresight pointing quaternion timestream. Must have the same number of elements as the data in timestreams and be present in every Scan frame.

  • timestreams (string (frame object G3TimestreamMap)) – Name of a frame object that contains the detector timestreams for the channels for which to compute pointing timestreams.

  • stub_map (G3SkyMap) – Template of the map for which to compute pixel pointing.

  • tod_pointing (string) – The key to which the pixel pointing G3MapVectorInt object is stored in the output Scan frames from this module.

  • bolo_properties_name (string, optional (frame object BolometerPropertiesMap)) – Name of a bolometer properties map containing detector pointing offsets from boresight. These are usually named “BolometerProperties”, the default, and this parameter only need be set if you wish to use alternative values.

Emits:

frame (G3Frame) – Adds a new key to every Scan frame containing the output pointing data:

Frame (Scan) [
    ...
    "OnlineRaDecRotation" (spt3g.core.G3TimestreamQuat) =>
15716 quaternions at 152.6 Hz
    "RawTimestreams_I" (spt3g.core.G3TimestreamMap) =>
Timestreams from 14112 detectors
    "TodPointing" (spt3g.core.G3MapVectorInt) => 14112 elements
    ...
]

See also

MapTODMasker

Projection of sky masks to detector timestreams.

MapBinner, SingleDetectorMapBinner, SingleDetectorBoresightBinner

MapMockObserver

The inverse of MapBinner. Produces timestreams from an input map.

FlatSkyMap, HealpixSkyMap

Examples

pipe.Add(
    maps.MapTODPointing,
    pointing="OnlineRaDecRotation",
    timestreams="RawTimestreams_I",
    stub_map=map_params,
    tod_pointing="TodPointing",
)
class spt3g.maps.SingleDetectorBoresightBinner(
stub_map: G3SkyMap,
pointing: str,
timestreams: str,
)

Bases: G3Module

Makes simple binned maps of the sky, in boresight coordinates, for every detector present in the given timestreams. This module is intended for use when making maps for detector-pointing calibration.

Parameters:
  • stub_map (G3SkyMap) – Template of the map in which to accumulate timestream data. All parameters of the output map (projection, boundaries, pixel size, etc.) are copied from this map, which is not modified.

  • pointing (string (frame object G3VectorQuat or G3TimestreamQuat)) – Name of a frame object containing the boresight pointing quaternion timestream. Must have the same number of elements as the data in timestreams and be present in every Scan frame.

  • timestreams (string (frame object G3TimestreamMap)) – Name of a frame object containing the timestreams to be binned into the output map. Must exist in every Scan frame, though may be empty if the frame should be ignored. Units in the output map are taken from the units of the detector timestreams. Because of the single stored weight/hit map, the set of detectors in every scan must be identical.

Emits:

frames (G3Frame) – At the end of processing, emits one frame of type Map for each detector containing the corresponding map. The “Id” property of the output frames gives the detector ID to which the map corresponds. Because the maps are unweighted (weights don’t make sense for single-detector maps) and the effective pointing for all detectors is identical, the weight/hit map is identical for all detectors and is stored only in the first output frame.

Frame (Map) [
    "Id" (spt3g.core.G3String) => "2019.000"
    "T" (spt3g.maps.FlatSkyMap) => 360 x 360 (3 x 3 deg) ZEA centered
at (179.5, 179.5) = (0, 0 deg) in local coordinates  (Power)
    "Wunpol" (spt3g.maps.G3SkyMapWeights) => G3SkyMapWeights
]
Frame (Map) [
    "Id" (spt3g.core.G3String) => "2019.005"
    "T" (spt3g.maps.FlatSkyMap) => 360 x 360 (3 x 3 deg) ZEA centered
at (179.5, 179.5) = (0, 0 deg) in local coordinates  (Power)
]

See also

SingleDetectorMapBinner

Produces single-detector maps, but in sky coordinates, taking into account individual-detector pointing offsets.

MapBinner

Produces co-added maps from many detectors.

MapMockObserver

The inverse of MapBinner. Produces timestreams from an input map.

FlatSkyMap, HealpixSkyMap

Examples

pipe.Add(
    maps.SingleDetectorBoresightBinner,
    stub_map=smstub,
    timestreams='PolyFilteredTimestreams',
    pointing='OffsetRotation',
)
class spt3g.maps.SingleDetectorMapBinner(
stub_map: G3SkyMap,
pointing: str,
timestreams: str,
bolo_properties_name: str = 'BolometerProperties',
)

Bases: G3Module

Makes a simple binned map of the sky, in sky coordinates, for every detector present in the given <timestreams>. Boresight pointing is specified by the <pointing> argument, with per-detector offsets from boresight as stored in the given bolometer properties map. The map parameters are copied from <stub_map>. When processing ends, this module will emit one map frame per detector, including per-detector (unpolarized) weights.

class spt3g.maps.map_modules.CoaddMaps(
map_ids=None,
output_map_id='Coadd',
collate=False,
weighted=True,
ignore_missing_weights=False,
drop_input_frames=False,
record_obs_id=False,
keep_outputs=False,
)[source]

Coadd maps and weights, optionally collating by map Id. This class can be used as an argument to pipe.Add() as a standard pipeline module, or instantiated as a standalone instance. In the latter case, the object is treated as a callable for input map frames, and the coadd_frame or coadd_frames attribute contains the running coadd(s).

The output coadd frames contain two additional keys: 'InputMapIds' and 'InputFiles', which are both lists of unique map Id’s and filenames that are associated with the frames that contribute to each coadd. When one coadd is added to another, these keys are updated recursively, so that the resulting coadd includes the Id’s and filenames that contributed to both itself and the other coadd. The list of filenames can be populated by combining this module with a G3Reader whose track_filename option is set to True; however, this feature is fragile and may not work as expected with complex pipelines.

Parameters:
  • map_ids (list of str) – List of map Id’s to include in the coadd(s). If None, any maps in the pipeline are included. Otherwise, the output of the get_map_ids method is compared with this list, and the input frame is discarded if no match is found.

  • output_map_id (str) – Id to assign to the output frame. If collate is True, this argument is required and treated as a prefix to which each input map Id is appended.

  • collate (bool) – If True, coadd unique map Id’s into separate output map frames.

  • weighted (bool) – If True (default), ensure that maps have had weights applied before coadding. Otherwise, coadd maps without checking the weights.

  • ignore_missing_weights (bool) – If False (default), a warning is issued when the frame contains weighted Stokes maps without a weights map. Set this option to True when feeding single bolometer map frames with common weights through a pipeline.

  • drop_input_frames (bool) – If True, drop input map frames from the pipeline that are included in any coadds.

  • record_obs_id (bool) – If True, include source name and observation ID info in the output coadd frame InputMapIds key, along with the map ID for each input frame. If False, only the map frame ID is included.

  • keep_outputs (bool) – If True, preserve the coadd frame module attributes after parsing an EndProcessing frame. Otherwise, coadd frames are deleted to avoid memory leaks in pipelines, under the assumption that ownership of the frame(s) is transfered to downstream modules, e.g. G3Writer.

get_map_id(frame)[source]

Return Id associated with the input frame

By default, this returns the “Id” entry in the frame, None if not found. Subclass the CoaddMaps structure to override the default behavior.

Parameters:

frame (core.G3Frame instance of type G3FrameType.Map) – Candidate map frame to include in a coadd.

Returns:

map_id – A string if the frame is to be included in a coadd, None if the frame is to be passed on to downstream pipeline modules, or False if the frame is to be dropped from the pipeline altogether.

Return type:

str, None or False

reset()[source]

Clear internal frame cache.

property coadd_frame

Output coadd map frame, also injected into the pipeline on EndProcessing. This attribute is only populated if the collate option is set to False.

Output coadd map frame, also injected into the pipeline on EndProcessing. This attribute is only populated if the collate option is set to False.

property coadd_frames

Dictionary of output coadd map frames, keyed by input map Id. Each frame is also injected into the pipeline on EndProcessing. This attribute is only populated if the collate option is set to True.

Dictionary of output coadd map frames, keyed by input map Id. Each frame is also injected into the pipeline on EndProcessing. This attribute is only populated if the collate option is set to True.

class spt3g.maps.map_modules.ExtractMaps(map_id=None, copy=False, ignore_missing_weights=False)[source]

Cache maps that come through the pipeline. Initialize an instance of this module before adding to a pipeline. Any map frames that pass through the pipe are stored in the .maps attribute of the object after the pipeline is run.

Parameters:
  • map_id (string) – If supplied, select only map frames that match this ID.

  • copy (bool) – If True, make a copy of the map on extraction.

  • ignore_missing_weights (bool) – If False (default), a warning is issued when the frame contains weighted Stokes maps without a weights map. Set this option to True when feeding single bolometer map frames with common weights through a pipeline.

property maps

Dictionary of map frames, keyed by Id. Map objects are extracted from each frame in the pipeline, and stored as simple dictionaries. Multiple frames with the same Id will result in a list of dictionaries for that Id.

Dictionary of map frames, keyed by Id. Map objects are extracted from each frame in the pipeline, and stored as simple dictionaries. Multiple frames with the same Id will result in a list of dictionaries for that Id.

class spt3g.maps.map_modules.InjectMapStub(map_id, map_stub)[source]

Inject a new map frame from a map stub.

Parameters:
  • map_id (string) – Id to assign to the new map frame

  • map_stub (G3SkyMap instance) – Map stub from which to clone the Stokes maps and weights. If the weighted attribute of the stub is True, the output frame will include weights. If the pol_conv attribute of the stub is not None, the output frame will include Q and U maps (and polarized weights).

class spt3g.maps.map_modules.InjectMaps(map_id, maps_in, ignore_missing_weights=False)[source]

Inject a set of maps into a new map frame.

Parameters:
  • map_id (string) – Id to assign to the new map frame

  • maps_in (list or dict) – Maps to add to the frame. If a list, contains Stokes maps with valid pol_type and weights. If a dict, contains Stokes and weights maps keyed by the standard map frame names.

  • ignore_missing_weights (bool) – Skip warning about missing weights. Useful for masks.

class spt3g.maps.map_modules.ReprojectMaps(
map_stub=None,
rebin=1,
interp=False,
weighted=True,
partial=False,
mask=None,
)[source]

Reproject a map frame into a different projection. Original data are dropped and replaced by reprojected maps in the input frames. Maps can be changed between flat sky and healpix pixelizations, rotated between Equatorial and Galactic coordinates, and/or change polarization convention between COSMO and IAU, by setting the appropriate attributes of the input and stub maps. Attributes not defined in the stub map are assumed to be that of the input map. NB: coordinate rotation of polarized maps is not currently implemented.

Parameters:
  • map_stub (G3SkyMap object) – A stub (empty) sky map object to be used to construct the output maps. Can be a HealpixSkyMap or FlatSkyMap object. Setting the pol_conv and/or coord_ref attributes to values that differ from those of the input maps will result in output maps whose polarization convention and/or reference coordinate system have been changed.

  • rebin (int) – If supplied and >1, subdivide the output pixel by n x n with each sub-pixel taking on the input map values at pixel center (with interp or nearest neighbor). The output pixel takes on the average of the sub-pixel values. In the case that the input map has higher resolution than the output map (and that the input map is not low-pass filtered to remove information above the Nyquist freq. of the output map pixel), this reduces aliasing compared with direct sampling. But there would still be aliased power from the input map from freq above the ouput map pixel’s Nyquist.

  • interp (bool) – If True, use bilinear interpolation to extract values from the input map. Otherwise, the nearest-neighbor value is used.

  • weighted (bool) – If True (default), ensure that maps have had weights applied before reprojection. Otherwise, reproject maps without checking the weights.

  • partial (bool) – If True, the reproj will be performed on a partial map (of the output map), defined by the mask. If the mask is not provided, it will be determined from the non-zero pixels of the first reprojected map.

  • mask (G3SkyMapMask, G3SkyMap, or np.ndarray, optional) – Mask to be used for partial reproject. This should be of the same size as the output map. For numpy array, all zeros/inf/nan/hp.UNSEEN pixels are skipped.

property mask

The mask to be used for partial reprojection, of the same shape as the output map. Masked (1) pixels are handled by the reprojection code, and unmasked (0) pixels are skipped, effectively setting their value to 0 in the output map.

The mask to be used for partial reprojection, of the same shape as the output map. Masked (1) pixels are handled by the reprojection code, and unmasked (0) pixels are skipped, effectively setting their value to 0 in the output map.

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.maps.azel.EquatorialToGalacticPointing(
frame,
ra_timestream='BoresightRa',
dec_timestream='BoresightDec',
glon_timestream='BoresightGalLon',
glat_timestream='BoresightGalLat',
)[source]

Converts a set of timestreams in Scan frames representing RA and Declination pointing of the telescope into Galactic longitude and latitude timestreams, stored in the frame under their respective names.

spt3g.maps.azel.LocalToAstronomicalPointing(
frame,
az_timestream='BoresightAz',
el_timestream='BoresightEl',
ra_timestream='BoresightRa',
dec_timestream='BoresightDec',
Telescope='spt',
)[source]

Converts a set of timestreams in Scan frames representing Az and El pointing of the telescope into RA and Declination timestreams, stored in the frame under their respective names.

spt3g.maps.coordsysmodules.AddLocalTransRotations(
frame,
az_key='RawBoresightAz',
el_key='RawBoresightEl',
out_key='RawAzElRotation',
)[source]

Creates the transform for boresight pointing for az el based maps. This is equivalent to FillCoordTransRotations with end_coord_sys in Local coordinates.

Right now it’s using the coordinate system where delta = -el because of implementation details. All of the maps generated with this will be upside down in el.

spt3g.maps.coordsysmodules.EquatorialToGalacticTransRotations(
frame,
eq_trans_key='OnlineRaDecRotation',
out_key='OnlineGalacticRotation',
)[source]

Takes a quaternion vector specifying the rotation to FK5 (Equatorial) boresight and converts it into a rotation to Galactic J2000 boresight coordinates.

Use this to convert the output of FillCoordTransRotations to Galactic coordinates.

spt3g.maps.coordsysmodules.FillCoordTransRotations(
frame,
transform_store_key='OnlineRaDecRotation',
end_coord_sys=spt3g.maps.MapCoordReference.Equatorial,
do_bad_transform=False,
bs_az_key='RawBoresightAz',
bs_el_key='RawBoresightEl',
bs_ra_key='OnlineBoresightRa',
bs_dec_key='OnlineBoresightDec',
offset_az_key='OffsetBoresightAz',
offset_el_key='OffsetBoresightEl',
offset_ra_key='OnlineOffsetRa',
offset_dec_key='OnlineOffsetDec',
)[source]

Calculates the rotation quaternions that take the point (1,0,0) (so az=el=0) in local coordinates to the coordinates specified by end_coord_sys and stores them in transform_store_key. This encodes the boresight pointing and any rotations about this boresight pointing due to coordinate system changes, az/el bearing tilt, etc.

Parameters:
  • transform_store_key (string) – The key where the output transformation quaternion will be stored. If already present in the frame, this calculation will be skipped.

  • end_coord_sys (MapCoordReference) – If Local, the transformation is computed using the negative of the detector delta angle. Otherwise the detector angle is not inverted.

  • do_bad_transform (bool) – If end_coord_sys is not Local and this argument is True, the offset keys are ignored and the coordinate transformation does not take into account rotation about the boresight.

  • bs_az_key (string) – Boresight coordinates in the local coordinate system. If end_coord_sys is Local, only these two keys are required.

  • bs_el_key (string) – Boresight coordinates in the local coordinate system. If end_coord_sys is Local, only these two keys are required.

  • bs_ra_key (string) – Boresight coordinates in the output coordinate system. If do_bad_transform is True, only these two keys and the previous two keys are required.

  • bs_dec_key (string) – Boresight coordinates in the output coordinate system. If do_bad_transform is True, only these two keys and the previous two keys are required.

  • offset_az_key (string) – Local and output coordinates computed at a small offset from boresight. These keys are required if do_bad_transform is False, and will be used to account for any rotation about boresight in the coordinate transformation.

  • offset_el_key (string) – Local and output coordinates computed at a small offset from boresight. These keys are required if do_bad_transform is False, and will be used to account for any rotation about boresight in the coordinate transformation.

  • offset_ra_key (string) – Local and output coordinates computed at a small offset from boresight. These keys are required if do_bad_transform is False, and will be used to account for any rotation about boresight in the coordinate transformation.

  • offset_dec_key (string) – Local and output coordinates computed at a small offset from boresight. These keys are required if do_bad_transform is False, and will be used to account for any rotation about boresight in the coordinate transformation.

spt3g.maps.fitsio.SaveMapFrame(
frame,
output_file=None,
hdr=None,
compress=False,
quantize_level=16.0,
overwrite=False,
)[source]

Save a map frame to a FITS file. See save_skymap_fits for details. The map frame should contain T maps and (optionally) unpolarized weights, or T/Q/U maps and (optionally) polarized weights to store in the output file.

Parameters:
  • output_file (str or callable) – Fits filename to which the map will be written. Maybe a callable function that takes a frame object as its sole input argument and returns a string filename.

  • hdr (dict) – If defined, extra keywords to be appened to the FITS header. The dict can contain entries such as hdr['NEWKEY'] = 'New value' or hdr['NEWKEY'] = ('New value', "Comment for New value").

  • compress (str or bool) – If defined, and if input maps are FlatSkyMap objects, store these in a series of compressed image HDUs, one per map. Otherwise, store input maps in a series of standard ImageHDUs, which are readable with older FITS readers (e.g. idlastro). If defined, the compression algorithm to be used by the Astropy class astropy.io.fits.CompImageHDU. Can be: ‘RICE_1’, ‘RICE_ONE’, ‘PLIO_1’, ‘GZIP_1’, ‘GZIP_2’ or ‘HCOMPRESS_1’. Only GZIP_1 and GZIP_2 are lossless, although only for integer data.

  • quantize_level (float) – Floating point quantization level for compression. Higher values result in more accurate floating point representation, but worse compression ratio. See the astropy FITS image documention for details: https://docs.astropy.org/en/stable/io/fits/api/images.html

  • overwrite (bool) – If True, any existing file with the same name will be ovewritten.

spt3g.maps.map_modules.ApplyWeights(frame)[source]

Apply weights to the input maps. The operation is performed in place to minimize memory use.

spt3g.maps.map_modules.CompactMaps(frame, zero_nans=False)[source]

Compact all maps in a frame to their default sparse representation. Optionally remove NaN values as well. Removing NaN values will reduce memory use, but will remove the distinction in unweighted (or weight-removed) maps between unobserved regions and regions with zero temperature.

spt3g.maps.map_modules.FlattenPol(frame, invert=False)[source]

For maps defined on the sphere the direction of the polarization angle is is defined relative to the direction of North. When making maps we follow this definition.

For any flat sky estimators, the polarization angle is defined relative to the vertical axis. For some map projections the direction of north is not the same as the vertical axis. This function applies a rotation to the Q and U values to switch the curved sky Q/U definition to the flat sky Q/U definition.

If for whatever reason you want to reverse the process set the invert argument to True.

spt3g.maps.map_modules.MakeMapsPolarized(frame, pol_conv=spt3g.maps.MapPolConv.IAU)[source]

Converts individual unpolarized maps to polarized versions of the same map, with the given polarization convention

This module is only a shim that creates null Q and U maps and populates a properly invertible Wpol array from the TT Wunpol weights.

spt3g.maps.map_modules.MakeMapsUnpolarized(frame)[source]

Converts individual polarized maps to temperature-only versions of the same map.

spt3g.maps.map_modules.RebinMaps(frame, scale=1, weighted=True, norm=False)[source]

Rebin any maps in the input frame into larger pixels by summing scale-x-scale blocks of pixels together. Map dimensions must be a multiple of the rebinning scale.

Parameters:
  • scale (int) – Rebinning scale factor, such that scale-x-scale blocks of pixels are summed into larger pixels. Must divide evenly into all map pixel dimensions.

  • weighted (bool) – If True (default), ensure that maps have had weights applied before rebinning. Otherwise, rebin maps without checking the weights.

  • norm (bool) – If False (default), sum all of the sub-pixels into each larger output pixel. If True, normalize the output pixel by the number of sub-pixels each encloses. Only applies to Stokes parameters T/Q/U, not weights or hits.

spt3g.maps.map_modules.RemoveWeights(frame, zero_nans=False)[source]

Remove weights from input maps. If zero_nans is True, empty pixels are skipped and pixels with zero weight are set to 0 instead of NaN. Operation is performed in place to minimize memory use.

spt3g.maps.map_modules.ReplicateMaps(frame, input_map_id, output_map_ids, copy_weights=False)[source]

Clone the input map frame with Id input_map_id into new stub frames, one for each Id listed in output_map_ids.

Parameters:
  • input_map_id (string) – ID of the map frame to replicate. The input frame is discarded after replication.

  • output_map_ids (list of strings) – List of IDs to assign to replicated map frames.

  • copy_weights (bool) – If False, only the first output frame in the list includes a weights key (Wpol or Wunpol). If True, all output frames include a weights key.

spt3g.maps.map_modules.SetPolConv(frame, pol_conv=spt3g.maps.MapPolConv.IAU)[source]

Set or change the polarization convention of the input polarized map frame. If switching between IAU and COSMO conventions, flip the sign of the U map and the TU and QU weights. Otherwise, just set the polarization convention for all maps and weights.

spt3g.maps.map_modules.ValidateMaps(frame, ignore_missing_weights=False)[source]

Validate that the input map frame has all the necessary keys.

If ignore_missing_weights is False (default), a warning is issued when the frame contains weighted Stokes maps without a weights map. Set this option to True when feeding single bolometer map frames with common weights through a pipeline.

spt3g.maps.quathelpers.AddTimingToPointingQuats(fr, key, timing_ref='RawBoresightAz')[source]

Transforms a quaternion pointing timestream <key> from a G3VectorQuat to a G3TimestreamQuat by adding timing information extracted from some other timestream-like object (scalar pointing timestreams, detector timestreams etc.) specified by <timing_ref>. Because this operation is backwards-compatible and involves no data loss, the transformation is done in-place – the previous data are deleted and replaced with the new one.

Useful Classes

Various Python and C++ classes that are part of the public API.

class spt3g.maps.G3SkyMap

Base class for 1- and 2-D skymaps of various projections. Usually you want a subclass of this (e.g. FlatSkyMap) rather than using it directly.

Clone(copy_data=True)
IsCompatible(other)
all(axis=None, out=None, keepdims=False, *, where=True)

Returns True if all elements evaluate to True.

Refer to numpy.all for full documentation.

See also

numpy.all

equivalent function

angle_to_pixel(
alphas: DoubleVector,
deltas: DoubleVector,
) UInt64Vector
angle_to_pixel(alpha: float, delta: float) int

Signature 1: Compute the 1D pixel location for each of the sky coordinates (vectorized)

Signature 2: Compute the 1D pixel location of the given sky position.

angles_to_pixels(
alphas: DoubleVector,
deltas: DoubleVector,
) UInt64Vector

Compute the 1D pixel location for each of the sky coordinates (vectorized)

any(axis=None, out=None, keepdims=False, *, where=True)

Returns True if any of the elements of a evaluate to True.

Refer to numpy.any for full documentation.

See also

numpy.any

equivalent function

apply_mask(mask: G3SkyMapMask, inverse: bool = False)

Apply a mask in-place to the map, optionally inverting which pixels are zeroed. If inverse = False, this is equivalent to in-place multiplication by the mask.

argmax(axis=None, out=None, *, keepdims=False)

Return indices of the maximum values along the given axis.

Refer to numpy.argmax for full documentation.

See also

numpy.argmax

equivalent function

argmin(axis=None, out=None, *, keepdims=False)

Return indices of the minimum values along the given axis.

Refer to numpy.argmin for detailed documentation.

See also

numpy.argmin

equivalent function

clone(copy_data: bool = True) G3SkyMap

Return a map of the same type, populated with a copy of the data if the argument is true (default), empty otherwise.

compact(zero_nans: bool = False)

Convert the map to its default sparse representation, removing empty pixels, and optionally also removing NaN values. A map that is already sparse will be compactified in place in its current representation without additional memory overhead.

compatible(arg: G3SkyMap) bool

Returns true if the input argument is a map with matching dimensions and boundaries on the sky.

copy() G3SkyMap

Return a copy of the map object

get_interp_values(
alphas: DoubleVector,
deltas: DoubleVector,
) DoubleVector
get_interp_values(quats: G3VectorQuat) DoubleVector

Signature 1: Return the values at each of the input coordinate locations. Computes each value using bilinear interpolation over the map pixels.

Signature 2: Return the values at each of the input coordinate locations. Computes each value using bilinear interpolation over the map pixels.

isfinite(where: G3SkyMapMask = None) G3SkyMapMask
isinf(where: G3SkyMapMask = None) G3SkyMapMask
isnan(where: G3SkyMapMask = None) G3SkyMapMask
max(axis=None, out=None, keepdims=False, initial=<no value>, where=True)

Return the maximum along a given axis.

Refer to numpy.amax for full documentation.

See also

numpy.amax

equivalent function

mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)

Returns the average of the array elements along given axis.

Refer to numpy.mean for full documentation.

See also

numpy.mean

equivalent function

median(where: G3SkyMapMask = None) float
min(axis=None, out=None, keepdims=False, initial=<no value>, where=True)

Return the minimum along a given axis.

Refer to numpy.amin for full documentation.

See also

numpy.amin

equivalent function

nanargmax(where: G3SkyMapMask = None) int
nanargmin(where: G3SkyMapMask = None) int
nanmax(where: G3SkyMapMask = None) float
nanmean(where: G3SkyMapMask = None) float
nanmedian(where: G3SkyMapMask = None) float
nanmin(where: G3SkyMapMask = None) float
nanstd(ddof: int = 0, where: G3SkyMapMask = None) float
nansum(where: G3SkyMapMask = None) float
nanvar(ddof: int = 0, where: G3SkyMapMask = None) float
nonzero() UInt64Vector

Return indices of non-zero pixels in the map

pixel_to_angle(pixels: UInt64Vector) tuple
pixel_to_angle(pixel: int) tuple

Signature 1: Compute the sky coordinates of each of the given 1D pixels (vectorized)

Signature 2: Compute the sky coordinates (alpha, delta) of the given 1D pixel

pixel_to_quat(arg: int) Quat
pixel_to_quat(arg: UInt64Vector) G3VectorQuat

Signature 1: Compute the quaternion rotation from the pole corresponding to the given 1D pixel.

Signature 2: Compute the sky coordinates, expressed as quaternion rotations from the pole, for each of the given 1-D pixel coordinates.

pixels_to_angles(pixels: UInt64Vector) tuple

Compute the sky coordinates of each of the given 1D pixels (vectorized)

pixels_to_quats(arg: UInt64Vector) G3VectorQuat

Compute the sky coordinates, expressed as quaternion rotations from the pole, for each of the given 1-D pixel coordinates.

quat_to_pixel(arg: Quat) int
quat_to_pixel(arg: G3VectorQuat) UInt64Vector

Signature 1: Compute the 1D pixel location of the given sky position, expressed as a quaternion rotation from the pole.

Signature 2: Compute the 1D pixel location for each of the sky coordinates (vectorized), expressed as quaternion rotations from the pole.

quats_to_pixels(arg: G3VectorQuat) UInt64Vector

Compute the 1D pixel location for each of the sky coordinates (vectorized), expressed as quaternion rotations from the pole.

query_alpha_ellipse(
alpha: float,
delta: float,
a: float,
b: float,
) UInt64Vector
query_alpha_ellipse(
quat: Quat,
a: float,
b: float,
) UInt64Vector

Signature 1: Return a list of pixel indices whose centers are located within an ellipse extended in the alpha direction, at the given alpha and delta sky coordinates, with semimajor and semiminor axes a and b.

Signature 2: Return a list of pixel indices whose centers are located within an ellipse extended in the alpha direction, at the given alpha and delta sky coordinates, with semimajor and semiminor axes a and b.

query_disc(
alpha: float,
delta: float,
radius: float,
) UInt64Vector
query_disc(quat: Quat, radius: float) UInt64Vector

Signature 1: Return a list of pixel indices whose centers are located within a disc of the given radius at the given sky coordinates.

Signature 2: Return a list of pixel indices whose centers are located within a disc of the given radius at the given sky coordinates.

rebin(scale: int, norm: bool = True) G3SkyMap

Rebin the map into larger pixels by summing (if norm is false) or averaging (if norm is true) scale-x-scale blocks of pixels together. Returns a new map object. Map dimensions must be a multiple of the rebinning scale.

std(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)

Returns the standard deviation of the array elements along given axis.

Refer to numpy.std for full documentation.

See also

numpy.std

equivalent function

sum(axis=None, dtype=None, out=None, keepdims=False, initial=0, where=True)

Return the sum of the array elements over the given axis.

Refer to numpy.sum for full documentation.

See also

numpy.sum

equivalent function

to_mask(
zero_nans: bool = False,
zero_infs: bool = False,
) G3SkyMapMask

Create a G3SkyMapMask object from the parent map, with pixels set to true where the map is non-zero (and optionally non-nan and/or finite).

var(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)

Returns the variance of the array elements, along given axis.

Refer to numpy.var for full documentation.

See also

numpy.var

equivalent function

property coord_ref: MapCoordReference

Coordinate system (maps.MapCoordReference) of the map (e.g. Galactic, Equatorial, etc.)

property npix_allocated: int

Number of pixels in map currently stored in memory

property npix_nonzero: int

Number of nonzero pixels in map currently stored in memory

property overflow: float

Combined value of data processed by the map maker but outside of the map area

property pol_conv: MapPolConv

Polarization convention (maps.MapPolConv) of the map (e.g. maps.MapPolConv.IAU or maps.MapPolConv.COSMO).

property pol_type: MapPolType

Polarization type (maps.MapPolType) of the map (e.g. maps.MapPolType.Q).

property polarized: bool

True if the pol_conv property is set to IAU or COSMO, False otherwise.

property shape: tuple

Shape of map

property size: int

Number of pixels in map

property units: G3TimestreamUnits

Unit class (core.G3TimestreamUnits) of the map (e.g. core.G3TimestreamUnits.Tcmb). Within each unit class, further conversions, for example from K to uK, should use core.G3Units.

property weighted: bool

True if map is multiplied by weights

class spt3g.maps.MapCoordReference(value: int)

Coordinate system of the sky map

Equatorial = spt3g.maps.MapCoordReference.Equatorial
Galactic = spt3g.maps.MapCoordReference.Galactic
Local = spt3g.maps.MapCoordReference.Local
property name: str
names: dict

Mapping of enum names to objects.

{'Equatorial': spt3g.maps.MapCoordReference.Equatorial,
 'Galactic': spt3g.maps.MapCoordReference.Galactic,
 'Local': spt3g.maps.MapCoordReference.Local}
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.maps.MapCoordReference.Local,
 1: spt3g.maps.MapCoordReference.Equatorial,
 2: spt3g.maps.MapCoordReference.Galactic}
class spt3g.maps.MapPolConv(value: int)
class spt3g.maps.MapPolConv(arg: None)

Polarization coordinate convention for Stokes Q/U alignment

COSMO = spt3g.maps.MapPolConv.COSMO
IAU = spt3g.maps.MapPolConv.IAU
property name: str
names: dict

Mapping of enum names to objects.

{'COSMO': spt3g.maps.MapPolConv.COSMO,
 'IAU': spt3g.maps.MapPolConv.IAU,
 'none': spt3g.maps.MapPolConv.none}
none = spt3g.maps.MapPolConv.none
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.maps.MapPolConv.IAU,
 1: spt3g.maps.MapPolConv.COSMO,
 2: spt3g.maps.MapPolConv.none}
class spt3g.maps.MapPolType(value: int)
class spt3g.maps.MapPolType(arg: None)

Polarization identifier for sky maps and and weights

B = spt3g.maps.MapPolType.B
BB = spt3g.maps.MapPolType.BB
E = spt3g.maps.MapPolType.E
EB = spt3g.maps.MapPolType.EB
EE = spt3g.maps.MapPolType.EE
Q = spt3g.maps.MapPolType.Q
QQ = spt3g.maps.MapPolType.QQ
QU = spt3g.maps.MapPolType.QU
T = spt3g.maps.MapPolType.T
TB = spt3g.maps.MapPolType.TB
TE = spt3g.maps.MapPolType.TE
TQ = spt3g.maps.MapPolType.TQ
TT = spt3g.maps.MapPolType.TT
TU = spt3g.maps.MapPolType.TU
U = spt3g.maps.MapPolType.U
UU = spt3g.maps.MapPolType.UU
property name: str
names: dict

Mapping of enum names to objects.

{'B': spt3g.maps.MapPolType.B,
 'BB': spt3g.maps.MapPolType.BB,
 'E': spt3g.maps.MapPolType.E,
 'EB': spt3g.maps.MapPolType.EB,
 'EE': spt3g.maps.MapPolType.EE,
 'Q': spt3g.maps.MapPolType.Q,
 'QQ': spt3g.maps.MapPolType.QQ,
 'QU': spt3g.maps.MapPolType.QU,
 'T': spt3g.maps.MapPolType.T,
 'TB': spt3g.maps.MapPolType.TB,
 'TE': spt3g.maps.MapPolType.TE,
 'TQ': spt3g.maps.MapPolType.TQ,
 'TT': spt3g.maps.MapPolType.TT,
 'TU': spt3g.maps.MapPolType.TU,
 'U': spt3g.maps.MapPolType.U,
 'UU': spt3g.maps.MapPolType.UU,
 'none': spt3g.maps.MapPolType.none}
none = spt3g.maps.MapPolType.none
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.maps.MapPolType.T,
 1: spt3g.maps.MapPolType.Q,
 2: spt3g.maps.MapPolType.U,
 3: spt3g.maps.MapPolType.E,
 4: spt3g.maps.MapPolType.B,
 7: spt3g.maps.MapPolType.none,
 8: spt3g.maps.MapPolType.TT,
 9: spt3g.maps.MapPolType.TQ,
 10: spt3g.maps.MapPolType.TU,
 11: spt3g.maps.MapPolType.QQ,
 12: spt3g.maps.MapPolType.QU,
 13: spt3g.maps.MapPolType.UU,
 14: spt3g.maps.MapPolType.TE,
 15: spt3g.maps.MapPolType.TB,
 16: spt3g.maps.MapPolType.EE,
 17: spt3g.maps.MapPolType.EB,
 18: spt3g.maps.MapPolType.BB}
class spt3g.maps.MapProjection(value: int)
class spt3g.maps.MapProjection(arg: None)

Flat sky map projection

Proj0 = spt3g.maps.MapProjection.ProjSFL
Proj1 = spt3g.maps.MapProjection.ProjCAR
Proj2 = spt3g.maps.MapProjection.ProjSIN
Proj3 = spt3g.maps.MapProjection.ProjARC
Proj4 = spt3g.maps.MapProjection.ProjSTG
Proj5 = spt3g.maps.MapProjection.ProjZEA
Proj6 = spt3g.maps.MapProjection.ProjTAN
Proj7 = spt3g.maps.MapProjection.ProjCEA
Proj8 = spt3g.maps.MapProjection.Proj8
Proj9 = spt3g.maps.MapProjection.ProjBICEP
ProjARC = spt3g.maps.MapProjection.ProjARC
ProjBICEP = spt3g.maps.MapProjection.ProjBICEP
ProjCAR = spt3g.maps.MapProjection.ProjCAR
ProjCEA = spt3g.maps.MapProjection.ProjCEA
ProjCylindricalEqualArea = spt3g.maps.MapProjection.ProjCEA
ProjGnomonic = spt3g.maps.MapProjection.ProjTAN
ProjLambertAzimuthalEqualArea = spt3g.maps.MapProjection.ProjZEA
ProjNone = spt3g.maps.MapProjection.ProjNone
ProjOrthographic = spt3g.maps.MapProjection.ProjSIN
ProjPlateCarree = spt3g.maps.MapProjection.ProjCAR
ProjSFL = spt3g.maps.MapProjection.ProjSFL
ProjSIN = spt3g.maps.MapProjection.ProjSIN
ProjSTG = spt3g.maps.MapProjection.ProjSTG
ProjSansonFlamsteed = spt3g.maps.MapProjection.ProjSFL
ProjStereographic = spt3g.maps.MapProjection.ProjSTG
ProjTAN = spt3g.maps.MapProjection.ProjTAN
ProjZEA = spt3g.maps.MapProjection.ProjZEA
ProjZenithalEquidistant = spt3g.maps.MapProjection.ProjARC
property name: str
names: dict

Mapping of enum names to objects.

{'Proj8': spt3g.maps.MapProjection.Proj8,
 'ProjARC': spt3g.maps.MapProjection.ProjARC,
 'ProjBICEP': spt3g.maps.MapProjection.ProjBICEP,
 'ProjCAR': spt3g.maps.MapProjection.ProjCAR,
 'ProjCEA': spt3g.maps.MapProjection.ProjCEA,
 'ProjNone': spt3g.maps.MapProjection.ProjNone,
 'ProjSFL': spt3g.maps.MapProjection.ProjSFL,
 'ProjSIN': spt3g.maps.MapProjection.ProjSIN,
 'ProjSTG': spt3g.maps.MapProjection.ProjSTG,
 'ProjTAN': spt3g.maps.MapProjection.ProjTAN,
 'ProjZEA': spt3g.maps.MapProjection.ProjZEA}
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.maps.MapProjection.ProjSFL,
 1: spt3g.maps.MapProjection.ProjCAR,
 2: spt3g.maps.MapProjection.ProjSIN,
 3: spt3g.maps.MapProjection.ProjARC,
 4: spt3g.maps.MapProjection.ProjSTG,
 5: spt3g.maps.MapProjection.ProjZEA,
 6: spt3g.maps.MapProjection.ProjTAN,
 7: spt3g.maps.MapProjection.ProjCEA,
 8: spt3g.maps.MapProjection.Proj8,
 9: spt3g.maps.MapProjection.ProjBICEP,
 42: spt3g.maps.MapProjection.ProjNone}

Useful Functions

Various Python and C++ functions that are part of the public API.

spt3g.maps.apply_weights(
T: G3SkyMap,
Q: G3SkyMap,
U: G3SkyMap,
W: G3SkyMapWeights,
)

Apply weights to polarized maps.

spt3g.maps.apply_weights_t(T: G3SkyMap, W: G3SkyMapWeights)

Apply weights to unpolarized maps.

spt3g.maps.azel.convert_azel_to_radec(az, el, location='spt', mjd=None)[source]

Convert timestreams of local azimuth and elevation to right ascension and declination.

Parameters:
  • az (np.ndarray or G3Timestream) – Array of local coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

  • el (np.ndarray or G3Timestream) – Array of local coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

  • location (str or astropy.coordinates.EarthLocation instance) – The telescope location on Earth.

  • mjd (np.ndarray) – An array of times for each az/el sample. If input az and el are not G3Timestreams, this argument is required.

Returns:

ra, dec

Return type:

np.ndarray or G3Timestream

spt3g.maps.azel.convert_gal_to_radec(glon, glat)[source]

Convert timestreams of Galactic longitude and latitude to right ascension and declination.

Parameters:
  • glon (np.ndarray or G3Timestream) – Array of Galactic sky coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

  • glat (np.ndarray or G3Timestream) – Array of Galactic sky coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

Returns:

ra, dec

Return type:

np.ndarray or G3Timestream

spt3g.maps.azel.convert_radec_to_azel(ra, dec, location='spt', mjd=None)[source]

Convert timestreams of right ascension and declination to local azimuth and elevation.

Parameters:
  • ra (np.ndarray or G3Timestream) – Array of Equatorial sky coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

  • dec (np.ndarray or G3Timestream) – Array of Equatorial sky coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

  • location (str or astropy.coordinates.EarthLocation instance) – The telescope location on Earth.

  • mjd (np.ndarray) – An array of times for each ra/dec sample. If input ra and dec are not G3Timestreams, this argument is required.

Returns:

az, el

Return type:

np.ndarray or G3Timestream

spt3g.maps.azel.convert_radec_to_gal(ra, dec)[source]

Convert timestreams of right ascension and declination to Galactic longitude and latitude.

Parameters:
  • ra (np.ndarray or G3Timestream) – Array of Equatorial sky coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

  • dec (np.ndarray or G3Timestream) – Array of Equatorial sky coordinates. If inputs are G3Timestream objects, G3Timestreams are also returned.

Returns:

glon, glat

Return type:

np.ndarray or G3Timestream

spt3g.maps.convolve_map(
map: FlatSkyMap,
kernel: FlatSkyMap,
) FlatSkyMap
spt3g.maps.convolve_map(map: FlatSkyMap, kernel: Buffer) FlatSkyMap

Signature 1: Convolve the input flat sky map with the given map-space kernel. The kernel must have odd dimensions and the same resolution as the map.

Signature 2: Convolve the input flat sky map with the given 2D array kernel. The kernel must have odd dimensions and is assumed to have the same resolution as the map.

spt3g.maps.fitsio.load_skymap_fits(filename, hdu=None, keys=None, memmap=False, apply_units=False)[source]

Load a fits file containing a sky map.

Parameters:
  • filename (str) – Path to fits file

  • hdu (int, optional) – If supplied, the data are extract from the given HDU index.

  • keys (list of strings, optional) – If supplied, return only these keys in the output dictionary. Options are: T, Q, U, W.

  • memmap (bool, optional) – Argument passed to astropy.io.fits.open. If True, the map is not read into memory, but only the required pixels are read when needed. Default: False.

  • apply_units (bool, optional) – If True, and input maps have known units, multiply by the appropriate conversion factor to return maps in G3Units.

Return type:

a dictionary of maps keyed with e.g. ‘T’, ’Q’, ‘U’ and ‘W’.

spt3g.maps.fitsio.load_skymapmask_fits(filename, hdu=None, memmap=False)[source]

Load a fits file containing a binary sky map mask. Floating pointing or integer data are converted to booleans. Assumes the fits file contains a single mask, with flat sky data stored in a single ImageHDU, and healpix masks stored in a single BinTableHDU in full-sky format with implicit indexing over all pixels.

Parameters:
  • filename (str) – Path to fits file

  • hdu (int, optional) – If supplied, the data are extract from the given HDU index.

  • memmap (bool, optional) – Argument passed to astropy.io.fits.open. If True, the map is not read into memory, but only the required pixels are read when needed. Default: False.

Returns:

The binary mask.

Return type:

G3SkyMapMask

spt3g.maps.fitsio.save_skymap_fits(
filename,
T,
Q=None,
U=None,
W=None,
overwrite=False,
compress=False,
quantize_level=16.0,
hdr=None,
)[source]

Save G3 map objects to a fits file.

FlatSkyMap objects are stored in a series of (optionally compressed) ImageHDU entries, in which each HDU contains the projection information in its header in standard WCS format, along with the image data for a single map (one of the Stokes maps or a weight map component).

HealpixSkyMap objects are stored in a BinTableHDU extension, which contains the necessary header information for compatiblity with healpix map readers (e.g. healpix.read_map), and a single table with one column per Stokes map or weight map component. Sparse maps are stored as cut-sky pixel-indexed tables, while dense maps are stored with implicit indexing over all pixels. The former produces output that is equivalent to using healpy.write_map with the partial=True option.

Parameters:
  • filename (str) – Path to output file. Must not exist, unless overwrite is True.

  • T (FlatSkyMap or HealpixSkyMap) – Maps to save

  • Q (FlatSkyMap or HealpixSkyMap) – Maps to save

  • U (FlatSkyMap or HealpixSkyMap) – Maps to save

  • W (G3SkyMapWeights) – Weights to save with the maps

  • overwrite (bool) – If True, any existing file with the same name will be ovewritten.

  • compress (str or bool) – If defined, and if input maps are FlatSkyMap objects, store these in a series of compressed image HDUs, one per map. Otherwise, store input maps in a series of standard ImageHDUs, which are readable with older FITS readers (e.g. idlastro). If defined, the compression algorithm to be used by the Astropy class astropy.io.fits.CompImageHDU. Can be: ‘RICE_1’, ‘RICE_ONE’, ‘PLIO_1’, ‘GZIP_1’, ‘GZIP_2’ or ‘HCOMPRESS_1’. Only GZIP_1 and GZIP_2 are lossless, although only for integer data.

  • quantize_level (float) – Floating point quantization level for compression. Higher values result in more accurate floating point representation, but worse compression ratio. See the astropy FITS image documention for details: https://docs.astropy.org/en/stable/io/fits/api/images.html

  • hdr (dict) – If defined, extra keywords to be appened to the FITS header. The dict can contain entries such as hdr['NEWKEY'] = 'New value' or hdr['NEWKEY'] = ('New value', "Comment for New value").

spt3g.maps.fitsio.save_skymapmask_fits(filename, mask, overwrite=False, compress=False, hdr=None)[source]

Save G3 mask objects to a fits file.

Masks with FlatSkyMap parents are stored in a (optionally compressed) ImageHDU entry, which contains the projection information in its header in standard WCS format, along with the image data for a single mask.

Masks with HealpixSkyMap parents are stored in a BinTableHDU extension, which contains the necessary header information for compatiblity with healpix map readers (e.g. healpix.read_map), and a single table with one column for the mask. Masks are stored densely with implicit indexing over all pixels.

Parameters:
  • filename (str) – Path to output file. Must not exist, unless overwrite is True.

  • mask (G3SkyMapMask) – Mask to save

  • overwrite (bool) – If True, any existing file with the same name will be ovewritten.

  • compress (str or bool) – If defined, and if input mask has a FlatSkyMap parent, store this in a compressed image HDU. Otherwise, store input mask in a standard ImageHDU, which is readable with older FITS readers (e.g. idlastro). If defined, the compression algorithm to be used by the Astropy class astropy.io.fits.CompImageHDU. Can be: ‘RICE_1’, ‘RICE_ONE’, ‘PLIO_1’, ‘GZIP_1’, ‘GZIP_2’ or ‘HCOMPRESS_1’. Only GZIP_1 and GZIP_2 are lossless, although only for integer data.

  • hdr (dict) – If defined, extra keywords to be appened to the FITS header. The dict can contain entries such as hdr['NEWKEY'] = 'New value' or hdr['NEWKEY'] = ('New value', "Comment for New value").

spt3g.maps.flatten_pol(
Q: FlatSkyMap,
U: FlatSkyMap,
W: G3SkyMapWeights = None,
h: float = 0.001,
invert: bool = False,
)

For maps defined on the sphere the direction of the polarization angle is is defined relative to the direction of North. When making maps we follow this definition.

For any flat sky estimators, the polarization angle is defined relative to the vertical axis. For some map projections the direction of north is not the same as the vertical axis. This function applies a rotation to the Q and U values to switch the curved sky Q/U definition to the flat sky Q/U definition.

If for whatever reason you want to reverse the process set the invert argument to True. Also applies the appropriate rotation to the Q and u elements of the associated weights.

spt3g.maps.get_boresight_rotator_timestream(
az_0: G3Timestream,
el_0: G3Timestream,
ra_0: G3Timestream,
dec_0: G3Timestream,
az_1: G3Timestream,
el_1: G3Timestream,
ra_1: G3Timestream,
dec_1: G3Timestream,
) G3TimestreamQuat

Construct a transform quaternion timestream from timestreams of local and equatorial boresight pointing coordinates. Computes the transform from local (az_0, el_0) coordinates to equatorial (ra_0, dec_0), accounting for rotation about the boresight by including the second set of points.

spt3g.maps.get_detector_pointing(
x_offset: float,
y_offset: float,
trans: G3VectorQuat,
coord_sys: MapCoordReference,
) tuple

Construct detector pointing vectors (alpha, delta) for the given pointing offsets (x_offset, y_offset) and boresight quaternion vector trans.

spt3g.maps.get_detector_pointing_quats(
x_offset: float,
y_offset: float,
trans: G3VectorQuat,
coord_sys: MapCoordReference,
) G3VectorQuat

Construct the detector pointing quaternion vector for the given pointing offsets (x_offset, y_offset) and boresight quaternion vector trans.

spt3g.maps.get_fk5_j2000_to_gal_quat() Quat

Return the rotation quaternion to rotate from equatorial to galactic coordinates.

spt3g.maps.get_galactic_plane_mask(
map_in: G3SkyMap,
glat: float,
) G3SkyMapMask

Returns a mask that is nonzero for any pixels within +/- the given latitude about the Galactic plane.

spt3g.maps.get_map_hist(
map: G3SkyMap,
bin_edges: DoubleVector,
mask: G3SkyMapMask = None,
ignore_zeros: bool = False,
ignore_nans: bool = False,
ignore_infs: bool = False,
) DoubleVector

Computes the histogram of the input map into bins defined by the array of bin edges, optionally ignoring zero, nan and/or inf values in the map. If a mask is supplied, then only the non-zero pixels in the mask are included.

spt3g.maps.get_map_moments(
map: G3SkyMap,
mask: G3SkyMapMask = None,
order: int = 2,
ignore_zeros: bool = False,
ignore_nans: bool = False,
ignore_infs: bool = False,
) DoubleVector

Computes moment statistics of the input map, optionally ignoring zero, nan and/or inf values in the map. If order = 1, only the mean is returned. If order = 2, 3 or 4 then the variance, skew and kurtosis are also included, respectively. If a mask is supplied, then only the non-zero pixels in the mask are included.

spt3g.maps.get_origin_rotator(alpha: float, delta: float) Quat

Compute the transformation quaternion that would rotate the vector (1, 0, 0) to point in the given direction.

spt3g.maps.get_origin_rotator_timestream(
alpha: G3Timestream,
delta: G3Timestream,
coord_sys: MapCoordReference,
) G3TimestreamQuat

Construct a transform quaternion timestream from timestreams of sky coordinates. Equivalent to R_z(alpha) * R_y(delta).

spt3g.maps.get_ra_dec_map(map_in: G3SkyMap) tuple

Returns maps of the ra and dec angles for each pixel in the input map

spt3g.maps.get_ra_dec_mask(
map_in: G3SkyMap,
ra_left: float,
ra_right: float,
dec_bottom: float,
dec_top: float,
) G3SkyMapMask

Returns a mask that is nonzero for any pixels within the given ra and dec ranges

spt3g.maps.get_rot_ang(start_q: Quat, trans: Quat) float

Computes the boresight rotation of the vector start_q when rotated by trans.

spt3g.maps.get_transform_quat(
as_0: float,
ds_0: float,
ae_0: float,
de_0: float,
as_1: float,
ds_1: float,
ae_1: float,
de_1: float,
) Quat

Computes a rotation that will take (as_0,ds_0) to (ae_0, de_0) and (as_1, ds_1) to (ae_1, de_1)

spt3g.maps.make_point_source_mask(
map: G3SkyMap,
ra: DoubleVector,
dec: DoubleVector,
radius: DoubleVector,
) G3SkyMapMask

Construct a mask from the input stub map with pixels within the given radius around each point source position set to 1.

spt3g.maps.map_modules.coadd_map_files(
input_files,
output_file=None,
coadder=None,
map_ids=None,
output_map_id='Coadd',
collate=False,
weighted=True,
record_obs_id=False,
)[source]

Coadd map files, optionally collating map Id’s into separate frames.

Parameters:
  • input_files (list of str) – List of input files to feed through the pipeline.

  • output_file (str) – Output G3 filename. If not supplied, the output frames are returned without saving to disk.

  • coadder (CoaddMaps instance) – If set, use this instantiated module in the coadding pipeline. In this case, all other keyword arguments below are ignored.

  • map_ids (list of str) – A list of map Id’s to include in the coadd(s).

  • output_map_id (str) – Id to use for the output map frame. If collate is True, this is the prefix applied to each output frame, with the input map Id appended to it.

  • collate (bool) – If True, coadd individual map Id’s into separate map frames. Otherwise, all map frames are coadded into one output frame.

  • weighted (bool) – If True, ensure that weights have been applied before coadding. Otherwise, the input maps are coadded as they are.

  • record_obs_id (bool) – If True, include source name and observation ID info in the output coadd frame InputMapIds key, along with the map ID for each input frame. If False, only the map frame ID is included.

Returns:

maps – If collate is True, returns a dictionary of map frames keyed by Id. Otherwise, returns a single map frame.

Return type:

G3Frame or dict of G3Frames

spt3g.maps.maputils.flatsky_to_healpix(
map_in,
map_stub=None,
rebin=1,
interp=False,
fullsky=False,
**kwargs,
)[source]

Re-pixelize a map to Healpix from one of the flat projections.

All additional keyword arguments are passed to HealpixSkyMap to construct the output map object. Required if map_stub is not supplied, otherwise ignored.

Maps can be rotated between Equatorial and Galactic coordinates, and/or change polarization convention between COSMO and IAU, by setting the appropriate attributes of the input and output maps. Attributes not defined in the output map are assumed to be that of the input map.

Parameters:
  • map_in (FlatSkyMap) – The input map you want to reproject

  • map_stub (HealpixSkyMap) – Stub output map object to be used to construct the output map. If not supplied, one will be constructed using the remaining keyword arguments.

  • rebin (int) – If supplied and >1, subdivide the output pixel by n x n with each sub-pixel taking on the input map values at pixel center (with interp or nearest neighbor). The output pixel takes on the average of the sub-pixel values. In the case that the input map has higher resolution than the output map (and that the input map is not low-pass filtered to remove information above the Nyquist freq. of the output map pixel), this reduces aliasing compared with direct sampling. But there would still be aliased power from the input map from freq above the ouput map pixel’s Nyquist.

  • interp (bool) – If True, use bilinear interpolation to extract values from the input map. Otherwise, the nearest-neighbor value is used.

  • fullsky (bool) – If True a full-sky numpy array representation of the map is returned. Otherwise, a HealpixSkyMap instance is returned, containing only the pixels that overlap with the input map.

Returns:

output_map – The array containing the healpix map. If fullsky is True, this is a numpy array, otherwise a HealpixSkyMap instance.

Return type:

numpy array or HealpixSkyMap

spt3g.maps.maputils.healpix_to_flatsky(
map_in,
nest=False,
map_stub=None,
rebin=1,
interp=False,
**kwargs,
)[source]

Re-pixelize a map from Healpix to one of the flat sky projections.

All additional keyword arguments are passed to FlatSkyMap to construct the output map object. Required if map_stub is not supplied, otherwise ignored.

Maps can be rotated between Equatorial and Galactic coordinates, and/or change polarization convention between COSMO and IAU, by setting the appropriate attributes of the input and output maps. Note that if the input map is a numpy array representation of a healpix map, the coordinate system and polarization convention are assumed to be that of the output map. Conversely, attributes not defined in the output map are assumed to be that of the input map.

Parameters:
  • map_in (numpy array or HealpixSkyMap) – The array containing the input healpix map to reproject.

  • nest (bool) – Ordering of the healpix map, if the input is a numpy array. Ring ordering is assumed by default.

  • map_stub (FlatSkyMap) – Stub output map object to be used to construct the output map. If not supplied, one will be constructed using the remaining keyword arguments.

  • rebin (int) – If supplied and >1, subdivide the output pixel by n x n with each sub-pixel taking on the input map values at pixel center (with interp or nearest neighbor). The output pixel takes on the average of the sub-pixel values. In the case that the input map has higher resolution than the output map (and that the input map is not low-pass filtered to remove information above the Nyquist freq. of the output map pixel), this reduces aliasing compared with direct sampling. But there would still be aliased power from the input map from freq above the ouput map pixel’s Nyquist.

  • interp (bool) – If True, use bilinear interpolation to extract values from the 4 closest pixel centers of the healpix map. Otherwise, the nearest-neighbor value is used.

Returns:

output_map – The reprojected map

Return type:

FlatSkyMap

spt3g.maps.offsets_to_quat(x: float, y: float) Quat

Returns the vector quaternion (0,1,0,0) rotated by the given x and y offsets. Equivalent to t * quat(0,1,0,0) / t, where t = get_origin_rotator(x, -y)

spt3g.maps.quathelpers.ang_to_quat(alpha, delta, start=None, stop=None)[source]

Convert a set of angles (or vector of them) specified as a (longitude, latitude) pair to a pointing quaternion (or vector of them). If start and stop are defined, the return value for vectors will be a G3TimestreamQuat with start and stop times set to the provided values.

spt3g.maps.quathelpers.quat_to_ang(q)[source]

Convert a pointing quaternion (or vector of them) to a set of angles (or vector of them) specified as a (longitude, latitude) pair.

spt3g.maps.remove_weights(
T: G3SkyMap,
Q: G3SkyMap,
U: G3SkyMap,
W: G3SkyMapWeights,
zero_nans: bool = False,
)

Remove weights from polarized maps. If zero_nans is true, empty pixels are skipped, and pixels with zero weight are set to 0 instead of nan.

spt3g.maps.remove_weights_t(
T: G3SkyMap,
W: G3SkyMapWeights,
zero_nans: bool = False,
)

Remove weights from unpolarized maps. If zero_nans is true, empty pixels are skipped, and pixels with zero weight are set to 0 instead of nan.

spt3g.maps.reproj_map(
in_map: G3SkyMap,
out_map: G3SkyMap,
rebin: int = 1,
interp: bool = False,
mask: G3SkyMapMask = None,
)

Reprojects the data from in_map onto out_map. out_map can have a different projection, size, resolution, etc. Optionally account for sub-pixel structure by setting rebin > 1 and/or enable bilinear interpolation of values from the input map by setting interp=True. Use the maps’ coord_ref attributes to rotate between Equatorial and Galactic coordinate systems. Use the maps’ pol_conv attributes to switch between COSMO and IAU polarization conventions. If output attributes are not set, they will be copied from the input map. out_map_mask, if given, skip the unused pixelsand set these pixels to 0.