Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/opsim 1140 #416

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions rubin_sim/maf/batches/col_map_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def col_map_dict(dict_name=None):
col_map["seeingGeom"] = "seeingFwhmGeom"
col_map["skyBrightness"] = "skyBrightness"
col_map["moonDistance"] = "moonDistance"
col_map["fieldId"] = "fieldId"
col_map["proposalId"] = "proposalId"
col_map["slewactivities"] = {}
col_map["metadataList"] = [
"airmass",
Expand All @@ -41,7 +39,7 @@ def col_map_dict(dict_name=None):
"saturation_mag",
]
col_map["metadataAngleList"] = ["rotSkyPos"]
col_map["note"] = "note"
col_map["scheduler_note"] = "scheduler_note"

elif dict_name == "opsimv4":
col_map = {}
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/batches/ddf_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def ddfBatch(
for f in filterlist:
fieldsqls[f] = sqls[f]
else:
fieldsql = f"note like '%{fieldname}%'"
fieldsql = f"scheduler_note like '%{fieldname}%'"
for f in filterlist:
if len(sqls[f]) > 0:
fieldsqls[f] = fieldsql + " and " + sqls[f]
Expand Down
26 changes: 14 additions & 12 deletions rubin_sim/maf/batches/glance_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def glanceBatch(
bundle_list.append(bundle)

# alt az of long gaps
sql = "note = 'long'"
sql = "scheduler_note = 'long'"
metric = metrics.CountMetric(colmap["mjd"], metric_name="Nvisits long")
bundle = metric_bundles.MetricBundle(
metric,
Expand All @@ -156,7 +156,7 @@ def glanceBatch(
)
bundle_list.append(bundle)

sql = "note like 'blob_long%'"
sql = "scheduler_note like 'blob_long%'"
metric = metrics.CountMetric(colmap["mjd"], metric_name="Nvisits blob long")
bundle = metric_bundles.MetricBundle(
metric,
Expand All @@ -168,7 +168,7 @@ def glanceBatch(
)
bundle_list.append(bundle)

sql = "note like '%neo%' or note like '%near_sun%'"
sql = "scheduler_note like '%neo%' or scheduler_note like '%near_sun%'"
metric = metrics.CountMetric(colmap["mjd"], metric_name="Nvisits twilight near sun")
bundle = metric_bundles.MetricBundle(
metric,
Expand All @@ -182,7 +182,7 @@ def glanceBatch(

# alt,az pf ToO

sql = "note like 'ToO%'"
sql = "scheduler_note like 'ToO%'"
metric = metrics.CountMetric(colmap["mjd"], metric_name="Nvisits long")
bundle = metric_bundles.MetricBundle(
metric,
Expand Down Expand Up @@ -277,7 +277,7 @@ def glanceBatch(
bundle_list.append(bundle)

# Make a cumulative plot of a WFD spot
sql = "note not like '%NEO%' and note not like '%near_sun%'"
sql = "scheduler_note not like '%NEO%' and scheduler_note not like '%near_sun%'"
uslicer = slicers.UserPointsSlicer(ra=0, dec=-20)
metric = metrics.CumulativeMetric()
metricb = metric_bundles.MetricBundle(
Expand Down Expand Up @@ -362,16 +362,16 @@ def glanceBatch(
)
bundle_list.append(bundle)

# stats from the note column
if "note" in colmap.keys():
# stats from the scheduler_note column
if "scheduler_note" in colmap.keys():
displayDict = {"group": "Basic Stats", "subgroup": "Percent stats"}
metric = metrics.StringCountMetric(col=colmap["note"], percent=True, metric_name="Percents")
metric = metrics.StringCountMetric(col=colmap["scheduler_note"], percent=True, metric_name="Percents")
sql = ""
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["note"], metric_name="Counts")
metric = metrics.StringCountMetric(col=colmap["scheduler_note"], metric_name="Counts")
bundle = metric_bundles.MetricBundle(metric, slicer, sql, display_dict=displayDict)
bundle_list.append(bundle)

Expand All @@ -381,7 +381,7 @@ def glanceBatch(
displayDict["subgroup"] = ""
for ddf in ddf_surveys:
label = ddf.replace("DD:", "")
sql = 'note like "%s%%"' % ("DD:" + label)
sql = 'scheduler_note like "%s%%"' % ("DD:" + label)
slicer = slicers.UniSlicer()
metric = metrics.CumulativeMetric()
metricb = metric_bundles.MetricBundle(
Expand Down Expand Up @@ -515,7 +515,7 @@ def glanceBatch(
lat_lon_deg=colmap["raDecDeg"],
)
for filtername in filternames:
sql = "filter='%s' and note like 'ToO%%'" % filtername
sql = "filter='%s' and scheduler_note like 'ToO%%'" % filtername
metric = metrics.CountMetric(col=colmap["mjd"], metric_name="N ToO")
bundle = metric_bundles.MetricBundle(
metric,
Expand All @@ -528,7 +528,9 @@ def glanceBatch(
)
bundle_list.append(bundle)

too_sqls = ["note like 'ToO, %" + "t%i'" % hour for hour in [0, 1, 2, 4, 24, 48]] + ["note like 'ToO, %'"]
too_sqls = ["scheduler_note like 'ToO, %" + "t%i'" % hour for hour in [0, 1, 2, 4, 24, 48]] + [
"scheduler_note like 'ToO, %'"
]
slicer = slicers.UniSlicer()
for sql in too_sqls:
metric = metrics.CountMetric(col="night")
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/batches/info_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def info_bundle_dicts(allsky_slicer, wfd_slicer, opsim="opsim", colmap=batches.c
colmap,
opsim,
slicer=allsky_slicer,
extraSql='night > 365*3.5 and night < 365*4.5 and note not like "%DD%"',
extraSql='night > 365*3.5 and night < 365*4.5 and scheduler_note not like "%DD%"',
extraInfoLabel="Yr 3-4",
runLength=1,
)
Expand All @@ -87,7 +87,7 @@ def info_bundle_dicts(allsky_slicer, wfd_slicer, opsim="opsim", colmap=batches.c
extraInfoLabel="WFD",
)
)
dd_constraint = "note like '%DD%'"
dd_constraint = "scheduler_note like '%DD%'"
bdict.update(
batches.nvisitsPerSubset(
colmap,
Expand Down
14 changes: 7 additions & 7 deletions rubin_sim/maf/batches/radar_limited.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def radar_limited(
for yr_cut in yrs:
ptsrc_lim_mag_i_band = mag_cuts[yr_cut]
sqlconstraint = "night <= %s" % (yr_cut * 365.25 + 0.5)
sqlconstraint += ' and note not like "DD%"'
sqlconstraint += ' and scheduler_note not like "DD%"'
info_label = f"{bandpass} band non-DD year {yr_cut}"
ThreebyTwoSummary_simple = metrics.StaticProbesFoMEmulatorMetricSimple(
nside=nside, year=yr_cut, metric_name="3x2ptFoM_simple"
Expand Down Expand Up @@ -581,7 +581,7 @@ def radar_limited(
subgroupCount += 1
displayDict["subgroup"] = f"{subgroupCount}: WL"
displayDict["order"] = 0
sqlconstraint = 'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
sqlconstraint = 'scheduler_note not like "DD%" and (filter="g" or filter="r" or filter="i")'
info_label = "gri band non-DD"
minExpTime = 15
m = metrics.WeakLensingNvisits(
Expand Down Expand Up @@ -612,7 +612,7 @@ def radar_limited(
# Do the weak lensing per year
for year in [10]:
sqlconstraint = (
'note not like "DD%"'
'scheduler_note not like "DD%"'
+ ' and (filter="g" or filter="r" or filter="i") and night < %i' % (year * 365.25)
)
m = metrics.WeakLensingNvisits(
Expand Down Expand Up @@ -648,7 +648,7 @@ def radar_limited(
bundleList.append(bundle)

sqlconstraint = (
'note not like "DD%"'
'scheduler_note not like "DD%"'
+ ' and (filter="r" or filter="i" or filter="z") and night < %i' % (year * 365.25)
)
m = metrics.WeakLensingNvisits(
Expand Down Expand Up @@ -741,7 +741,7 @@ def radar_limited(
bundle = mb.MetricBundle(
metric,
snslicer,
"note not like '%DD%'",
"scheduler_note not like '%DD%'",
plot_dict=plotDict,
display_dict=displayDict,
info_label="DDF excluded",
Expand Down Expand Up @@ -925,7 +925,7 @@ def radar_limited(
bundle = mb.MetricBundle(
metric,
kneslicer,
"note not like 'DD%'",
"scheduler_note not like 'DD%'",
run_name=runName,
info_label="single model",
summary_metrics=lightcurve_summary(),
Expand All @@ -947,7 +947,7 @@ def radar_limited(
bundle = mb.MetricBundle(
metric_allkne,
kneslicer_allkne,
"note not like 'DD%'",
"scheduler_note not like 'DD%'",
run_name=runName,
info_label="all models",
summary_metrics=lightcurve_summary(),
Expand Down
20 changes: 10 additions & 10 deletions rubin_sim/maf/batches/science_radar_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def science_radar_batch(
for yr_cut in yrs:
ptsrc_lim_mag_i_band = mag_cuts[yr_cut]
sqlconstraint = "night <= %s" % (yr_cut * 365.25 + 0.5)
sqlconstraint += ' and note not like "DD%"'
sqlconstraint += ' and scheduler_note not like "DD%"'
info_label = f"{bandpass} band non-DD year {yr_cut}"
ThreebyTwoSummary_simple = metrics.StaticProbesFoMEmulatorMetricSimple(
nside=nside, year=yr_cut, metric_name="3x2ptFoM_simple"
Expand Down Expand Up @@ -614,7 +614,7 @@ def science_radar_batch(
plotDict = {"n_ticks": 5}
# Have to include all filters in query to check for filter coverage.
# Galaxy numbers calculated using 'bandpass' images only though.
sqlconstraint = 'note not like "DD%"'
sqlconstraint = 'scheduler_note not like "DD%"'
info_label = f"{bandpass} band galaxies non-DD"
metric = maf.DepthLimitedNumGalMetric(
nside=nside,
Expand Down Expand Up @@ -654,7 +654,7 @@ def science_radar_batch(
subgroupCount += 1
displayDict["subgroup"] = f"{subgroupCount}: WL"
displayDict["order"] = 0
sqlconstraint = 'note not like "DD%" and (filter="g" or filter="r" or filter="i")'
sqlconstraint = 'scheduler_note not like "DD%" and (filter="g" or filter="r" or filter="i")'
info_label = "gri band non-DD"
minExpTime = 15
m = metrics.WeakLensingNvisits(
Expand Down Expand Up @@ -686,7 +686,7 @@ def science_radar_batch(
for year in np.arange(1, 10):
displayDict["order"] = year
sqlconstraint = (
'note not like "DD%"'
'scheduler_note not like "DD%"'
+ ' and (filter="g" or filter="r" or filter="i") and night < %i' % (year * 365.25)
)
m = metrics.WeakLensingNvisits(
Expand Down Expand Up @@ -722,7 +722,7 @@ def science_radar_batch(
bundleList.append(bundle)

sqlconstraint = (
'note not like "DD%"'
'scheduler_note not like "DD%"'
+ ' and (filter="r" or filter="i" or filter="z") and night < %i' % (year * 365.25)
)
m = metrics.WeakLensingNvisits(
Expand Down Expand Up @@ -781,7 +781,7 @@ def science_radar_batch(
# Kuiper per year in gri and riz
for year in np.arange(1, 10):
sqlconstraint = (
'note not like "DD%"'
'scheduler_note not like "DD%"'
+ ' and (filter="g" or filter="r" or filter="i") and night < %i' % (year * 365.25)
)
metric1 = metrics.KuiperMetric("rotSkyPos", metric_name="Kuiper_rotSkyPos_gri_year%i" % year)
Expand Down Expand Up @@ -835,7 +835,7 @@ def science_radar_batch(
bundle = mb.MetricBundle(
metric,
snslicer,
"note not like '%DD%'",
"scheduler_note not like '%DD%'",
plot_dict=plotDict,
display_dict=displayDict,
info_label="DDF excluded",
Expand All @@ -858,7 +858,7 @@ def science_radar_batch(

# Calculate the number of expected QSOs, in each band
for f in filterlist:
sql = filtersqls[f] + ' and note not like "%DD%"'
sql = filtersqls[f] + ' and scheduler_note not like "%DD%"'
md = filterinfo_label[f] + " and non-DD"
summaryMetrics = [metrics.SumMetric(metric_name="Total QSO")]
zmin = 0.3
Expand Down Expand Up @@ -1359,7 +1359,7 @@ def science_radar_batch(
bundle = mb.MetricBundle(
metric,
kneslicer,
"note not like 'DD%'",
"scheduler_note not like 'DD%'",
run_name=runName,
info_label="single model",
summary_metrics=lightcurve_summary(),
Expand All @@ -1381,7 +1381,7 @@ def science_radar_batch(
bundle = mb.MetricBundle(
metric_allkne,
kneslicer_allkne,
"note not like 'DD%'",
"scheduler_note not like 'DD%'",
run_name=runName,
info_label="all models",
summary_metrics=lightcurve_summary(),
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/sn_n_sn_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
nexp_col="numExposures",
vistime_col="visitTime",
seeing_col="seeingFwhmEff",
note_col="note",
note_col="scheduler_note",
season=[-1],
coadd_night=True,
zmin=0.1,
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/use_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class UseMetric(BaseMetric): # pylint: disable=too-few-public-methods
"""Metric to classify visits by type of visits"""

def __init__(self, note_col="note", **kwargs):
def __init__(self, note_col="scheduler_note", **kwargs):
self.note_col = note_col
super().__init__(col=[note_col], metric_dtype="object", **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/slicers/time_interval_slicers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(
self,
mjd_column_name="observationStartMJD",
duration_column_name="visitTime",
note_column_name="note",
note_column_name="scheduler_note",
badval=np.NaN,
verbose=False,
):
Expand All @@ -171,7 +171,7 @@ def setup_slicer(self, sim_data, maps=None):
columns={
self.mjd_column_name: "mjd",
self.duration_column_name: "duration",
self.note_column_name: "note",
self.note_column_name: "scheduler_note",
},
inplace=True,
)
Expand Down
1 change: 0 additions & 1 deletion rubin_sim/maf/stackers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .base_stacker import *
from .coord_stackers import *
from .date_stackers import *
from .dither_stackers import *
from .general_stackers import *
from .get_col_info import *
from .label_stackers import *
Expand Down
19 changes: 18 additions & 1 deletion rubin_sim/maf/stackers/coord_stackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@
from rubin_scheduler.utils import calc_lmst

from .base_stacker import BaseStacker
from .dither_stackers import wrap_ra


def wrap_ra(ra):
"""
Wrap only RA values into 0-2pi (using mod).

Parameters
----------
ra : numpy.ndarray
RA in radians

Returns
-------
numpy.ndarray
Wrapped RA values, in radians.
"""
ra = ra % (2.0 * np.pi)
return ra


def ra_dec2_alt_az(ra, dec, lat, lon, mjd, altonly=False):
Expand Down
Loading
Loading