litebird / litebird_sim

Simulation tools for LiteBIRD
GNU General Public License v3.0
18 stars 13 forks source link

Better handling of multiple TODs #225

Closed ziotom78 closed 1 year ago

ziotom78 commented 1 year ago

This PR implements a high-level API to allocate multiple TODs during a call to Simulation.create_observations: the new parameter tods lets the caller to specify how many TOD matrices must be allocated, their dtype, and a short description. This information is used when TODs are saved to HDF5 files and is restored properly when those files are read.

ziotom78 commented 1 year ago

This PR should be complete. The new API lets the user to allocate several TODs at once:

    sim.create_observations(
        detectors=[det1, det2, det3],
        tods=[
            lbs.TodDescription(
                name="tod", description="TOD", dtype=np.float64,
            ),
            lbs.TodDescription(
                name="noise", description="1/f+white noise", dtype=np.float32
            ),
        ],
    )

    for cur_obs in sim.observations:
        print("Shape of 'tod': ", cur_obs.tod.shape)
        print("Shape of 'noise': ", cur_obs.noise.shape)

These TODs are reported by Simulation.describe_mpi_distribution and can be referred to when saving/loading HDF5 files.