Skip to content

Commit

Permalink
Merge pull request #239 from macro-consortium/peg-dev
Browse files Browse the repository at this point in the history
Sky plot updates
  • Loading branch information
WWGolay authored Jul 1, 2024
2 parents fcf651d + 5e85f03 commit a379a3a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,4 @@ dmypy.json
docs/source/api/auto_api/
docs/source/_build/
pgHardware
pgtest
6 changes: 3 additions & 3 deletions pyscope/telrun/schedtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,12 @@ def validate(schedule_table, observatory=None):
# f"Column '{column.name}' must be of type int64, not {column.dtype}"
# )
case "exposure" | "pm_ra_cosdec" | "pm_dec":
if not np.issubdtype(column.dtype, np.dtype("float64")):
if not np.issubdtype(column.dtype, np.floating):
logger.error(
f"Column '{column.name}' must be of type float64, not {column.dtype}"
f"Column '{column.name}' must be of a float type, not {column.dtype}"
)
raise ValueError(
f"Column '{column.name}' must be of type float64, not {column.dtype}"
f"Column '{column.name}' must be of a float type, not {column.dtype}"
)
case "shutter_state":
if column.dtype != bool:
Expand Down
55 changes: 45 additions & 10 deletions pyscope/telrun/schedtel.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,14 @@ def schedtel_cli(
queue_table = schedtab.blocks_to_table(queue_blocks)

exec_blocks = exec_blocks + unscheduled_slots
for block in exec_blocks:
try:
# print(block.configuration["ID"], type(block.configuration["ID"]))
my_id = block.configuration["ID"].mjd
# print(my_id, type(my_id))
block.configuration["ID"] = my_id
except:
pass
exec_table = schedtab.blocks_to_table(exec_blocks)

# Write the schedule to file
Expand Down Expand Up @@ -1119,24 +1127,51 @@ def plot_schedule_sky_cli(schedule_table, observatory):
)
return

fig, ax = plt.subplots(1, 1, figsize=(7, 7), subplot_kw={"projection": "polar"})
for i, row in enumerate(schedule_table):
# Get unique targets in the schedule
target_times = {}

for row in schedule_table:
if row["name"] == "TransitionBlock" or row["name"] == "EmptyBlock":
continue
target_string = row["target"].to_string("hmsdms")
target_name = row["name"]
if target_string not in target_times:
target_times[target_string] = {
"name": target_name,
"times": [row["start_time"]],
}
else:
target_times[target_string]["times"].append(row["start_time"])

# targets = [t.to_string("hmsdms") for t in schedule_table["target"]]

fig, ax = plt.subplots(1, 1, figsize=(7, 7), subplot_kw={"projection": "polar"})
for target, target_dict in target_times.items():
times = target_dict["times"]
try:
label = target_dict["name"]
except:
label = target.to_string("hmsdms")
target = coord.SkyCoord(target, unit=(u.hourangle, u.deg))
ax = astroplan_plots.plot_sky(
astroplan.FixedTarget(row["target"]),
astroplan.FixedTarget(target),
observatory,
times,
astrotime.Time(np.float64(row["start_time"].jd), format="jd"),
ax=ax,
style_kwargs={
"label": row["target"].to_string("hmsdms"),
},
style_kwargs={"label": label},
)

handles, labels = ax.get_legend_handles_labels()
unique = [
(h, l) for i, (h, l) in enumerate(zip(handles, labels)) if l not in labels[:i]
]
ax.legend(*zip(*unique), loc=(1.1, 0))

# Commented out - if objects have same name, they will be combined in the legend
# print(labels)
# unique = [
# (h, l) for i, (h, l) in enumerate(zip(handles, labels)) if l not in labels[:i]
# ]
# ax.legend(*zip(*unique), loc=(1.1, 0))

ax.legend(labels, loc=(1.1, 0))

fig.set_facecolor("white")
fig.set_dpi(300)
Expand Down

0 comments on commit a379a3a

Please sign in to comment.