Skip to content

Commit

Permalink
Merge pull request #357 from lsst-ts/tickets/DM-47381
Browse files Browse the repository at this point in the history
Tickets/dm 47381: Support Summit Observing Weeks 45-46 of 2024
  • Loading branch information
edennihy authored Nov 18, 2024
2 parents bcd8feb + e21bc5e commit 407b7bc
Show file tree
Hide file tree
Showing 25 changed files with 2,423 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_scheduler():

make_scheduler = MakeFieldSurveyScheduler(nside=nside, ntiers=1)

nvisits = {"u_02": 1, "g_01": 1, "r_03": 1, "i_06": 1, "z_03": 1, "y": 1}
nvisits = {"u_02": 5, "g_01": 5, "r_03": 5, "i_06": 5, "z_03": 5, "y": 5}
sequence = ["r_03", "i_06", "z_03"]
# exposure time in seconds
exptimes = {"u_02": 38, "g_01": 30, "r_03": 30, "i_06": 30, "z_03": 30, "y": 30}
Expand All @@ -56,7 +56,7 @@ def get_scheduler():
}

config_basis_functions = [
# basis_functions.NotTwilightBasisFunction(sun_alt_limit=-12.0),
basis_functions.NotTwilightBasisFunction(sun_alt_limit=-12.0),
basis_functions.AltAzShadowMaskBasisFunction(
nside=nside,
min_alt=20.0,
Expand All @@ -71,11 +71,13 @@ def get_scheduler():
basis_functions.FilterLoadedBasisFunction(filternames=sequence),
]

config_detailers = [detailers.DitherDetailer(max_dither=0.2, per_night=False)]
config_detailers = [
detailers.DitherDetailer(max_dither=0.2, per_night=False),
detailers.CameraRotDetailer(max_rot=10.0, min_rot=-10.0),
]

observation_reason = "science"
science_program = "BLOCK-320" # json BLOCK to be used
survey_name = science_program # match nextVisit metadata

tier = 0
target_names = get_comcam_sv_targets().keys()
Expand All @@ -84,7 +86,6 @@ def get_scheduler():
observation_reason,
science_program,
target_names,
survey_name=survey_name,
basis_functions=config_basis_functions,
detailers=config_detailers,
**field_survey_kwargs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def gen_greedy_surveys(
ignore_obs="DD",
footprint_weight=0.3,
slewtime_weight=3.0,
stayfilter_weight=3.0,
stayfilter_weight=0.8,
footprints=None,
seed=42,
):
Expand Down Expand Up @@ -86,13 +86,14 @@ def gen_greedy_surveys(
"""
# Define the extra parameters that are used in the greedy survey. I
# think these are fairly set, so no need to promote to utility func kwargs
name = "BLOCK-T233"
greed_survey_params = {
"block_size": 1,
"smoothing_kernel": None,
"seed": seed,
"camera": "LSST",
"dither": True,
"survey_name": "BLOCK-T233",
"survey_name": name,
}

surveys = []
Expand All @@ -113,6 +114,7 @@ def gen_greedy_surveys(
nexps.update(nexp_override)

for filtername in filters:
note = f"{name}_{filtername}"
bfs = [
(
bf.FootprintBasisFunction(
Expand All @@ -137,7 +139,16 @@ def gen_greedy_surveys(
),
0,
),
(bf.FilterLoadedBasisFunction(filternames=filtername), 0),
(bf.FilterLoadedBasisFunction(filternames=filtername), 1),
(bf.AvoidFastRevisitsBasisFunction(filtername=filtername, nside=nside), 1),
(
bf.BalanceVisits(
nobs_reference=10, note_survey=note, note_interest=name, nside=nside
),
1,
),
(bf.FilterChangeBasisFunction(filtername=filtername), 1),
(bf.FilterDistBasisFunction(filtername=filtername), 1),
]

weights = [val[1] for val in bfs]
Expand Down Expand Up @@ -173,29 +184,39 @@ def gen_greedy_surveys(
sky = SkyAreaGenerator(nside=nside)
footprints_hp, footprints_labels = sky.return_maps()

footprints = Footprint(MJD_START, sun_ra_start=conditions.sun_ra, nside=nside)
footprints = Footprint(
MJD_START,
sun_ra_start=conditions.sun_ra,
nside=nside,
filters=["u", "g_6", "r_57", "i", "z", "y_10"],
)
for i, key in enumerate(footprints_hp.dtype.names):
footprints.footprints[i, :] = footprints_hp[key]
footprints.filters = dict(
u=0,
g_6=1,
r_57=2,
i=3,
z=4,
y_10=5,
)

# Generate surveys for all filters to test "FilterLoaded" basis func
eo_test_filters = [
"u",
"y",
"g",
"i",
"r",
"z",
"g_6",
"r_57",
"y_10",
] # ['y', 'r', 'g'] actually present
# for EO OpSim, we'll have 'g' function like 'u' (IE 1 long exposure)
nexp_override = {"g": 1}
exptime_override = {"g": 38}
nexp_override = {"g_6": 1}
exptime_override = {"g_6": 30.0}

greedy = gen_greedy_surveys(
nside,
nexp=2,
nexp_override=nexp_override,
exptime_override=exptime_override,
exptime=29.2,
exptime=30.0,
filters=eo_test_filters,
footprints=footprints,
seed=seed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

def gen_field_survey(
name,
ra=30.0,
dec=-80.0,
ra=0.0,
dec=-70.0,
sequence=["r_03", "i_06"],
visits=1,
nexp=1,
Expand Down Expand Up @@ -94,27 +94,15 @@ def gen_field_survey(
# think these are fairly set, so no need to promote to utility func kwargs

survey_detailers = [
detailers.TrackingInfoDetailer(science_program=name),
detailers.CameraRotDetailer(
min_rot=np.min(camera_rot_limits), max_rot=np.max(camera_rot_limits)
),
]

for filtername in sequence:
bfs = [
(
bf.SlewtimeBasisFunction(filtername=filtername, nside=nside),
slewtime_weight,
),
(bf.StrictFilterBasisFunction(filtername=filtername), stayfilter_weight),
(
bf.AltAzShadowMaskBasisFunction(
nside=nside,
shadow_minutes=shadow_minutes,
max_alt=max_alt,
min_alt=30.0,
),
0,
),
(bf.FilterLoadedBasisFunction(filternames=filtername), 0),
(bf.VisitGap(name, gap_min=720.0), 0),
]
Expand Down Expand Up @@ -144,7 +132,7 @@ def gen_field_survey(
if __name__ == "config":
nside = 32

filters_list = ["i_06", "r_03"]
filters_list = ["z_03"]

surveys = []
for i in range(0, 30):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# This file is part of ts_config_ocs.
#
# Developed for the Vera Rubin Observatory Telescope and Site System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import numpy as np
import rubin_scheduler.scheduler.basis_functions as bf
import rubin_scheduler.scheduler.detailers as detailers
from rubin_scheduler.scheduler.schedulers import CoreScheduler
from rubin_scheduler.scheduler.surveys import FieldSurvey


def gen_field_survey(
name,
ra=0.0,
dec=-70.0,
sequence=["r_03", "i_06"],
visits=1,
nexp=1,
exptime=30.0,
nside=32,
camera_rot_limits=[-80.0, 80.0],
shadow_minutes=60.0,
max_alt=86.0,
ignore_obs="DD",
slewtime_weight=3.0,
stayfilter_weight=3.0,
):
"""A survey class for running field surveys.
Parameters
----------
name : `str` name of survey
RA : `float`
The RA of the field (degrees)
dec : `float`
The dec of the field to observe (degrees)
sequence : `list` [`str`]
The sequence of observations to take. (specify which filters to use).
nvisits : `dict` {`str`: `int`}
Dictionary of the number of visits in each filter.
Default of None will use a backup sequence of 20 visits per filter.
Must contain all filters in sequence.
exptimes : `dict` {`str`: `float`}
Dictionary of the exposure time for visits in each filter.
Default of None will use a backup sequence of 38s in u, and
29.2s in all other bands. Must contain all filters in sequence.
nexps : dict` {`str`: `int`}
Dictionary of the number of exposures per visit in each filter.
Default of None will use a backup sequence of 1 exposure per visit
in u band, 2 in all other bands. Must contain all filters in sequence.
ignore_obs : `list` [`str`] or None
Ignore observations with this string in the `scheduler_note`.
Will ignore observations which match subsets of the string, as well as
the entire string. Ignoring 'mysurvey23' will also ignore 'mysurvey2'.
survey_name : `str` or None.
The name to give this survey, for debugging and visualization purposes.
Also propagated to the 'target_name' in the observation.
The default None will construct a name based on the
RA/Dec of the field.
nside : `float` or None
Nside for computing survey basis functions and maps.
The default of None will use rubin_scheduler.utils.set_default_nside().
camera_rot_limits : list of float ([-80., 80.])
The limits to impose when rotationally dithering the camera (degrees).
shadow_minutes : float (60.)
Used to mask regions around zenith (minutes).
max_alt : float (76.)
The maximium altitude to use when masking zenith (degrees).
ignore_obs : str or list of str ('DD')
Ignore observations by surveys that include the given substring(s).
slewtime_weight : float (3.)
The weight on the slewtime basis function.
stayfilter_weight : float (3.)
The weight on basis function that tries to stay avoid filter changes.
"""
# Define the extra parameters that are used in the greedy survey. I
# think these are fairly set, so no need to promote to utility func kwargs

survey_detailers = [
detailers.TrackingInfoDetailer(science_program=name),
detailers.CameraRotDetailer(
min_rot=np.min(camera_rot_limits), max_rot=np.max(camera_rot_limits)
),
]

for filtername in sequence:
bfs = [
(bf.StrictFilterBasisFunction(filtername=filtername), stayfilter_weight),
(bf.FilterLoadedBasisFunction(filternames=filtername), 0),
(bf.VisitGap(name, gap_min=720.0), 0),
]

exptimes = {filter: exptime for filter in sequence}
nexps = {filter: nexp for filter in sequence}
nvisits = {filter: visits for filter in sequence}
basis_functions = [val[0] for val in bfs]
survey = FieldSurvey(
basis_functions,
ra,
dec,
sequence=sequence,
exptimes=exptimes,
nexps=nexps,
nvisits=nvisits,
nside=nside,
ignore_obs=ignore_obs,
detailers=survey_detailers,
survey_name=name,
science_program=name,
)

return survey


if __name__ == "config":
nside = 32

filters_list = ["r_03", "i_06", "g_07"]

surveys = []
for i in range(0, 30):
surveys.append(gen_field_survey(f"BLOCK-T248_{i}", sequence=filters_list))
scheduler = CoreScheduler(surveys, nside=nside)
Loading

0 comments on commit 407b7bc

Please sign in to comment.