Skip to content

Commit

Permalink
more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
yoachim committed Jan 16, 2024
1 parent 2f4db6d commit 13a65b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
3 changes: 2 additions & 1 deletion rubin_scheduler/scheduler/detailers/detailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def __call__(self, observation_list, conditions):


class FlushByDetailer(BaseDetailer):

Check warning on line 75 in rubin_scheduler/scheduler/detailers/detailer.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/detailers/detailer.py#L75

Added line #L75 was not covered by tests
"""
"""Set the MJD an observation should be flushed from the scheduler queue if not yet completed.
Parameters
----------
flush_time : float
Expand Down
21 changes: 14 additions & 7 deletions rubin_scheduler/scheduler/surveys/pointings_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PointingsSurvey(BaseSurvey):
Parameters
----------
observations : np.array
observations : `np.array`
An array of observations, from e.g. rubin_scheduler.scheduler.utils.empty_observation
expect "RA", "dec", and "note" to be filled, other columns ignored.
gap_min : `float`
Expand All @@ -28,23 +28,23 @@ class PointingsSurvey(BaseSurvey):
Altitude limit of the telescope (degrees). Default 20.
alt_max : `float`
Altitude limit of the telescope (degrees). Default 85.
ha_max, ha_min : float (4,-4)
ha_max, ha_min : `float` (4,-4)
hour angle limits (hours). Applied to all observations. Default 4,-4.
weights : dict
weights : `dict`
Dictionary with keys of method names and values of floats.
Default of None uses {"visit_gap": 1.0, "balance_revisit": 1.0,
"m5diff": 1.0,
"wind_limit": 1.0, "slew_time": -1.0,
"ha_limit": 0, "alt_limit": 0, "moon_limit": 0}
wind_speed_maximum : float
wind_speed_maximum : `float`
The maximum wind (m/s), mask any targets that would take more wind than that.
Default 100 m/s.
fiducial_FWHMEff : float
fiducial_FWHMEff : `float`
A fiducial seeing value to use when computing dark sky depth.
Default 0.7 arcsec.
sun_alt_limit : float
sun_alt_limit : `float`
Have survey as infeasible when sun altitude is above the limit. default -12 (degrees).
track_notes_ngoal : dict
track_notes_ngoal : `dict`
If there are observations that should be tracked together (e.g., a sequence that
should be observed together). Dict with keys of str and values of int.
"""
Expand Down Expand Up @@ -130,6 +130,7 @@ def __init__(
self.detailers = detailers

Check warning on line 130 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L130

Added line #L130 was not covered by tests

def _check_feasibility(self, conditions):

Check warning on line 132 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L132

Added line #L132 was not covered by tests
"""Check if the survey is feasable in the current conditions"""
# Simple feasability check.
result = True

Check warning on line 135 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L135

Added line #L135 was not covered by tests

Expand All @@ -143,6 +144,7 @@ def _check_feasibility(self, conditions):
return result

Check warning on line 144 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L141-L144

Added lines #L141 - L144 were not covered by tests

def calc_reward_function(self, conditions):

Check warning on line 146 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L146

Added line #L146 was not covered by tests
"""Compute reward function using methods set by `weights` dict on init."""
if self.last_computed_reward != conditions.mjd:
self.alt, self.az = _approx_ra_dec2_alt_az(

Check warning on line 149 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L148-L149

Added lines #L148 - L149 were not covered by tests
self.observations["RA"],
Expand All @@ -167,13 +169,17 @@ def calc_reward_function(self, conditions):
return np.nanmax(self.reward)

Check warning on line 169 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L168-L169

Added lines #L168 - L169 were not covered by tests

def generate_observations_rough(self, conditions):

Check warning on line 171 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L171

Added line #L171 was not covered by tests
"""Calculate reward function and highest reward observation. This is usually
called by `generate_observations` which will take the result and then apply detailers to them.
"""
max_reward = self.calc_reward_function(conditions)

Check warning on line 175 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L175

Added line #L175 was not covered by tests
# take the first one in the array if there's a tie
# Could change logic to return multiple pointings
winner = np.min(np.where(self.reward == max_reward)[0])
return [self.observations[winner].copy().reshape(1)]

Check warning on line 179 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L178-L179

Added lines #L178 - L179 were not covered by tests

def add_observation(self, observation, indx=None):

Check warning on line 181 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L181

Added line #L181 was not covered by tests
"""Let survey know about a completed observation."""
# Check for a nore match
indx = np.where(observation["note"] == self.observations["note"])[0]

Check warning on line 184 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L184

Added line #L184 was not covered by tests
# Tracking arrays
Expand All @@ -186,6 +192,7 @@ def add_observation(self, observation, indx=None):
self.tracking_notes[key] += 1

Check warning on line 192 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L190-L192

Added lines #L190 - L192 were not covered by tests

def add_observations_array(self, observations_array_in, observations_hpid_in):

Check warning on line 194 in rubin_scheduler/scheduler/surveys/pointings_survey.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/scheduler/surveys/pointings_survey.py#L194

Added line #L194 was not covered by tests
"""Like `add_observation`, but for a large array of completed observations."""
for unote in np.unique(observations_array_in["note"]):
matching = np.where(observations_array_in["note"] == unote)[0]
indx = np.where(self.observations["note"] == unote)[0]
Expand Down
20 changes: 19 additions & 1 deletion rubin_scheduler/skybrightness_pre/dark_sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,25 @@ def dark_sky(nside=32):


def dark_m5(decs, filtername, latitude_rad, fiducial_FWHMEff, exptime=30.0, nexp=1):

Check warning on line 42 in rubin_scheduler/skybrightness_pre/dark_sky.py

View check run for this annotation

Codecov / codecov/patch

rubin_scheduler/skybrightness_pre/dark_sky.py#L42

Added line #L42 was not covered by tests
"""Return a nominal best-depth map of the sky"""
"""Return a nominal best-depth map of the sky
Parameters
----------
decs : `float`
The declinations for the desired points. Float or adday-like. (radians)
filtername : `str`
Name of filter, one of ugrizy.
latitude_rad : `float`
Latitude of the observatory (radians)
fiducial_FWHMEff : `float`
The fiducial seeing FWHMeff to use (arcsec).
exptime : `float`
The fiducial exposure time to assume (seconds). Default 30.
nexp : `int`
The number of exposures per visit. Default 1.
"""
nside = hp.npix2nside(np.size(decs))
ds = dark_sky(nside)[filtername]
min_z = np.abs(decs - latitude_rad)
Expand Down

0 comments on commit 13a65b6

Please sign in to comment.