Skip to content

Commit 6eb5518

Browse files
Merge pull request #360 from lsst/tickets/OPSIM-1050
2 parents cc03dbe + 8f7a2eb commit 6eb5518

20 files changed

+601
-447
lines changed

rubin_sim/maf/batches/common.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"microlensing_summary",
1414
)
1515

16-
import inspect
1716

1817
import rubin_sim.maf.metrics as metrics
1918

rubin_sim/maf/batches/glance_batch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def glanceBatch(
473473
for filtername in filternames:
474474
sql = "filter='%s' and night < 365" % filtername
475475
metric = metrics.CountMetric(col="night", metric_name="N year 1")
476-
summary_stat = metrics.FootprintFraction(
476+
summary_stat = metrics.FootprintFractionMetric(
477477
footprint=footprints_hp_array[filtername],
478478
n_min=3,
479479
)
@@ -499,7 +499,7 @@ def glanceBatch(
499499

500500
# Add basic slew stats.
501501
try:
502-
slewDict = slewBasics(colmap=colmap, runName=run_name)
502+
slewDict = slewBasics(colmap=colmap, run_name=run_name)
503503
bd.update(slewDict)
504504
except KeyError as e:
505505
warnings.warn("Could not add slew stats: missing required key %s from colmap" % (e))

rubin_sim/maf/batches/moving_objects_batch.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ def _setup_child_metrics(parentMetric):
183183
def _configure_child_bundles(parentBundle):
184184
dispDict = {
185185
"group": f"{objtype}",
186-
"subgroup": f"Completeness Over Time",
186+
"subgroup": "Completeness Over Time",
187187
"caption": "Time of discovery of objects",
188188
"order": 0,
189189
}
190190
parentBundle.child_bundles["Time"].set_display_dict(dispDict)
191191
dispDict = {
192192
"group": f"{objtype}",
193-
"subgroup": f"N Chances",
193+
"subgroup": "N Chances",
194194
"caption": "Number of chances for discovery of objects",
195195
"order": 0,
196196
}
@@ -326,14 +326,14 @@ def _setup_child_metrics(parentMetric):
326326
def _configure_child_bundles(parentBundle):
327327
dispDict = {
328328
"group": f"{objtype}",
329-
"subgroup": f"Completeness Over Time",
329+
"subgroup": "Completeness Over Time",
330330
"caption": "Time of discovery of objects",
331331
"order": 0,
332332
}
333333
parentBundle.child_bundles["Time"].set_display_dict(dispDict)
334334
dispDict = {
335335
"group": f"{objtype}",
336-
"subgroup": f"N Chances",
336+
"subgroup": "N Chances",
337337
"caption": "Number of chances for discovery of objects",
338338
"order": 0,
339339
}
@@ -734,7 +734,7 @@ def _compbundles(b, bundle, h_mark, results_db):
734734
# Write the completeness bundles to disk, so we can re-read them later.
735735
# (also set the display dict properties, for the results_db output).
736736
for b, bundle in completeness.items():
737-
bundle.display_dict["subgroup"] = f"Completeness"
737+
bundle.display_dict["subgroup"] = "Completeness"
738738
bundle.write(out_dir=out_dir, results_db=results_db)
739739

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

950950
# Number of observations.
951951
md = info_label
952-
display_dict["subgroup"] = f"N Obs"
952+
display_dict["subgroup"] = "N Obs"
953953
plotDict = {
954954
"ylabel": "Number of observations (#)",
955955
"title": "%s: Number of observations %s" % (run_name, md),
@@ -971,7 +971,7 @@ def characterization_inner_batch(
971971

972972
# Observational arc.
973973
md = info_label
974-
display_dict["subgroup"] = f"Obs Arc"
974+
display_dict["subgroup"] = "Obs Arc"
975975
plotDict = {
976976
"ylabel": "Observational Arc (days)",
977977
"title": "%s: Observational Arc Length %s" % (run_name, md),
@@ -992,7 +992,7 @@ def characterization_inner_batch(
992992
bundleList.append(bundle)
993993

994994
# Activity detection.
995-
display_dict["subgroup"] = f"Activity"
995+
display_dict["subgroup"] = "Activity"
996996
for w in windows:
997997
md = info_label + " activity lasting %.0f days" % w
998998
plotDict = {
@@ -1037,7 +1037,7 @@ def characterization_inner_batch(
10371037

10381038
# Lightcurve inversion.
10391039
md = info_label
1040-
display_dict["subgroup"] = f"Color/Inversion"
1040+
display_dict["subgroup"] = "Color/Inversion"
10411041
plotDict = {
10421042
"y_min": 0,
10431043
"y_max": 1,
@@ -1146,7 +1146,7 @@ def characterization_outer_batch(
11461146

11471147
# Number of observations.
11481148
md = info_label
1149-
display_dict["subgroup"] = f"N Obs"
1149+
display_dict["subgroup"] = "N Obs"
11501150
plotDict = {
11511151
"ylabel": "Number of observations (#)",
11521152
"title": "%s: Number of observations %s" % (run_name, md),
@@ -1168,7 +1168,7 @@ def characterization_outer_batch(
11681168

11691169
# Observational arc.
11701170
md = info_label
1171-
display_dict["subgroup"] = f"Obs Arc"
1171+
display_dict["subgroup"] = "Obs Arc"
11721172
plotDict = {
11731173
"ylabel": "Observational Arc (days)",
11741174
"title": "%s: Observational Arc Length %s" % (run_name, md),
@@ -1189,7 +1189,7 @@ def characterization_outer_batch(
11891189
bundleList.append(bundle)
11901190

11911191
# Activity detection.
1192-
display_dict["subgroup"] = f"Activity"
1192+
display_dict["subgroup"] = "Activity"
11931193
for w in windows:
11941194
md = info_label + " activity lasting %.0f days" % w
11951195
plotDict = {
@@ -1234,7 +1234,7 @@ def characterization_outer_batch(
12341234

12351235
# Color determination.
12361236
md = info_label
1237-
display_dict["subgroup"] = f"Color/Inversion"
1237+
display_dict["subgroup"] = "Color/Inversion"
12381238
plotDict = {
12391239
"y_min": 0,
12401240
"y_max": 1,
@@ -1375,7 +1375,7 @@ def plot_fractions(
13751375
if figroot is None:
13761376
figroot = run_name
13771377
display_dict = deepcopy(first.display_dict)
1378-
display_dict["subgroup"] = f"Characterization Fraction"
1378+
display_dict["subgroup"] = "Characterization Fraction"
13791379

13801380
ph = plots.PlotHandler(fig_format=fig_format, results_db=results_db, out_dir=out_dir)
13811381
ph.set_metric_bundles(bdictFractions)

rubin_sim/maf/batches/radar_limited.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ def radar_limited(
568568
subgroupCount += 1
569569
displayDict["subgroup"] = f"{subgroupCount}: WL"
570570
displayDict["order"] = 0
571-
sqlconstraint = f'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
572-
info_label = f"gri band non-DD"
571+
sqlconstraint = 'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
572+
info_label = "gri band non-DD"
573573
minExpTime = 15
574574
m = metrics.WeakLensingNvisits(
575575
lsst_filter=bandpass,

rubin_sim/maf/batches/science_radar_batch.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def science_radar_batch(
589589
plotDict = {"n_ticks": 5}
590590
# Have to include all filters in query, so that we check for all-band coverage.
591591
# Galaxy numbers calculated using 'bandpass' images only though.
592-
sqlconstraint = f'note not like "DD%"'
592+
sqlconstraint = 'note not like "DD%"'
593593
info_label = f"{bandpass} band galaxies non-DD"
594594
metric = maf.DepthLimitedNumGalMetric(
595595
nside=nside,
@@ -628,8 +628,8 @@ def science_radar_batch(
628628
subgroupCount += 1
629629
displayDict["subgroup"] = f"{subgroupCount}: WL"
630630
displayDict["order"] = 0
631-
sqlconstraint = f'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
632-
info_label = f"gri band non-DD"
631+
sqlconstraint = 'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
632+
info_label = "gri band non-DD"
633633
minExpTime = 15
634634
m = metrics.WeakLensingNvisits(
635635
lsst_filter=bandpass,
@@ -1457,9 +1457,9 @@ def science_radar_batch(
14571457
plotDict = {"color_min": 0, "color_max": 1500, "x_min": 0, "x_max": 2000}
14581458
displayDict["order"] = 0
14591459
displayDict["caption"] = (
1460-
f"Evaluate the distribution of filter pairs and time gaps at each point in "
1461-
f"the sky. The time gaps are evaluated on a logarithmic spacing "
1462-
f"from 0-100 days for pairs of filters, and 0-3650 days for same filters."
1460+
"Evaluate the distribution of filter pairs and time gaps at each point in "
1461+
"the sky. The time gaps are evaluated on a logarithmic spacing "
1462+
"from 0-100 days for pairs of filters, and 0-3650 days for same filters."
14631463
)
14641464
summarystats = [
14651465
metrics.MedianMetric(),
@@ -1881,8 +1881,8 @@ def science_radar_batch(
18811881
# galaxy counting uses dustmap
18821882
slicer = slicers.HealpixSlicer(nside=nside, use_cache=False)
18831883
displayDict["caption"] = (
1884-
f"Approximate number of resolvable galaxies in i band, scaled by the "
1885-
f"coadded depth and median seeing. A dust and magnitude cut has been applied."
1884+
"Approximate number of resolvable galaxies in i band, scaled by the "
1885+
"coadded depth and median seeing. A dust and magnitude cut has been applied."
18861886
)
18871887
bundle = mb.MetricBundle(
18881888
metric,
@@ -1901,9 +1901,9 @@ def science_radar_batch(
19011901
# NlcPoints metric uses star density maps
19021902
slicer = slicers.HealpixSlicer(nside=nside, use_cache=False)
19031903
displayDict["caption"] = (
1904-
f"Approximate number of expected stellar measurements (nstars * nobs) "
1905-
f"in all filters, where the limiting magnitude for at least 10 visits "
1906-
f"is fainter than 21st magnitude, using a TRILEGAL stellar density map."
1904+
"Approximate number of expected stellar measurements (nstars * nobs) "
1905+
"in all filters, where the limiting magnitude for at least 10 visits "
1906+
"is fainter than 21st magnitude, using a TRILEGAL stellar density map."
19071907
)
19081908
bundle = mb.MetricBundle(
19091909
metric,

rubin_sim/maf/batches/slew_batch.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .common import standard_metrics
1313

1414

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

4141
info_label = "All visits"
42-
if sqlConstraint is not None and len(sqlConstraint) > 0:
43-
info_label = "%s" % (sqlConstraint)
42+
if sql_constraint is not None and len(sql_constraint) > 0:
43+
info_label = "%s" % (sql_constraint)
4444
displayDict = {
4545
"group": "Slew",
4646
"subgroup": "Slew Basics",
@@ -51,15 +51,15 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
5151
metric = metrics.CountMetric(colmap["slewtime"], metric_name="Slew Count")
5252
displayDict["caption"] = "Total number of slews recorded in summary table."
5353
displayDict["order"] += 1
54-
bundle = mb.MetricBundle(metric, slicer, sqlConstraint, info_label=info_label, display_dict=displayDict)
54+
bundle = mb.MetricBundle(metric, slicer, sql_constraint, info_label=info_label, display_dict=displayDict)
5555
bundleList.append(bundle)
5656
for metric in standard_metrics(colmap["slewtime"]):
5757
displayDict["caption"] = "%s in seconds." % (metric.name)
5858
displayDict["order"] += 1
5959
bundle = mb.MetricBundle(
6060
metric,
6161
slicer,
62-
sqlConstraint,
62+
sql_constraint,
6363
info_label=info_label,
6464
display_dict=displayDict,
6565
)
@@ -75,7 +75,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
7575
bundle = mb.MetricBundle(
7676
metric,
7777
slicer,
78-
sqlConstraint,
78+
sql_constraint,
7979
info_label=info_label,
8080
plot_dict=plotDict,
8181
display_dict=displayDict,
@@ -91,7 +91,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
9191
bundle = mb.MetricBundle(
9292
metric,
9393
slicer,
94-
sqlConstraint,
94+
sql_constraint,
9595
info_label=info_label,
9696
plot_dict=plotDict,
9797
display_dict=displayDict,
@@ -111,7 +111,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
111111
bundle = mb.MetricBundle(
112112
metric,
113113
slicer,
114-
sqlConstraint,
114+
sql_constraint,
115115
info_label=info_label,
116116
plot_dict=plotDict,
117117
display_dict=displayDict,
@@ -134,7 +134,7 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
134134
bundle = mb.MetricBundle(
135135
metric,
136136
slicer,
137-
sqlConstraint,
137+
sql_constraint,
138138
info_label=info_label,
139139
plot_dict=plotDict,
140140
display_dict=displayDict,
@@ -143,5 +143,5 @@ def slewBasics(colmap=None, runName="opsim", sqlConstraint=None):
143143

144144
# Set the run_name for all bundles and return the bundleDict.
145145
for b in bundleList:
146-
b.set_run_name(runName)
146+
b.set_run_name(run_name)
147147
return mb.make_bundles_dict_from_list(bundleList)

rubin_sim/maf/batches/srd_batch.py

+55-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def astrometryBatch(
233233
"caption": None,
234234
}
235235
# Expected error on parallax at 10 AU.
236-
plotmaxVals = (2.0, 15.0)
236+
plotmaxVals = (5.0, 18.0)
237237
good_parallax_limit = 11.5
238238
summary = [
239239
metrics.AreaSummaryMetric(
@@ -342,6 +342,60 @@ def astrometryBatch(
342342
bundleList.append(bundle)
343343
displayDict["order"] += 1
344344

345+
# Evaluate y-band-only parallax uncertainty
346+
# Approximate "10sigma sources" as y=21.33
347+
ymag = 21.33
348+
if info_label == "All visits":
349+
yinfo = "y band visits"
350+
else:
351+
yinfo = f"{info_label} y band only"
352+
if len(sql) == 0:
353+
ysql = "filter == 'y'"
354+
else:
355+
ysql = f"{sql} and filter == 'y'"
356+
plotDict = {"x_min": 0, "x_max": 15, "color_min": 0, "color_max": 15}
357+
metric = metrics.ParallaxMetric(
358+
metric_name="Parallax Uncert @ %.1f" % (ymag),
359+
rmag=ymag,
360+
seeing_col=colmap["seeingGeom"],
361+
filter_col=colmap["filter"],
362+
m5_col=colmap["fiveSigmaDepth"],
363+
normalize=False,
364+
)
365+
bundle = mb.MetricBundle(
366+
metric,
367+
slicer,
368+
ysql,
369+
info_label=yinfo,
370+
stacker_list=[parallaxStacker],
371+
display_dict=displayDict,
372+
plot_dict=plotDict,
373+
summary_metrics=summary,
374+
plot_funcs=subsetPlots,
375+
)
376+
bundleList.append(bundle)
377+
displayDict["order"] += 1
378+
metric = metrics.ParallaxMetric(
379+
metric_name="Normalized Parallax Uncert @ %.1f" % (ymag),
380+
rmag=ymag,
381+
seeing_col=colmap["seeingGeom"],
382+
filter_col=colmap["filter"],
383+
m5_col=colmap["fiveSigmaDepth"],
384+
normalize=True,
385+
)
386+
bundle = mb.MetricBundle(
387+
metric,
388+
slicer,
389+
ysql,
390+
info_label=yinfo,
391+
stacker_list=[parallaxStacker],
392+
display_dict=displayDict,
393+
summary_metrics=summary,
394+
plot_funcs=subsetPlots,
395+
)
396+
bundleList.append(bundle)
397+
displayDict["order"] += 1
398+
345399
# Proper Motion metrics.
346400
displayDict = {
347401
"group": "SRD Proper Motion",

0 commit comments

Comments
 (0)