diff --git a/src/schedlib/instrument.py b/src/schedlib/instrument.py index e742f8d..5b6cf5d 100644 --- a/src/schedlib/instrument.py +++ b/src/schedlib/instrument.py @@ -450,7 +450,7 @@ def parse_sequence_from_toast_lat(ifile): """ columns = [ - "start_utc", "stop_utc", "target", "el", "az_min", "az_max", "uid" + "start_utc", "stop_utc", "target", "direction", "el", "az_min", "az_max", "uid" ] # count the number of lines to skip with open(ifile) as f: @@ -476,14 +476,14 @@ def parse_sequence_from_toast_lat(ifile): priority=1, #row['#'], tag=_escape_string( str(row['target']).strip()+","+ - "uid-"+str(row['uid']).strip() + "uid-"+str(int(row['uid'])).strip() ), ) blocks.append(block) return blocks def parse_cal_targets_from_toast_lat(ifile): - columns = ["start_utc", "stop_utc", "target", "el", + columns = ["start_utc", "stop_utc", "target", "direction", "el", "az_min", "az_max", "uid", ] # count the number of lines to skip @@ -499,26 +499,14 @@ def parse_cal_targets_from_toast_lat(ifile): for _, row in df.iterrows(): target_fields = _escape_string(row['target'].strip()).lower().split(';') - match = re.match(r"([a-zA-Z0-9]+)_([a-zA-Z0-9]+)", target_fields[1]) - tubes, wafers = match.groups() - tubes = re.findall(r"[a-zA-Z]\d+", tubes) + tubes = re.findall(r'[a-zA-Z]\d+', target_fields[1]) + suffix_map = { + 0: ['ws1', 'ws2', 'ws0'], + 1: ['ws0', 'ws1', 'ws2'] + } - array_query = "" - - suffixes = { - 'ws0': ['ws0'], - 'wsi': ['ws1', 'ws2'] - }.get(wafers, []) - - array_query = ",".join(f"{tube}_{suffix}" for tube in tubes for suffix in suffixes) - - azmean = np.mean( - np.unwrap([row['az_min'], row['az_max']], period=360) - ) % 360 - if azmean < 180: - direction = "rising" - else: - direction = "setting" + # Generate the full labels in order + array_query = ",".join(f"{tube}_{suffix}" for i, tube in enumerate(tubes) for suffix in suffix_map[i]) cal_target = CalTarget( t0=u.str2datetime(row['start_utc']), @@ -526,8 +514,8 @@ def parse_cal_targets_from_toast_lat(ifile): source=target_fields[0], el_bore=row['el'], boresight_rot=None, - tag=f"{str(array_query).strip()},{'uid-'+str(row['uid']).strip()}", - source_direction=direction,#_escape_string(row['direction'].strip()).lower(), + tag=f"{str(array_query).strip()},{'uid-'+str(int(row['uid'])).strip()}", + source_direction=_escape_string(row['direction'].strip()).lower(), array_query=array_query, allow_partial=False, from_table=True diff --git a/src/schedlib/policies/lat.py b/src/schedlib/policies/lat.py index 8ad2767..89727a9 100644 --- a/src/schedlib/policies/lat.py +++ b/src/schedlib/policies/lat.py @@ -656,7 +656,9 @@ def init_seqs(self, cfile: str, t0: dt.datetime, t1: dt.datetime) -> core.Blocks if self.corotator_override is None: corotator = boresight_to_corotator(cal_target.el_bore, 0) - boresight = corotator_to_boresight(cal_target.el_bore, float(corotator)) + boresight = corotator_to_boresight(cal_target.el_bore, corotator) + else: + boresight = corotator_to_boresight(cal_target.el_bore, float(self.corotator_override)) cal_targets[i] = replace(cal_targets[i], boresight_rot=boresight) if self.az_branch_override is not None: