Skip to content

Add support for ISO schedule #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions src/schedlib/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,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:
Expand All @@ -412,14 +412,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
Expand All @@ -435,35 +435,23 @@ 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']),
t1=u.str2datetime(row['stop_utc']),
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
Expand Down
4 changes: 3 additions & 1 deletion src/schedlib/policies/lat.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,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:
Expand Down