Skip to content

Commit

Permalink
Merge pull request #436 from lsst/tickets/SP-1791
Browse files Browse the repository at this point in the history
SP-1791: update some stats to make analyzing scheduler_note values easier
  • Loading branch information
yoachim authored Dec 19, 2024
2 parents e5f36e6 + 29be6ae commit f881cfa
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions rubin_sim/maf/batches/col_map_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def col_map_dict(dict_name=None):
]
col_map["metadataAngleList"] = ["rotSkyPos"]
col_map["scheduler_note"] = "scheduler_note"
col_map["scheduler_note_root"] = "scheduler_note_root"

elif dict_name == "opsimv4":
col_map = {}
Expand Down
1 change: 1 addition & 0 deletions rubin_sim/maf/batches/ddf_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def ddfBatch(
info_label=" ".join([fieldname]),
summary_metrics=lightcurve_summary(),
display_dict=displayDict,
plot_funcs=[],
)
)

Expand Down
25 changes: 22 additions & 3 deletions rubin_sim/maf/batches/glance_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,35 @@ def glanceBatch(

# stats from the scheduler_note column
if "scheduler_note" in colmap.keys():
displayDict = {"group": "Basic Stats", "subgroup": "Percent stats"}
displayDict = {"group": "Basic Stats", "subgroup": "Percent root stats"}
metric = metrics.StringCountMetric(
col=colmap["scheduler_note"], percent=True, metric_name="Percents", clip_end=True
col=colmap["scheduler_note_root"], percent=True, metric_name="Percents", clip_end=False
)
sql = ""
slicer = slicers.UniSlicer()
bundle = metric_bundles.MetricBundle(metric, slicer, sql, display_dict=displayDict)
bundle_list.append(bundle)
displayDict["subgroup"] = "Count root Stats"
metric = metrics.StringCountMetric(
col=colmap["scheduler_note_root"], metric_name="Counts", clip_end=False
)
bundle = metric_bundles.MetricBundle(metric, slicer, sql, display_dict=displayDict)
bundle_list.append(bundle)

# For pairs and twilights
if "scheduler_note" in colmap.keys():
displayDict = {"group": "Basic Stats", "subgroup": "Percent stats"}
metric = metrics.StringCountMetric(
col=colmap["scheduler_note"], percent=True, metric_name="Percents", clip_end=False
)
sql = (
"scheduler_note like 'pair%%' or scheduler_note like 'twilight%%' or scheduler_note like 'blob%%'"
)
slicer = slicers.UniSlicer()
bundle = metric_bundles.MetricBundle(metric, slicer, sql, display_dict=displayDict)
bundle_list.append(bundle)
displayDict["subgroup"] = "Count Stats"
metric = metrics.StringCountMetric(col=colmap["scheduler_note"], metric_name="Counts", clip_end=True)
metric = metrics.StringCountMetric(col=colmap["scheduler_note"], metric_name="Counts", clip_end=False)
bundle = metric_bundles.MetricBundle(metric, slicer, sql, display_dict=displayDict)
bundle_list.append(bundle)

Expand Down
20 changes: 20 additions & 0 deletions rubin_sim/maf/stackers/general_stackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ def _run(self, sim_data, cols_present=False):
return sim_data


class NoteRootStacker(BaseStacker):
"""Strip off things after a comma in the scheduler_note"""

cols_added = ["scheduler_note_root"]

def __init__(self, note_col="scheduler_note"):
self.units = ["mag"]
self.cols_req = [note_col]
self.note_col = note_col
self.cols_added_dtypes = ["<U50"]

def _run(self, sim_data, cols_present=False):
if cols_present:
# Column already present in data; assume it is fine.
return sim_data
new_note = [note.split(",")[0] for note in sim_data[self.note_col]]
sim_data["scheduler_note_root"] = new_note
return sim_data


class FiveSigmaStacker(BaseStacker):
"""Calculate the 5-sigma limiting depth for a point source in the given
conditions.
Expand Down

0 comments on commit f881cfa

Please sign in to comment.