Working with time-ordered data (TOD)¶
The TOD class is the basic container for detector and pointing data. Populating a TOD with data can be done a number of different ways, so loading TODs is normally done through the moby2.scripting.get_tod function, which is able to decode complicated parameters and handle the peculiarities of different experiments.
Quick start¶
To load all of the detector and pointing data for a dirfile:
import moby2
filename = '1234560000.1234569999.ar1'
tod = moby2.scripting.get_tod({'filename': filename})
Look at the data and pointing info:
>>> print tod.data.shape
(1056, 256000)
>>> print tod.data[0] # First detector data
[1.34e3, 1.33e3, ...]
>>> print tod.az
[...]
>>> print tod.alt
[...]
To load only certain samples, use the start
and end
arguments.
These have the same semantics as array indices [start:end], including
the handling of negative arguments:
# Load samples 200 to 1200 samples
tod = moby2.TOD.from_dirfile({'filename': filename,
'start': 200, 'end': 1200})
# Load entire TOD except for the last 400 samples:
tod = moby2.TOD.from_dirfile({'filename', 'end': -400})
To select particular detectors, use det_uid
or rows
and
cols
with read_block
:
# Load detector channel 123
tod = moby2.TOD.from_dirfile({'filename': filename, 'det_uid': [123]})
# Load multiplexing row 2
tod = moby2.TOD.from_dirfile({'filename': filename, 'rows': [2]})
# Load only (row 2, col 3) and (row 8, col 0) by passing block_read=False
tod = moby2.TOD.from_dirfile({'filename': filename,
'rows': [2,8], 'cols': [3,0],
'block_read': False})
Full class documentation¶
-
class
moby2.
TOD
(n_samples, n_dets=None, create_data=True, create_pointing=True, info=None)[source]¶ -
abuses
= None¶ A place to log processing operations
-
alt
= None¶ Boresight altitude in radians (n_samp)
-
az
= None¶ Boresight azimuth in radians (n_samp)
-
copy
(copy_data=True, copy_pointing=True, copy_id=True, copy_cuts=True, copy_info=True, resample=1, resample_filter=True, resample_offset=None)[source]¶ Return a copy of the TOD. A complete copy is made of all detector and pointing data unless the corresponding copy_* field is passed in.
This routine can also resample a TOD. The TOD is resampled at every Nth index, where N is a (possibly non-integral) value given by the
resample
parameter. If resample_filter=True, then a low-pass filter is used to resample the detector data… but that only currently works if resample is a power of 2.
-
ctime
= None¶ Time, as unix timestamp (n_samp)
-
cuts
= None¶ A preferred TODCuts object for the TOD
-
data
= None¶ The detector data, a numpy array of shape (n_det,n_samp)
-
det_uid
= None¶ Detector uids; integer array of shape (n_dept)
-
enc_flags
= None¶ Pointing validity indicator (n_samp)
-
get_hk
(fields, filename=None, start=None, count=None, dtype='float32', fix_gaps=False)[source]¶ Load housekeeping (or other) fields from a dirfile. Assuming that the TOD was loaded using TOD.for_dirfile, this function will look to the same dirfile and load the data corresponding to the same sample indices.
“fields” can be a string, or a list of string. The function will return an array or a list of arrays, respectively.
If you need to override the dirfile name, pass “filename”. If you want different starting or stopping indices, use “start” and “count”. To manipulate the output data type, set dtype (our wrapping of getdata probably only supports float32, float64, int32, int64, and maybe some unsigned ints).
Set fix_gaps=True to attempt patching of non-400 Hz ACTPol HK data in cases where the encoder tick dropped out for a while. Missing samples will be interpolated.
-
info
= None¶ A TODInfo object providing misc. TOD metadata
-
classmethod
init_from_dirfile
(filename=None, start=None, end=None, channel_names=[], hk_spec=[], extractor=None, read_data=True)[source]¶ Create a TOD object with data taken from a (probably ACT-style) dirfile. Since we use libactpol calls, the dirfile can be slimmed and zipped.
-
nsamps
= None¶ n_samp
-