Skip to content

Commit

Permalink
Merge pull request #360 from lsst/tickets/OPSIM-1050
Browse files Browse the repository at this point in the history
  • Loading branch information
rhiannonlynne authored Sep 19, 2023
2 parents cc03dbe + 8f7a2eb commit 6eb5518
Show file tree
Hide file tree
Showing 20 changed files with 601 additions and 447 deletions.
1 change: 0 additions & 1 deletion rubin_sim/maf/batches/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"microlensing_summary",
)

import inspect

import rubin_sim.maf.metrics as metrics

Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/batches/glance_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def glanceBatch(
for filtername in filternames:
sql = "filter='%s' and night < 365" % filtername
metric = metrics.CountMetric(col="night", metric_name="N year 1")
summary_stat = metrics.FootprintFraction(
summary_stat = metrics.FootprintFractionMetric(
footprint=footprints_hp_array[filtername],
n_min=3,
)
Expand All @@ -499,7 +499,7 @@ def glanceBatch(

# Add basic slew stats.
try:
slewDict = slewBasics(colmap=colmap, runName=run_name)
slewDict = slewBasics(colmap=colmap, run_name=run_name)
bd.update(slewDict)
except KeyError as e:
warnings.warn("Could not add slew stats: missing required key %s from colmap" % (e))
Expand Down
32 changes: 16 additions & 16 deletions rubin_sim/maf/batches/moving_objects_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ def _setup_child_metrics(parentMetric):
def _configure_child_bundles(parentBundle):
dispDict = {
"group": f"{objtype}",
"subgroup": f"Completeness Over Time",
"subgroup": "Completeness Over Time",
"caption": "Time of discovery of objects",
"order": 0,
}
parentBundle.child_bundles["Time"].set_display_dict(dispDict)
dispDict = {
"group": f"{objtype}",
"subgroup": f"N Chances",
"subgroup": "N Chances",
"caption": "Number of chances for discovery of objects",
"order": 0,
}
Expand Down Expand Up @@ -326,14 +326,14 @@ def _setup_child_metrics(parentMetric):
def _configure_child_bundles(parentBundle):
dispDict = {
"group": f"{objtype}",
"subgroup": f"Completeness Over Time",
"subgroup": "Completeness Over Time",
"caption": "Time of discovery of objects",
"order": 0,
}
parentBundle.child_bundles["Time"].set_display_dict(dispDict)
dispDict = {
"group": f"{objtype}",
"subgroup": f"N Chances",
"subgroup": "N Chances",
"caption": "Number of chances for discovery of objects",
"order": 0,
}
Expand Down Expand Up @@ -734,7 +734,7 @@ def _compbundles(b, bundle, h_mark, results_db):
# Write the completeness bundles to disk, so we can re-read them later.
# (also set the display dict properties, for the results_db output).
for b, bundle in completeness.items():
bundle.display_dict["subgroup"] = f"Completeness"
bundle.display_dict["subgroup"] = "Completeness"
bundle.write(out_dir=out_dir, results_db=results_db)

# Calculate total number of objects - currently for NEOs and PHAs only
Expand Down Expand Up @@ -825,7 +825,7 @@ def _codePlot(key):
plt.grid(True, alpha=0.3)
# Make a PlotHandler to deal with savings/results_db, etc.
ph = plots.PlotHandler(fig_format=fig_format, results_db=results_db, out_dir=out_dir)
display_dict["subgroup"] = f"Completeness over time"
display_dict["subgroup"] = "Completeness over time"
display_dict["caption"] = "Completeness over time, for H values indicated in legend."
ph.save_fig(
fig.number,
Expand Down Expand Up @@ -881,7 +881,7 @@ def _codePlot(key):
"legendloc": (1.01, 0.1),
"color": None,
}
display_dict["subgroup"] = f"Completeness all criteria"
display_dict["subgroup"] = "Completeness all criteria"
display_dict["caption"] = "Plotting all of the cumulative completeness curves together."
ph.plot(
plot_func=plots.MetricVsH(),
Expand Down Expand Up @@ -949,7 +949,7 @@ def characterization_inner_batch(

# Number of observations.
md = info_label
display_dict["subgroup"] = f"N Obs"
display_dict["subgroup"] = "N Obs"
plotDict = {
"ylabel": "Number of observations (#)",
"title": "%s: Number of observations %s" % (run_name, md),
Expand All @@ -971,7 +971,7 @@ def characterization_inner_batch(

# Observational arc.
md = info_label
display_dict["subgroup"] = f"Obs Arc"
display_dict["subgroup"] = "Obs Arc"
plotDict = {
"ylabel": "Observational Arc (days)",
"title": "%s: Observational Arc Length %s" % (run_name, md),
Expand All @@ -992,7 +992,7 @@ def characterization_inner_batch(
bundleList.append(bundle)

# Activity detection.
display_dict["subgroup"] = f"Activity"
display_dict["subgroup"] = "Activity"
for w in windows:
md = info_label + " activity lasting %.0f days" % w
plotDict = {
Expand Down Expand Up @@ -1037,7 +1037,7 @@ def characterization_inner_batch(

# Lightcurve inversion.
md = info_label
display_dict["subgroup"] = f"Color/Inversion"
display_dict["subgroup"] = "Color/Inversion"
plotDict = {
"y_min": 0,
"y_max": 1,
Expand Down Expand Up @@ -1146,7 +1146,7 @@ def characterization_outer_batch(

# Number of observations.
md = info_label
display_dict["subgroup"] = f"N Obs"
display_dict["subgroup"] = "N Obs"
plotDict = {
"ylabel": "Number of observations (#)",
"title": "%s: Number of observations %s" % (run_name, md),
Expand All @@ -1168,7 +1168,7 @@ def characterization_outer_batch(

# Observational arc.
md = info_label
display_dict["subgroup"] = f"Obs Arc"
display_dict["subgroup"] = "Obs Arc"
plotDict = {
"ylabel": "Observational Arc (days)",
"title": "%s: Observational Arc Length %s" % (run_name, md),
Expand All @@ -1189,7 +1189,7 @@ def characterization_outer_batch(
bundleList.append(bundle)

# Activity detection.
display_dict["subgroup"] = f"Activity"
display_dict["subgroup"] = "Activity"
for w in windows:
md = info_label + " activity lasting %.0f days" % w
plotDict = {
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def characterization_outer_batch(

# Color determination.
md = info_label
display_dict["subgroup"] = f"Color/Inversion"
display_dict["subgroup"] = "Color/Inversion"
plotDict = {
"y_min": 0,
"y_max": 1,
Expand Down Expand Up @@ -1375,7 +1375,7 @@ def plot_fractions(
if figroot is None:
figroot = run_name
display_dict = deepcopy(first.display_dict)
display_dict["subgroup"] = f"Characterization Fraction"
display_dict["subgroup"] = "Characterization Fraction"

ph = plots.PlotHandler(fig_format=fig_format, results_db=results_db, out_dir=out_dir)
ph.set_metric_bundles(bdictFractions)
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/batches/radar_limited.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ def radar_limited(
subgroupCount += 1
displayDict["subgroup"] = f"{subgroupCount}: WL"
displayDict["order"] = 0
sqlconstraint = f'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
info_label = f"gri band non-DD"
sqlconstraint = 'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
info_label = "gri band non-DD"
minExpTime = 15
m = metrics.WeakLensingNvisits(
lsst_filter=bandpass,
Expand Down
22 changes: 11 additions & 11 deletions rubin_sim/maf/batches/science_radar_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def science_radar_batch(
plotDict = {"n_ticks": 5}
# Have to include all filters in query, so that we check for all-band coverage.
# Galaxy numbers calculated using 'bandpass' images only though.
sqlconstraint = f'note not like "DD%"'
sqlconstraint = 'note not like "DD%"'
info_label = f"{bandpass} band galaxies non-DD"
metric = maf.DepthLimitedNumGalMetric(
nside=nside,
Expand Down Expand Up @@ -628,8 +628,8 @@ def science_radar_batch(
subgroupCount += 1
displayDict["subgroup"] = f"{subgroupCount}: WL"
displayDict["order"] = 0
sqlconstraint = f'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
info_label = f"gri band non-DD"
sqlconstraint = 'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
info_label = "gri band non-DD"
minExpTime = 15
m = metrics.WeakLensingNvisits(
lsst_filter=bandpass,
Expand Down Expand Up @@ -1457,9 +1457,9 @@ def science_radar_batch(
plotDict = {"color_min": 0, "color_max": 1500, "x_min": 0, "x_max": 2000}
displayDict["order"] = 0
displayDict["caption"] = (
f"Evaluate the distribution of filter pairs and time gaps at each point in "
f"the sky. The time gaps are evaluated on a logarithmic spacing "
f"from 0-100 days for pairs of filters, and 0-3650 days for same filters."
"Evaluate the distribution of filter pairs and time gaps at each point in "
"the sky. The time gaps are evaluated on a logarithmic spacing "
"from 0-100 days for pairs of filters, and 0-3650 days for same filters."
)
summarystats = [
metrics.MedianMetric(),
Expand Down Expand Up @@ -1881,8 +1881,8 @@ def science_radar_batch(
# galaxy counting uses dustmap
slicer = slicers.HealpixSlicer(nside=nside, use_cache=False)
displayDict["caption"] = (
f"Approximate number of resolvable galaxies in i band, scaled by the "
f"coadded depth and median seeing. A dust and magnitude cut has been applied."
"Approximate number of resolvable galaxies in i band, scaled by the "
"coadded depth and median seeing. A dust and magnitude cut has been applied."
)
bundle = mb.MetricBundle(
metric,
Expand All @@ -1901,9 +1901,9 @@ def science_radar_batch(
# NlcPoints metric uses star density maps
slicer = slicers.HealpixSlicer(nside=nside, use_cache=False)
displayDict["caption"] = (
f"Approximate number of expected stellar measurements (nstars * nobs) "
f"in all filters, where the limiting magnitude for at least 10 visits "
f"is fainter than 21st magnitude, using a TRILEGAL stellar density map."
"Approximate number of expected stellar measurements (nstars * nobs) "
"in all filters, where the limiting magnitude for at least 10 visits "
"is fainter than 21st magnitude, using a TRILEGAL stellar density map."
)
bundle = mb.MetricBundle(
metric,
Expand Down
20 changes: 10 additions & 10 deletions rubin_sim/maf/batches/slew_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .common import standard_metrics


def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
def slewBasics(colmap=None, run_name="opsim", sql_constraint=None):
"""Generate a simple set of statistics about the slew times and distances.
These slew statistics can be run on the summary or default tables.
Expand All @@ -39,8 +39,8 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
slicer = slicers.UniSlicer()

info_label = "All visits"
if sqlConstraint is not None and len(sqlConstraint) > 0:
info_label = "%s" % (sqlConstraint)
if sql_constraint is not None and len(sql_constraint) > 0:
info_label = "%s" % (sql_constraint)
displayDict = {
"group": "Slew",
"subgroup": "Slew Basics",
Expand All @@ -51,15 +51,15 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
metric = metrics.CountMetric(colmap["slewtime"], metric_name="Slew Count")
displayDict["caption"] = "Total number of slews recorded in summary table."
displayDict["order"] += 1
bundle = mb.MetricBundle(metric, slicer, sqlConstraint, info_label=info_label, display_dict=displayDict)
bundle = mb.MetricBundle(metric, slicer, sql_constraint, info_label=info_label, display_dict=displayDict)
bundleList.append(bundle)
for metric in standard_metrics(colmap["slewtime"]):
displayDict["caption"] = "%s in seconds." % (metric.name)
displayDict["order"] += 1
bundle = mb.MetricBundle(
metric,
slicer,
sqlConstraint,
sql_constraint,
info_label=info_label,
display_dict=displayDict,
)
Expand All @@ -75,7 +75,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
bundle = mb.MetricBundle(
metric,
slicer,
sqlConstraint,
sql_constraint,
info_label=info_label,
plot_dict=plotDict,
display_dict=displayDict,
Expand All @@ -91,7 +91,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
bundle = mb.MetricBundle(
metric,
slicer,
sqlConstraint,
sql_constraint,
info_label=info_label,
plot_dict=plotDict,
display_dict=displayDict,
Expand All @@ -111,7 +111,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
bundle = mb.MetricBundle(
metric,
slicer,
sqlConstraint,
sql_constraint,
info_label=info_label,
plot_dict=plotDict,
display_dict=displayDict,
Expand All @@ -134,7 +134,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
bundle = mb.MetricBundle(
metric,
slicer,
sqlConstraint,
sql_constraint,
info_label=info_label,
plot_dict=plotDict,
display_dict=displayDict,
Expand All @@ -143,5 +143,5 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):

# Set the run_name for all bundles and return the bundleDict.
for b in bundleList:
b.set_run_name(runName)
b.set_run_name(run_name)
return mb.make_bundles_dict_from_list(bundleList)
56 changes: 55 additions & 1 deletion rubin_sim/maf/batches/srd_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def astrometryBatch(
"caption": None,
}
# Expected error on parallax at 10 AU.
plotmaxVals = (2.0, 15.0)
plotmaxVals = (5.0, 18.0)
good_parallax_limit = 11.5
summary = [
metrics.AreaSummaryMetric(
Expand Down Expand Up @@ -342,6 +342,60 @@ def astrometryBatch(
bundleList.append(bundle)
displayDict["order"] += 1

# Evaluate y-band-only parallax uncertainty
# Approximate "10sigma sources" as y=21.33
ymag = 21.33
if info_label == "All visits":
yinfo = "y band visits"
else:
yinfo = f"{info_label} y band only"
if len(sql) == 0:
ysql = "filter == 'y'"
else:
ysql = f"{sql} and filter == 'y'"
plotDict = {"x_min": 0, "x_max": 15, "color_min": 0, "color_max": 15}
metric = metrics.ParallaxMetric(
metric_name="Parallax Uncert @ %.1f" % (ymag),
rmag=ymag,
seeing_col=colmap["seeingGeom"],
filter_col=colmap["filter"],
m5_col=colmap["fiveSigmaDepth"],
normalize=False,
)
bundle = mb.MetricBundle(
metric,
slicer,
ysql,
info_label=yinfo,
stacker_list=[parallaxStacker],
display_dict=displayDict,
plot_dict=plotDict,
summary_metrics=summary,
plot_funcs=subsetPlots,
)
bundleList.append(bundle)
displayDict["order"] += 1
metric = metrics.ParallaxMetric(
metric_name="Normalized Parallax Uncert @ %.1f" % (ymag),
rmag=ymag,
seeing_col=colmap["seeingGeom"],
filter_col=colmap["filter"],
m5_col=colmap["fiveSigmaDepth"],
normalize=True,
)
bundle = mb.MetricBundle(
metric,
slicer,
ysql,
info_label=yinfo,
stacker_list=[parallaxStacker],
display_dict=displayDict,
summary_metrics=summary,
plot_funcs=subsetPlots,
)
bundleList.append(bundle)
displayDict["order"] += 1

# Proper Motion metrics.
displayDict = {
"group": "SRD Proper Motion",
Expand Down
Loading

0 comments on commit 6eb5518

Please sign in to comment.