diff --git a/rubin_scheduler/scheduler/schedulers/core_scheduler.py b/rubin_scheduler/scheduler/schedulers/core_scheduler.py index 2ff995b8..c7f4d4b4 100644 --- a/rubin_scheduler/scheduler/schedulers/core_scheduler.py +++ b/rubin_scheduler/scheduler/schedulers/core_scheduler.py @@ -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__( @@ -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. @@ -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 = [] @@ -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: diff --git a/rubin_scheduler/scheduler/surveys/surveys.py b/rubin_scheduler/scheduler/surveys/surveys.py index da72df3a..668a29cd 100644 --- a/rubin_scheduler/scheduler/surveys/surveys.py +++ b/rubin_scheduler/scheduler/surveys/surveys.py @@ -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 diff --git a/rubin_scheduler/scheduler/utils/utils.py b/rubin_scheduler/scheduler/utils/utils.py index 66274b23..7f3a8cb9 100644 --- a/rubin_scheduler/scheduler/utils/utils.py +++ b/rubin_scheduler/scheduler/utils/utils.py @@ -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),