litebird / litebird_sim

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

Error in reading observation when it does not have tod field #261

Closed marcobortolami closed 1 year ago

marcobortolami commented 1 year ago

Hi:) While working on the post-ptep e2e simulations, I noticed that if we try to read an observation saved without the tod field, I mean there is no obs.tod, then lines 543 and 568-569 give an error as there is no result.tod. I propose to change these lines as follows (this is a git diff output):

                 # All the fields must conform to the same shape as `Observation.tod`
-                assert result.tod.shape == hdf5_tod.shape
+                assert result.__getattribute__(tod_fields[0]).shape == hdf5_tod.shape
                 result.__setattr__(cur_field_name, hdf5_tod.astype(tod_dtype)[:])

         # If we arrive here, we must have read at least one TOD
@@ -565,8 +565,8 @@ def read_one_observation(
         if read_local_flags_if_present:
             flags = __find_flags(
                 inpf,
-                expected_num_of_dets=result.tod.shape[0],
-                expected_num_of_samples=result.tod.shape[1],
+                expected_num_of_dets=result.__getattribute__(tod_fields[0]).shape[0],
+                expected_num_of_samples=result.__getattribute__(tod_fields[0]).shape[1],
             )

I've tried with this modification and the code works. I can take care of the fix, I already created a local branch and I'm ready to commit in a PR:) What do you think?

ziotom78 commented 1 year ago

Hi Marco, thanks for having spotted this. No problems from my side, go on!

marcobortolami commented 1 year ago

262 solved this Issue.