simonsobs / sotodlib

Simons Observatory: Time-Ordered Data processing library.
MIT License
16 stars 19 forks source link

G3tSmurf: Fix Multislot Observations #179

Closed kmharrington closed 2 years ago

kmharrington commented 3 years ago

G3tSmurf is currently making observations per slot / stream_id. This isn't surprising given how the code is currently written but does not mesh with how context wants observations organized.

This adds new questions we need to deal with regarding synchronization because each slot will start streaming at slightly different times. Here's an example from the most recent streaming tests:

Observation:  1633987456: 2021-10-11 17:24:16 -> 2021-10-11 18:24:29.252010 [1:00:13.252010] (None)
Tuneset/Detset [('1633642729_tune.npy', 'crate1slot2')]
Files:
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_006.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_005.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_004.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_003.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_002.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_001.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot2/1633987463_000.g3
Observation:  1633987468: 2021-10-11 17:24:28 -> 2021-10-11 18:24:41.469677 [1:00:13.469677] (None)
Tuneset/Detset [('1633644164_tune.npy', 'crate1slot3')]
Files:
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_006.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_005.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_004.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_003.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_002.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_001.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot3/1633987475_000.g3
Observation:  1633987477: 2021-10-11 17:24:37 -> 2021-10-11 18:24:50.746929 [1:00:13.746929] (None)
Tuneset/Detset [('1633652245_tune.npy', 'crate1slot4')]
Files:
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_006.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_005.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_004.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_003.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_002.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_001.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot4/1633987485_000.g3
Observation:  1633987490: 2021-10-11 17:24:50 -> 2021-10-11 18:25:03.452792 [1:00:13.452792] (None)
Tuneset/Detset [('1633652636_tune.npy', 'crate1slot5')]
Files:
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_006.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_005.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_004.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_003.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_002.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_001.g3
     /mnt/so1/data/pton-rd/timestreams/16339/crate1slot5/1633987498_000.g3

Note how each observation has a slightly different timestamp, that's because there are slight delays between calling for starts (and stops).

Do we define observations as the maximum overlap between all slots? If one slot starts streaming while another is already running do we always assume we only care about the overlapped regions? If the start of streaming is separated by X time do we make different observations?

mhasself commented 3 years ago

(First, but in brackets: why are these spread out so much in time? We can get the acqs to all start/stop within a second or so of each other, right?)

Data should only be treated as a single "observation" if they are strictly co-sampled and if they have reasonable close (like <1 or 2 seconds) start and stop times. This is to resolve the trimming issue you describe, as well as make it possible to load all of them into a single AxisManager without worrying about slight time offsets. (Perfectly co-sampled data, spread across multiple files, was the origin of the "detset" -- a detset constitutes the detectors in one time-ordered set of files.)

So I would say that these acquisitions should be separate observations, called, perhaps "crate1slot2_1633987463", "crate1slot3_1633987475", "crate1slot4_1633987485", "crate1slot5_1633987498".

I would encourage you to use ObsDb to group those (separate) observations together, so you can easily gather and analyze all the files from that acquisition event ... e.g. make an ObsDb field, perhaps "acq_event=", for which they would all share the same value. This is what the ObsDb is intended for -- tagging and grouping observations.

At the observatory, we do plan to bundle multiple blades into a single Observation. This is the Bookbinder's job, using information from the main observatory database. It will copy the data into a new set of files, with all of them starting and stopping on exactly the same sample; it will also "reframe" the data to improve compression, load speed, and certain kinds of analysis. But the key difference for survey data at the observatory is:

a) we will know exactly what acqs were commanded to start and stop together b) the smurfs are all on the master timing system, which makes them perfectly co-sampled.