diff --git a/sotodlib/io/datapkg_completion.py b/sotodlib/io/datapkg_completion.py index 8d2c27ec6..39f3010cc 100644 --- a/sotodlib/io/datapkg_completion.py +++ b/sotodlib/io/datapkg_completion.py @@ -111,18 +111,17 @@ def get_suprsync_files(self, timecode): return [] stc = os.path.join(self.SMURF.meta_path, str(timecode)) ttc = os.path.join(self.SMURF.archive_path, str(timecode)) + htc = os.path.join(self.HK.hkarchive_path, str(timecode)) flist = [] - if not os.path.exists(stc) and not os.path.exists(ttc): - return flist - if os.path.exists(ttc) and 'suprsync' in os.listdir(ttc): - for root, _, files in os.walk(os.path.join(ttc, 'suprsync')): - for name in files: - flist.append(os.path.join(ttc, root, name)) - if os.path.exists(stc) and 'suprsync' in os.listdir(stc): - for root, _, files in os.walk(os.path.join(stc, 'suprsync')): - for name in files: - flist.append(os.path.join(stc, root, name)) + for tc_root in [stc, ttc, htc]: + if os.path.exists(tc_root) and 'suprsync' in os.listdir(tc_root): + for root, _, files in os.walk( + os.path.join(tc_root, 'suprsync') + ): + for name in files: + flist.append(os.path.join(tc_root, root, name)) + return flist def check_hk_registered(self, timecode, complete): @@ -752,11 +751,10 @@ def cleanup_level2_folders(self, timecode): return stc = os.path.join(self.SMURF.meta_path, str(timecode)) ttc = os.path.join(self.SMURF.archive_path, str(timecode)) - - if os.path.exists(stc): - if len(os.listdir(stc)) == 0 or just_suprsync(stc): - shutil.rmtree(stc) - if os.path.exists(ttc): - if len(os.listdir(ttc)) == 0 or just_suprsync(ttc): - shutil.rmtree(ttc) + htc = os.path.join(self.HK.hkarchive_path, str(timecode)) + + for tc_root in [stc, ttc, htc]: + if os.path.exists(tc_root): + if len(os.listdir(tc_root)) == 0 or just_suprsync(tc_root): + shutil.rmtree(tc_root) return diff --git a/sotodlib/io/imprinter_cli.py b/sotodlib/io/imprinter_cli.py index 5a2b6c9d8..e020c4218 100644 --- a/sotodlib/io/imprinter_cli.py +++ b/sotodlib/io/imprinter_cli.py @@ -20,7 +20,10 @@ from typing import Optional import sotodlib.io.bookbinder as bbinder -from sotodlib.io.imprinter import Imprinter, Books, FAILED +from sotodlib.io.imprinter import ( + Imprinter, Books, + FAILED, BOUND +) import sotodlib.io.imprinter_utils as utils def fix_single_book(imprint:Imprinter, book:Books): @@ -347,7 +350,9 @@ def fix_book(self): if np.all([x<=self.max_drops_to_fix for x in self.dropped.values()]): utils.set_book_rebind(self.imprint, self.book) self.imprint.bind_book(self.book, allow_bad_timing=True,) - + if self.book.status == BOUND: + return ## simple fix complete + ## if any observations are over the limit, double check it's not a ## SMURF database error dropped_oids = [k for k,x in self.dropped.items() @@ -384,7 +389,7 @@ def fix_book(self): for oid in remove_oid: self.book = utils.remove_level2_obs_from_book( self.imprint, self.book, oid - ) + ) def report_error(self): msg = f"{self.book.bid} has dropped time samples\n" @@ -398,6 +403,10 @@ def report_error(self): class NonMonotonicAncillaryTimes(BookError): fields_to_fix = { "acu.acu_status.Azimuth_mode": 5, + "acu.acu_udp_stream.Corrected_Azimuth": 5, + "acu.acu_udp_stream.Corrected_Elevation": 5, + "acu.acu_udp_stream.Corrected_Boresight": 5, + "acu.acu_status.Corotator_current_position": 5, } n_samps = None field_dropped = None