tod_io
File I/O utilities for beam maps, scan data, and TOD output.
- tod_io.load_beam(folder_beam, filename, center_x=None, center_y=None)[source]
Load a beam map and return RA/Dec offsets and pixel amplitudes.
Reads a pixell/enmap FITS beam map, extracts the WCS-based sky coordinates, and returns them as offsets relative to the beam centre pixel.
- Parameters:
folder_beam (str) – Path to the directory containing beam FITS files. Must end with a path separator.
filename (str) – Filename of the beam FITS file relative to
folder_beam.center_x (int or None) – Row index of the beam centre pixel in the matrix. When
None(default),H // 2is used.center_y (int or None) – Column index of the beam centre pixel in the matrix. When
None(default),W // 2is used.
- Returns:
ra (numpy.ndarray) – RA offsets from beam centre [rad], same shape as the beam map.
dec (numpy.ndarray) – Dec offsets from beam centre [rad], same shape as the beam map.
pixel_map (numpy.ndarray) – Beam amplitude values (linear, not dB), same shape as the beam map.
- Return type:
- tod_io.load_scan_information(folder)[source]
Discover the number of observation days and the sampling rate.
Scans
folderfor files namedpsi_N.npyand infers the total day count from the highest index found. The sample rate is estimated from the length of the first psi file divided by 86 400 (seconds per day).
- tod_io.open_scan_day(folder_scan, day_index)[source]
Open the three scan-data files for one day as persistent memory-maps.
The caller is responsible for holding the returned objects alive for as long as slices from them are needed. If the returned memmap references are reassigned or garbage-collected, subsequent array slices will silently read stale or zeroed memory — keep at least one live reference per day for the entire processing window of that day. Keeping the mmaps open across all batches avoids the repeated open/header-parse/mmap syscalls that
load_scan_data_batch()would otherwise incur on every batch call.- Parameters:
- Returns:
theta_mmap (numpy.memmap) – Boresight colatitude [rad].
phi_mmap (numpy.memmap) – Boresight longitude [rad].
psi_mmap (numpy.memmap) – Polarisation roll angle [rad].
- Return type:
- tod_io.load_scan_data_batch(folder_scan, day_index, start_idx, end_idx, dtype=<class 'numpy.float32'>)[source]
Load a contiguous batch of scan samples for one day into RAM.
Opens the three scan files for
day_indexas memory-maps, slices the requested sample range, and returns them as contiguous arrays of the requested dtype. Preferopen_scan_day()when processing many batches from the same day to avoid redundant file opens.- Parameters:
folder_scan (str) – Path to the scan data directory. Must end with a path separator.
day_index (int) – Zero-based index of the observation day.
start_idx (int) – First sample index (inclusive).
end_idx (int) – Last sample index (exclusive).
dtype (numpy.dtype) – Output dtype for theta/phi/psi. Defaults to
np.float32; passtod_config.precision_dtypeto honour the run-wide precision setting.
- Returns:
theta (numpy.ndarray) – Boresight colatitude [rad], shape
(end_idx - start_idx,).phi (numpy.ndarray) – Boresight longitude [rad], same shape.
psi (numpy.ndarray) – Polarisation roll angle [rad], same shape.
- Return type: