Skip to content

Commit

Permalink
no_sky option on model observatory
Browse files Browse the repository at this point in the history
  • Loading branch information
yoachim committed Sep 28, 2023
1 parent 490475f commit 806adec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 1 addition & 2 deletions rubin_sim/scheduler/example/example_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
generate_ddf_scheduled_obs,
)
from rubin_sim.scheduler.utils import ConstantFootprint, EuclidOverlapFootprint, make_rolling_footprints
from rubin_sim.utils import _hpid2_ra_dec
from rubin_sim.site_models import Almanac

from rubin_sim.utils import _hpid2_ra_dec

iers.conf.auto_download = False

Expand Down
22 changes: 16 additions & 6 deletions rubin_sim/scheduler/model_observatory/model_observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(
cloud_data=None,
seeing_data=None,
downtimes=None,
no_sky=False,
):
"""
Parameters
Expand Down Expand Up @@ -108,13 +109,17 @@ def __init__(
downtimes : None
If one wants to replace the default downtimes. Should be a np.array with columns
of "start" and "end" with MJD values and should include both scheduled and unscheduled downtime
no_sky : bool
Don't bother loading sky files. Handy if one wants a well filled out Conditions object,
but doesn't need the sky since that can be slower to load. Default False.
"""

if nside is None:
nside = set_default_nside()
self.nside = nside

self.cloud_limit = cloud_limit
self.no_sky = no_sky

self.alt_min = np.radians(alt_min)
self.lax_dome = lax_dome
Expand Down Expand Up @@ -192,7 +197,10 @@ def __init__(
else:
self.cloud_data = CloudData(mjd_start_time, cloud_db=cloud_db, offset_year=cloud_offset_year)

self.sky_model = sb.SkyModelPre(init_load_length=init_load_length)
if not self.no_sky:
self.sky_model = sb.SkyModelPre(init_load_length=init_load_length)
else:
self.sky_model = None

if kinem_model is None:
self.observatory = KinemModel(mjd0=self.mjd_start)
Expand Down Expand Up @@ -288,7 +296,8 @@ def return_conditions(self):
self.conditions.fwhm_eff = self.seeing_fwhm_eff

# sky brightness
self.conditions.skybrightness = self.sky_model.return_mags(self.mjd)
if self.sky_model is not None:
self.conditions.skybrightness = self.sky_model.return_mags(self.mjd)

self.conditions.mounted_filters = self.observatory.mounted_filters
self.conditions.current_filter = self.observatory.current_filter[0]
Expand Down Expand Up @@ -390,10 +399,11 @@ def observation_add_data(self, observation):
observation["night"] = self.night
observation["mjd"] = self.mjd

hpid = _ra_dec2_hpid(self.sky_model.nside, observation["RA"], observation["dec"])
observation["skybrightness"] = self.sky_model.return_mags(self.mjd, indx=[hpid], extrapolate=True)[
observation["filter"][0]
]
if self.sky_model is not None:
hpid = _ra_dec2_hpid(self.sky_model.nside, observation["RA"], observation["dec"])
observation["skybrightness"] = self.sky_model.return_mags(
self.mjd, indx=[hpid], extrapolate=True
)[observation["filter"][0]]

observation["fivesigmadepth"] = m5_flat_sed(
observation["filter"][0],
Expand Down

0 comments on commit 806adec

Please sign in to comment.