Skip to content

Commit

Permalink
Update fO plot defaults, use 750 as min nvis for fO_area
Browse files Browse the repository at this point in the history
  • Loading branch information
rhiannonlynne committed Mar 5, 2024
1 parent a04ebf6 commit 095572a
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 78 deletions.
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 @@ -413,8 +413,8 @@ def glanceBatch(
metric = metrics.CountExplimMetric(metric_name="fO")
plotDict = {
"xlabel": "Number of Visits",
"Asky": benchmarkArea,
"Nvisit": minNvisits,
"asky": benchmarkArea,
"n_visits": minNvisits,
"x_min": 0,
"x_max": 1500,
}
Expand Down
6 changes: 3 additions & 3 deletions rubin_sim/maf/batches/info_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def info_bundle_dicts(allsky_slicer, wfd_slicer, opsim="opsim", colmap=batches.c
bdict = {}

for tag, slicer in zip(["All sky", "WFD"], [allsky_slicer, wfd_slicer]):
fO = batches.fOBatch(colmap=colmap, runName=opsim, slicer=slicer, extraInfoLabel=tag)
fO = batches.fOBatch(colmap=colmap, run_name=opsim, slicer=slicer, extra_info=tag)
bdict.update(fO)
astrometry = batches.astrometryBatch(colmap=colmap, runName=opsim, slicer=slicer, extraInfoLabel=tag)
astrometry = batches.astrometryBatch(colmap=colmap, run_name=opsim, slicer=slicer, extra_info=tag)
bdict.update(astrometry)
rapidrevisit = batches.rapidRevisitBatch(
colmap=colmap, runName=opsim, slicer=slicer, extraInfoLabel=tag
colmap=colmap, run_name=opsim, slicer=slicer, extra_info=tag
)
bdict.update(rapidrevisit)

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 @@ -80,8 +80,8 @@ def radar_limited(
metric = metrics.CountExplimMetric(col="observationStartMJD", metric_name="fO")
plotDict = {
"xlabel": "Number of Visits",
"Asky": benchmarkArea,
"Nvisit": benchmarkNvisits,
"asky": benchmarkArea,
"n_visits": benchmarkNvisits,
"x_min": 0,
"x_max": 1500,
}
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/batches/science_radar_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def science_radar_batch(
metric = metrics.CountExplimMetric(metric_name="fO")
plotDict = {
"xlabel": "Number of Visits",
"Asky": benchmarkArea,
"Nvisit": minNvisits,
"asky": benchmarkArea,
"n_visits": minNvisits,
"x_min": 0,
"x_max": 1500,
}
Expand Down
124 changes: 65 additions & 59 deletions rubin_sim/maf/batches/srd_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,36 @@

def fOBatch(
colmap=None,
runName="run_name",
extraSql=None,
extraInfoLabel=None,
run_name="run_name",
extra_sql=None,
extra_info=None,
slicer=None,
benchmarkArea=18000,
benchmarkn_visits=825,
minn_visits=750,
benchmark_area=18000,
benchmark_n_visits=825,
min_n_visits=750,
):
"""Metrics for calculating fO.
Parameters
----------
colmap : `dict` or None, optional
colmap : `dict` or None, opt
A dictionary with a mapping of column names.
runName : `str`, optional
run_name : `str`, opt
The name of the simulated survey.
extraSql : `str` or None, optional
extra_sql : `str` or None, opt
Additional sql constraint to apply to all metrics.
extraInfoLabel : `str` or None, optional
extra_Info : `str` or None, opt
Additional info_label to apply to all results.
slicer : `rubin_sim.maf.slicer.HealpixSlicer` or None, optional
slicer : `rubin_sim.maf.slicer.HealpixSlicer` or None, opt
This must be a HealpixSlicer or some kind,
although could be a HealpixSubsetSlicer.
None will default to HealpixSlicer with nside=64.
benchmark_area : `float`, opt
Area to use when calculating fO_Nvis, for design.
benchmark_n_visits : `float`, opt
Nvisits minimum to use when calculating fO_Area, for design.
min_n_visits : `float`, opt
Nvisits minimum to use when calculating fO_Area, for minimum.
Returns
-------
Expand All @@ -58,13 +64,13 @@ def fOBatch(
sql = ""
info_label = "All visits"
# Add additional sql constraint (such as wfdWhere) and info_label
if (extraSql is not None) and (len(extraSql) > 0):
sql = extraSql
if extraInfoLabel is None:
info_label = extraSql.replace("filter =", "").replace("filter=", "")
if (extra_sql is not None) and (len(extra_sql) > 0):
sql = extra_sql
if extra_info is None:
info_label = extra_sql.replace("filter =", "").replace("filter=", "")
info_label = info_label.replace('"', "").replace("'", "")
if extraInfoLabel is not None:
info_label = extraInfoLabel
if extra_info is not None:
info_label = extra_info

subgroup = info_label

Expand All @@ -89,8 +95,8 @@ def fOBatch(
metric = metrics.CountExplimMetric(metric_name="fO", exp_col=colmap["exptime"])
plotDict = {
"xlabel": "Number of Visits",
"asky": benchmarkArea,
"n_visit": minn_visits,
"asky": benchmark_area,
"n_visits": min_n_visits,
"x_min": 0,
"x_max": 1500,
}
Expand All @@ -99,46 +105,46 @@ def fOBatch(
nside=nside,
norm=False,
metric_name="fOArea",
asky=benchmarkArea,
n_visit=benchmarkn_visits,
asky=benchmark_area,
n_visit=benchmark_n_visits,
),
metrics.FOArea(
nside=nside,
norm=True,
metric_name="fOArea/benchmark",
asky=benchmarkArea,
n_visit=benchmarkn_visits,
asky=benchmark_area,
n_visit=benchmark_n_visits,
),
metrics.FONv(
nside=nside,
norm=False,
metric_name="fONv",
asky=benchmarkArea,
n_visit=benchmarkn_visits,
asky=benchmark_area,
n_visit=benchmark_n_visits,
),
metrics.FONv(
nside=nside,
norm=True,
metric_name="fONv/benchmark",
asky=benchmarkArea,
n_visit=benchmarkn_visits,
asky=benchmark_area,
n_visit=benchmark_n_visits,
),
metrics.FOArea(
nside=nside,
norm=False,
metric_name=f"fOArea_{minn_visits}",
asky=benchmarkArea,
n_visit=minn_visits,
metric_name=f"fOArea_{min_n_visits}",
asky=benchmark_area,
n_visit=min_n_visits,
),
]
caption = "The FO metric evaluates the overall efficiency of observing. "
caption += (
"foNv: out of %.2f sq degrees, the area receives at least X and a median of Y visits "
"(out of %d, if compared to benchmark). " % (benchmarkArea, benchmarkn_visits)
"(out of %d, if compared to benchmark). " % (benchmark_area, benchmark_n_visits)
)
caption += (
"fOArea: this many sq deg (out of %.2f sq deg if compared "
"to benchmark) receives at least %d visits. " % (benchmarkArea, benchmarkn_visits)
"to benchmark) receives at least %d visits. " % (benchmark_area, benchmark_n_visits)
)
displayDict["caption"] = caption
bundle = mb.MetricBundle(
Expand All @@ -154,15 +160,15 @@ def fOBatch(
bundleList.append(bundle)
# 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)


def astrometryBatch(
colmap=None,
runName="opsim",
extraSql=None,
extraInfoLabel=None,
run_name="opsim",
extra_sql=None,
extra_info=None,
slicer=None,
):
"""Metrics for evaluating proper motion and parallax.
Expand All @@ -171,11 +177,11 @@ def astrometryBatch(
----------
colmap : `dict` or None, optional
A dictionary with a mapping of column names.
runName : `str`, optional
run_name : `str`, optional
The name of the simulated survey.
extraSql : `str` or None, optional
extra_sql : `str` or None, optional
Additional sql constraint to apply to all metrics.
extraInfoLabel : `str` or None, optional
extra_info : `str` or None, optional
Additional info_label to apply to all results.
slicer : `rubin_sim.maf.slicer` or None, optional
Optionally, specify something other than an nside=64 healpix slicer.
Expand All @@ -191,13 +197,13 @@ def astrometryBatch(
sql = ""
info_label = "All visits"
# Add additional sql constraint (such as wfdWhere) and info_label
if (extraSql is not None) and (len(extraSql) > 0):
sql = extraSql
if extraInfoLabel is None:
info_label = extraSql.replace("filter =", "").replace("filter=", "")
if (extra_sql is not None) and (len(extra_sql) > 0):
sql = extra_sql
if extra_info is None:
info_label = extra_sql.replace("filter =", "").replace("filter=", "")
info_label = info_label.replace('"', "").replace("'", "")
if extraInfoLabel is not None:
info_label = extraInfoLabel
if extra_info is not None:
info_label = extra_info

subgroup = info_label

Expand Down Expand Up @@ -466,15 +472,15 @@ def astrometryBatch(

# 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)


def rapidRevisitBatch(
colmap=None,
runName="opsim",
extraSql=None,
extraInfoLabel=None,
run_name="opsim",
extra_sql=None,
extra_info=None,
slicer=None,
):
"""Metrics for evaluating proper motion and parallax.
Expand All @@ -483,11 +489,11 @@ def rapidRevisitBatch(
----------
colmap : `dict` or None, optional
A dictionary with a mapping of column names.
runName : `str`, optional
run_name : `str`, optional
The name of the simulated survey.
extraSql : `str` or None, optional
extra_sql : `str` or None, optional
Additional sql constraint to apply to all metrics.
extraInfoLabel : `str` or None, optional
extra_info : `str` or None, optional
Additional info_label to apply to all results.
slicer : `rubin_sim_maf.slicers.HealpixSlicer` or None, optional
Optionally, specify something other than an nside=64 healpix slicer.
Expand All @@ -504,13 +510,13 @@ def rapidRevisitBatch(
sql = ""
info_label = "All visits"
# Add additional sql constraint (such as wfdWhere) and info_label.
if (extraSql is not None) and (len(extraSql) > 0):
sql = extraSql
if extraInfoLabel is None:
info_label = extraSql.replace("filter =", "").replace("filter=", "")
if (extra_sql is not None) and (len(extra_sql) > 0):
sql = extra_sql
if extra_info is None:
info_label = extra_sql.replace("filter =", "").replace("filter=", "")
info_label = info_label.replace('"', "").replace("'", "")
if extraInfoLabel is not None:
info_label = extraInfoLabel
if extra_info is not None:
info_label = extra_info

subgroup = info_label

Expand Down Expand Up @@ -623,5 +629,5 @@ def rapidRevisitBatch(

# 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)
23 changes: 13 additions & 10 deletions rubin_sim/maf/plots/special_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,37 @@ def __call__(self, metric_value, slicer, user_plot_dict, fignum=None):
)
# This results in calculating the summary stats in two places ..
# not the ideal choice but easiest for most uses in this case.
asky = plot_dict["asky"]
n_visits = plot_dict["n_visits"]
rarr = np.array(list(zip(metric_value.compressed())), dtype=[("fO", metric_value.dtype)])
f_o_area = metrics.FOArea(
col="fO", n_visit=plot_dict["n_visits"], norm=False, nside=slicer.nside
col="fO", n_visit=n_visits, norm=False, nside=slicer.nside
).run(rarr)
f_o_nv = metrics.FONv(col="fO", asky=plot_dict["asky"], norm=False, nside=slicer.nside).run(rarr)
f_o_nv = metrics.FONv(col="fO", asky=asky, norm=False, nside=slicer.nside).run(rarr)

plt.axvline(x=plot_dict["n_visits"], linewidth=plot_dict["reflinewidth"], color="b")
plt.axhline(y=plot_dict["asky"] / 1000.0, linewidth=plot_dict["reflinewidth"], color="r")
plt.axvline(x=n_visits, linewidth=plot_dict["reflinewidth"], color="b", linestyle=':')
plt.axhline(y=asky / 1000.0, linewidth=plot_dict["reflinewidth"], color="r", linestyle=':')
# Add lines for nvis_median and f_o_area:
# note if these are -666 (badval), they will 'disappear'
nvis_median = f_o_nv["value"][np.where(f_o_nv["name"] == "MedianNvis")]
nvis_median = f_o_nv["value"][np.where(f_o_nv["name"] == "MedianNvis")][0]

plt.axvline(
x=nvis_median,
linewidth=plot_dict["reflinewidth"],
color="b",
alpha=0.5,
linestyle=":",
label=r"f$_0$ Median n_visits=%.0f" % nvis_median,
linestyle="-",
label=f"f$_0$ Med. Nvis. (@ {asky/1000 :.0f}K sq deg) = {nvis_median :.0f} visits",
)
plt.axhline(
y=f_o_area / 1000.0,
linewidth=plot_dict["reflinewidth"],
color="r",
alpha=0.5,
linestyle=":",
label="f$_0$ Area=%.0f" % f_o_area,
linestyle="-",
label=f"f$_0$ Area (@ {n_visits :.0f} visits) = {f_o_area/1000 :.01f}K sq deg",
)
plt.legend(loc="lower left", fontsize="small", numpoints=1)
plt.legend(loc="upper right", fontsize="small", numpoints=1, framealpha=1.0)

plt.xlabel(plot_dict["xlabel"])
plt.ylabel(plot_dict["ylabel"])
Expand Down

0 comments on commit 095572a

Please sign in to comment.