Skip to content

Commit

Permalink
add target_id added by the CoreScheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
yoachim committed Dec 19, 2024
1 parent 21cba3a commit 69df366
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
24 changes: 17 additions & 7 deletions rubin_scheduler/scheduler/schedulers/core_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class CoreScheduler:
telescope : `str`
Which telescope model to use for rotTelPos/rotSkyPos conversions.
Default "rubin".
target_id_counter : int
Starting value for the target_id. If restarting observations, could
be useful to set to whatever value the scheduler was at previously.
Default 0.
"""

def __init__(
Expand All @@ -51,6 +55,7 @@ def __init__(
log=None,
keep_rewards=False,
telescope="rubin",
target_id_counter=0,
):
self.keep_rewards = keep_rewards
# Use integer ns just to be sure there are no rounding issues.
Expand Down Expand Up @@ -86,9 +91,12 @@ def __init__(

self.rc = rotation_converter(telescope=telescope)

# keep track of how many observations get flushed from the queue
# Keep track of how many observations get flushed from the queue
self.flushed = 0

# Counter for observations added to the queue
self.target_id_counter = target_id_counter

def flush_queue(self):
"""Like it sounds, clear any currently queued desired observations."""
self.queue = []
Expand Down Expand Up @@ -302,14 +310,16 @@ def _fill_queue(self):
# Take a min here, so the surveys will be executed in the order
# they are entered if there is a tie.
self.survey_index[1] = np.min(np.where(rewards == np.nanmax(rewards)))
# Survey returns ObservationArray. Convert to list.
result = (
self.survey_lists[self.survey_index[0]][self.survey_index[1]]
.generate_observations(self.conditions)
.tolist()
# Survey returns ObservationArray
result = self.survey_lists[self.survey_index[0]][self.survey_index[1]].generate_observations(
self.conditions
)
# Tag with a unique target_id
result["target_id"] = np.arange(self.target_id_counter, self.target_id_counter + result.size)
self.target_id_counter += result.size

self.queue = result
# Convert to a list for the queue
self.queue = result.tolist()
self.queue_filled = self.conditions.mjd

if len(self.queue) == 0:
Expand Down
1 change: 0 additions & 1 deletion rubin_scheduler/scheduler/surveys/surveys.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ def generate_observations_rough(self, conditions):
observations["nexp"] = self.nexp_dict[self.filtername1]
observations["exptime"] = self.exptime
observations["scheduler_note"] = self.scheduler_note
observations["block_id"] = self.counter
observations["flush_by_mjd"] = flush_time

return observations
2 changes: 1 addition & 1 deletion rubin_scheduler/scheduler/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def __new__(cls, n=1):
("note", "U40"),
("scheduler_note", "U40"),
("target_name", "U40"),
("block_id", int),
("target_id", int),
("lmst", float),
("rotTelPos", float),
("rotTelPos_backup", float),
Expand Down

0 comments on commit 69df366

Please sign in to comment.