diff --git a/scheduler/core/calculations/selection.py b/scheduler/core/calculations/selection.py index 78c41513..4a81e638 100644 --- a/scheduler/core/calculations/selection.py +++ b/scheduler/core/calculations/selection.py @@ -3,10 +3,10 @@ from dataclasses import dataclass from datetime import timedelta -from typing import final, Callable, FrozenSet, Mapping, Optional +from typing import final, Callable, FrozenSet, Mapping, Optional, Dict from lucupy.helpers import flatten -from lucupy.minimodel import Group, NightIndices, Program, ProgramID, Site, UniqueGroupID +from lucupy.minimodel import Group, NightIndices, Program, ProgramID, Site, UniqueGroupID, VariantSnapshot from scheduler.core.components.ranker import Ranker from scheduler.core.types import StartingTimeslots @@ -35,6 +35,7 @@ class Selection: schedulable_groups: Mapping[UniqueGroupID, GroupData] night_events: Mapping[Site, NightEvents] night_indices: NightIndices + night_conditions: Dict[Site, VariantSnapshot] time_slot_length: timedelta starting_time_slots: StartingTimeslots ranker: Ranker diff --git a/scheduler/core/components/changemonitor/change_monitor.py b/scheduler/core/components/changemonitor/change_monitor.py index 5b374b0e..bdbd17c3 100644 --- a/scheduler/core/components/changemonitor/change_monitor.py +++ b/scheduler/core/components/changemonitor/change_monitor.py @@ -137,7 +137,7 @@ def process_event(self, # Regardless, we want to change the weather values for CC and IQ. self.selector.update_site_variant(site, variant_change) - # If the site is blocked, we have no reason to recalculate a plan until all blocking evens + # If the site is blocked, we have no reason to recalculate a plan until all blocking events # are unblocked. if plans is None: if self.is_site_blocked(site): diff --git a/scheduler/core/components/optimizer/optimizer.py b/scheduler/core/components/optimizer/optimizer.py index 3a5be229..87a0d6bd 100644 --- a/scheduler/core/components/optimizer/optimizer.py +++ b/scheduler/core/components/optimizer/optimizer.py @@ -42,7 +42,9 @@ def schedule(self, selection: Selection) -> List[Plans]: self.night_events = selection.night_events # Create set of plans for the amount of nights - nights = [Plans(self.night_events, night_idx) for night_idx in self.selection.night_indices] + nights = [Plans(self.night_events, + selection.night_conditions, + night_idx) for night_idx in self.selection.night_indices] self.algorithm.schedule(nights) return nights diff --git a/scheduler/core/components/selector/selector.py b/scheduler/core/components/selector/selector.py index 80b37453..b3f06157 100644 --- a/scheduler/core/components/selector/selector.py +++ b/scheduler/core/components/selector/selector.py @@ -270,6 +270,7 @@ def select(self, schedulable_groups=schedulable_groups_map, night_events={site: self.collector.get_night_events(site) for site in sites}, night_indices=night_indices, + night_conditions=self._variant_snapshot_per_site, starting_time_slots=starting_time_slots, time_slot_length=self.collector.time_slot_length.to_datetime(), ranker=ranker, diff --git a/scheduler/core/eventsqueue/nightchanges.py b/scheduler/core/eventsqueue/nightchanges.py index 0ec43fcb..2d30124d 100644 --- a/scheduler/core/eventsqueue/nightchanges.py +++ b/scheduler/core/eventsqueue/nightchanges.py @@ -91,7 +91,8 @@ def get_final_plan(self, night_idx: NightIndex, site: Site) -> Optional[Plan]: end=relevant_entries[-1].plan_generated.end, time_slot_length=relevant_entries[0].plan_generated.time_slot_length, site=site, - _time_slots_left=relevant_entries[-1].plan_generated.time_left()) + _time_slots_left=relevant_entries[-1].plan_generated.time_left(), + conditions=relevant_entries[-1].plan_generated.conditions) p.visits = [v for v in reversed(all_generated)] return p diff --git a/scheduler/core/plans/plan.py b/scheduler/core/plans/plan.py index 73cdecd6..2bdc6f07 100644 --- a/scheduler/core/plans/plan.py +++ b/scheduler/core/plans/plan.py @@ -6,7 +6,7 @@ from typing import final, List, Optional, Tuple from lucupy.observatory.abstract import ObservatoryProperties -from lucupy.minimodel import Observation, ObservationID, Site +from lucupy.minimodel import Observation, ObservationID, Site, VariantSnapshot from lucupy.timeutils import time2slots from .nightstats import NightStats @@ -31,12 +31,14 @@ class Plan: time_slot_length: timedelta site: Site _time_slots_left: int + conditions: VariantSnapshot visits: List[Visit] = field(init=False, default_factory=list) is_full: bool = field(init=False, default=False) night_stats: Optional[NightStats] = field(init=False, default=None) alt_degs: List[List[float]] = field(init=False, default_factory=list) + def nir_slots(self, science_obs: List[Observation], n_slots_filled: int, @@ -115,7 +117,7 @@ def get_slice(self, start: Optional[int] = None, stop: Optional[int] = None) -> else: visits_by_timeslot = {v.start_time_slot: v for v in self.visits} visits_timeslots = [v.start_time_slot for v in self.visits] - plan = Plan(self.start, self.end, self.time_slot_length, self.site, self._time_slots_left) + plan = Plan(self.start, self.end, self.time_slot_length, self.site, self._time_slots_left, self.conditions) start = start or 0 stop = stop or visits_timeslots[-1] diff --git a/scheduler/core/plans/plans.py b/scheduler/core/plans/plans.py index f910c5f0..b6f9933e 100644 --- a/scheduler/core/plans/plans.py +++ b/scheduler/core/plans/plans.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field, InitVar from typing import final, Dict, Mapping -from lucupy.minimodel import NightIndex, Site +from lucupy.minimodel import NightIndex, Site, VariantSnapshot from .plan import Plan from scheduler.core.calculations.nightevents import NightEvents @@ -21,6 +21,7 @@ class Plans: A collection of Plan for all sites for a specific night. """ night_events: InitVar[Mapping[Site, NightEvents]] + night_conditions: Dict[Site, VariantSnapshot] night_idx: NightIndex plans: Dict[Site, Plan] = field(init=False, default_factory=dict) @@ -32,7 +33,8 @@ def __post_init__(self, night_events: Mapping[Site, NightEvents]): ne.local_times[self.night_idx][-1], ne.time_slot_length.to_datetime(), site, - len(ne.times[self.night_idx])) + len(ne.times[self.night_idx]), + self.night_conditions[site]) def __getitem__(self, site: Site) -> Plan: return self.plans[site] diff --git a/scheduler/engine/engine.py b/scheduler/engine/engine.py index 4f52b36c..2afd831a 100644 --- a/scheduler/engine/engine.py +++ b/scheduler/engine/engine.py @@ -286,6 +286,10 @@ def setup(self, scp: SCP) -> Dict[Site, Dict[NightIndex, Optional[VariantSnapsho # morn_twi_slot = time2slots(time_slot_length, morn_twi_time - eve_twi_time) morn_twi_slot = night_events.num_timeslots_per_night[night_idx] + # Get initial conditions for the nights + initial_variants[site][night_idx] = scp.collector.sources.origin.env.get_initial_conditions(site, + night_date) + # Get the weather events for the site for the given night date. # Get the VariantSnapshots for the times of the night where the variant changes. variant_changes_dict = scp.collector.sources.origin.env.get_variant_changes_for_night(site, night_date) @@ -296,7 +300,6 @@ def setup(self, scp: SCP) -> Dict[Site, Dict[NightIndex, Optional[VariantSnapsho # The closer to the first time slot, the more accurate, and the ordering on them will overwrite # the previous values. if variant_timeslot <= 0: - initial_variants[site][night_idx] = variant_snapshot continue if variant_timeslot >= morn_twi_slot: diff --git a/scheduler/graphql_mid/types.py b/scheduler/graphql_mid/types.py index 44eaef92..db4de752 100644 --- a/scheduler/graphql_mid/types.py +++ b/scheduler/graphql_mid/types.py @@ -41,6 +41,16 @@ def from_computed_night_stats(ns: NightStats) -> 'SNightStats': program_completion=pc) +@strawberry.type +class SConditions: + iq: str + cc: str + + @staticmethod + def from_computed_conditions(variant: VariantSnapshot): + return SConditions(iq=variant.iq.name, cc=variant.cc.name) + + @strawberry.type class SVisit: """ @@ -85,6 +95,7 @@ class SPlan: end_time: datetime visits: List[SVisit] night_stats: SNightStats + night_conditions: SConditions @staticmethod def from_computed_plan(plan: Plan) -> 'SPlan': @@ -94,7 +105,8 @@ def from_computed_plan(plan: Plan) -> 'SPlan': start_time=plan.start.astimezone(utc), end_time=plan.end.astimezone(utc), visits=[SVisit.from_computed_visit(visit, alt) for visit, alt in zip(plan.visits, plan.alt_degs)], - night_stats=SNightStats.from_computed_night_stats(plan.night_stats) + night_stats=SNightStats.from_computed_night_stats(plan.night_stats), + night_conditions=SConditions.from_computed_conditions(plan.conditions) ) @@ -169,7 +181,6 @@ def from_computed_timelines(timeline: NightlyTimeline) -> 'SNightTimelines': timelines.append(sn) return SNightTimelines(night_timeline=timelines) - @strawberry.type class NewNightPlans: night_plans: SNightTimelines diff --git a/scheduler/pickles/ocsenv.pickle b/scheduler/pickles/ocsenv.pickle index 2e68628c..bfa101a8 100644 Binary files a/scheduler/pickles/ocsenv.pickle and b/scheduler/pickles/ocsenv.pickle differ diff --git a/scheduler/scripts/run_main.py b/scheduler/scripts/run_main.py index 86de49ba..21845f10 100644 --- a/scheduler/scripts/run_main.py +++ b/scheduler/scripts/run_main.py @@ -141,6 +141,9 @@ def main(*, # morn_twi_slot = time2slots(time_slot_length, morn_twi_time - eve_twi_time) morn_twi_slot = night_events.num_timeslots_per_night[night_idx] + # Get initial conditions for the nights + initial_variants[site][night_idx] = collector.sources.origin.env.get_initial_conditions(site, night_date) + # Get the weather events for the site for the given night date. # Get the VariantSnapshots for the times of the night where the variant changes. variant_changes_dict = collector.sources.origin.env.get_variant_changes_for_night(site, night_date) @@ -151,7 +154,6 @@ def main(*, # The closer to the first time slot, the more accurate, and the ordering on them will overwrite # the previous values. if variant_timeslot <= 0: - initial_variants[site][night_idx] = variant_snapshot continue if variant_timeslot >= morn_twi_slot: @@ -384,7 +386,8 @@ def main(*, # Piece together the plans for the night to get the overall plans. # This is rather convoluted because of the confusing relationship between Plan, Plans, and NightlyTimeline. night_events = {site: collector.get_night_events(site) for site in collector.sites} - final_plans = Plans(night_events, NightIndex(night_idx)) + night_conditions = {site: initial_variants[site][night_idx] for site in collector.sites} + final_plans = Plans(night_events, night_conditions, NightIndex(night_idx)) for site in collector.sites: calculated_plan = nightly_timeline.get_final_plan(NightIndex(night_idx), site) if calculated_plan is not None: diff --git a/scheduler/services/environment/data/validation/gn_initial_conditions.csv b/scheduler/services/environment/data/validation/gn_initial_conditions.csv new file mode 100644 index 00000000..3824f03c --- /dev/null +++ b/scheduler/services/environment/data/validation/gn_initial_conditions.csv @@ -0,0 +1,367 @@ +HST,UT,IQ,CC,WV,Notes +2018-01-31,2018-02-01,Any,Any,,closed for winds initially +2018-02-01,2018-02-02,na,na,, +2018-02-02,2018-02-03,na,na,, +2018-02-03,2018-02-04,na,na,, +2018-02-04,2018-02-05,na,na,, +2018-02-05,2018-02-06,na,na,, +2018-02-06,2018-02-07,na,na,, +2018-02-07,2018-02-08,na,na,, +2018-02-08,2018-02-09,Any,50,, +2018-02-09,2018-02-10,Any,50,, +2018-02-10,2018-02-11,70,50,,WL and Eng for start of the night +2018-02-11,2018-02-12,20,50,50, +2018-02-12,2018-02-13,20,50,80, +2018-02-13,2018-02-14,Any,Any,,WL most of night +2018-02-14,2018-02-15,na,na,, +2018-02-15,2018-02-16,na,na,, +2018-02-16,2018-02-17,85,50,, +2018-02-17,2018-02-18,85,50,,closed initially +2018-02-18,2018-02-19,na,na,, +2018-02-19,2018-02-20,na,na,, +2018-02-20,2018-02-21,na,na,, +2018-02-21,2018-02-22,na,na,, +2018-02-22,2018-02-23,na,na,, +2018-02-23,2018-02-24,na,na,, +2018-02-24,2018-02-25,na,na,, +2018-02-25,2018-02-26,na,na,, +2018-02-26,2018-02-27,na,na,, +2018-02-27,2018-02-28,70,80,Any, +2018-02-28,2018-03-01,na,na,, +2018-03-01,2018-03-02,85,Any,, +2018-03-02,2018-03-03,85,Any,, +2018-03-03,2018-03-04,Any,Any,,closed initially +2018-03-04,2018-03-05,85,Any,, +2018-03-05,2018-03-06,85,50,, +2018-03-06,2018-03-07,85,50,, +2018-03-07,2018-03-08,na,na,, +2018-03-08,2018-03-09,na,na,, +2018-03-09,2018-03-10,na,na,, +2018-03-10,2018-03-11,na,na,, +2018-03-11,2018-03-12,na,na,, +2018-03-12,2018-03-13,na,na,, +2018-03-13,2018-03-14,na,na,, +2018-03-14,2018-03-15,85,80,, +2018-03-15,2018-03-16,na,na,, +2018-03-16,2018-03-17,85,50,,closed initially +2018-03-17,2018-03-18,70,50,,closed initially +2018-03-18,2018-03-19,Any,70,, +2018-03-19,2018-03-20,na,na,,closed initially +2018-03-20,2018-03-21,na,na,,closed initially +2018-03-21,2018-03-22,85,80,,closed initially +2018-03-22,2018-03-23,na,na,, +2018-03-23,2018-03-24,na,na,, +2018-03-24,2018-03-25,na,na,, +2018-03-25,2018-03-26,na,na,, +2018-03-26,2018-03-27,na,na,, +2018-03-27,2018-03-28,na,na,, +2018-03-28,2018-03-29,70,50,80, +2018-03-29,2018-03-30,70,50,50, +2018-03-30,2018-03-31,70,50,, +2018-03-31,2018-04-01,80,85,, +2018-04-01,2018-04-02,85,Any,, +2018-04-02,2018-04-03,na,na,, +2018-04-03,2018-04-04,na,na,, +2018-04-04,2018-04-05,na,na,, +2018-04-05,2018-04-06,na,na,, +2018-04-06,2018-04-07,na,na,, +2018-04-07,2018-04-08,na,na,, +2018-04-08,2018-04-09,na,na,, +2018-04-09,2018-04-10,na,na,, +2018-04-10,2018-04-11,70,50,, +2018-04-11,2018-04-12,na,na,, +2018-04-12,2018-04-13,70,50,, +2018-04-13,2018-04-14,na,na,, +2018-04-14,2018-04-15,na,na,, +2018-04-15,2018-04-16,na,na,, +2018-04-16,2018-04-17,85,80,,closed initially +2018-04-17,2018-04-18,70,80,, +2018-04-18,2018-04-19,85,Any,,closed initally +2018-04-19,2018-04-20,na,na,, +2018-04-20,2018-04-21,85,Any,,closed initially +2018-04-21,2018-04-22,Any,Any,, +2018-04-22,2018-04-23,85,80,, +2018-04-23,2018-04-24,70,50,, +2018-04-24,2018-04-25,85,50,, +2018-04-25,2018-04-26,85,80,, +2018-04-26,2018-04-27,70,80,, +2018-04-27,2018-04-28,na,na,, +2018-04-28,2018-04-29,na,na,, +2018-04-29,2018-04-30,na,na,, +2018-04-30,2018-05-01,na,na,, +2018-05-01,2018-05-02,na,na,, +2018-05-02,2018-05-03,na,na,, +2018-05-03,2018-05-04,85,70,,closed initially +2018-05-04,2018-05-05,85,70,, +2018-05-05,2018-05-06,85,80,, +2018-05-06,2018-05-07,85,80,, +2018-05-07,2018-05-08,Any,Any,,closed initially +2018-05-08,2018-05-09,Any,Any,, +2018-05-09,2018-05-10,70,70,, +2018-05-10,2018-05-11,70,70,, +2018-05-11,2018-05-12,70,80,, +2018-05-12,2018-05-13,70,50,, +2018-05-13,2018-05-14,70,70,, +2018-05-14,2018-05-15,70,50,, +2018-05-15,2018-05-16,70,70,, +2018-05-16,2018-05-17,70,70,, +2018-05-17,2018-05-18,70,70,, +2018-05-18,2018-05-19,70,50,, +2018-05-19,2018-05-20,70,50,, +2018-05-20,2018-05-21,70,50,, +2018-05-21,2018-05-22,70,80,, +2018-05-22,2018-05-23,70,70,80, +2018-05-23,2018-05-24,70,80,, +2018-05-24,2018-05-25,70,80,, +2018-05-25,2018-05-26,70,70,Any, +2018-05-26,2018-05-27,70,70,, +2018-05-27,2018-05-28,Any,Any,,closed initially +2018-05-28,2018-05-29,Any,Any,,weather loss +2018-05-29,2018-05-30,na,na,, +2018-05-30,2018-05-31,70,50,, +2018-05-31,2018-06-01,70,80,, +2018-06-01,2018-06-02,70,70,, +2018-06-02,2018-06-03,70,50,, +2018-06-03,2018-06-04,70,70,, +2018-06-04,2018-06-05,85,70,80, +2018-06-05,2018-06-06,85,50,, +2018-06-06,2018-06-07,70,80,, +2018-06-07,2018-06-08,85,50,,closed initially +2018-06-08,2018-06-09,na,na,, +2018-06-09,2018-06-10,85,50,, +2018-06-10,2018-06-11,Any,50,, +2018-06-11,2018-06-12,70,50,80, +2018-06-12,2018-06-13,70,50,, +2018-06-13,2018-06-14,70,70,, +2018-06-14,2018-06-15,70,50,, +2018-06-15,2018-06-16,70,70,, +2018-06-16,2018-06-17,70,80,, +2018-06-17,2018-06-18,20,70,, +2018-06-18,2018-06-19,na,na,, +2018-06-19,2018-06-20,na,na,, +2018-06-20,2018-06-21,20,50,, +2018-06-21,2018-06-22,20,50,, +2018-06-22,2018-06-23,70,50,, +2018-06-23,2018-06-24,85,50,50, +2018-06-24,2018-06-25,70,50,, +2018-06-25,2018-06-26,85,50,50, +2018-06-26,2018-06-27,85,50,, +2018-06-27,2018-06-28,85,50,, +2018-06-28,2018-06-29,85,50,, +2018-06-29,2018-06-30,70,70,Any, +2018-06-30,2018-07-01,70,70,, +2018-07-01,2018-07-02,Any,Any,,closed initially +2018-07-02,2018-07-03,na,na,, +2018-07-03,2018-07-04,70,50,, +2018-07-04,2018-07-05,70,80,, +2018-07-05,2018-07-06,20,80,Any, +2018-07-06,2018-07-07,Any,50,80,closed initially +2018-07-07,2018-07-08,85,50,, +2018-07-08,2018-07-09,85,50,,closed initially +2018-07-09,2018-07-10,Any,80,50, +2018-07-10,2018-07-11,20,80,, +2018-07-11,2018-07-12,70,70,80, +2018-07-12,2018-07-13,20,80,, +2018-07-13,2018-07-14,85,80,, +2018-07-14,2018-07-15,85,80,,closed initially +2018-07-15,2018-07-16,70,80,, +2018-07-16,2018-07-17,85,70,50, +2018-07-17,2018-07-18,70,70,,closed initially +2018-07-18,2018-07-19,85,70,, +2018-07-19,2018-07-20,70,80,, +2018-07-20,2018-07-21,85,80,,closed initially +2018-07-21,2018-07-22,20,50,, +2018-07-22,2018-07-23,70,50,, +2018-07-23,2018-07-24,70,70,, +2018-07-24,2018-07-25,85,70,, +2018-07-25,2018-07-26,70,50,, +2018-07-26,2018-07-27,na,na,, +2018-07-27,2018-07-28,70,70,, +2018-07-28,2018-07-29,70,50,, +2018-07-29,2018-07-30,70,80,, +2018-07-30,2018-07-31,70,70,, +2018-07-31,2018-08-01,85,70,Any, +2018-08-01,2018-08-02,70,50,, +2018-08-02,2018-08-03,70,70,, +2018-08-03,2018-08-04,85,80,, +2018-08-04,2018-08-05,70,70,, +2018-08-05,2018-08-06,70,50,, +2018-08-06,2018-08-07,70,50,, +2018-08-07,2018-08-08,85,70,, +2018-08-08,2018-08-09,na,na,, +2018-08-09,2018-08-10,85,80,,closed initially +2018-08-10,2018-08-11,20,70,, +2018-08-11,2018-08-12,Any,50,, +2018-08-12,2018-08-13,85,50,Any, +2018-08-13,2018-08-14,85,70,, +2018-08-14,2018-08-15,na,na,, +2018-08-15,2018-08-16,70,70,,closed initially +2018-08-16,2018-08-17,20,70,, +2018-08-17,2018-08-18,70,50,, +2018-08-18,2018-08-19,na,na,, +2018-08-19,2018-08-20,Any,Any,,closed initially +2018-08-20,2018-08-21,85,70,Any, +2018-08-21,2018-08-22,70,70,80, +2018-08-22,2018-08-23,na,na,, +2018-08-23,2018-08-24,na,na,, +2018-08-24,2018-08-25,na,na,, +2018-08-25,2018-08-26,na,na,, +2018-08-26,2018-08-27,na,na,, +2018-08-27,2018-08-28,na,na,, +2018-08-28,2018-08-29,na,na,, +2018-08-29,2018-08-30,70,70,, +2018-08-30,2018-08-31,20,50,, +2018-08-31,2018-09-01,70,50,, +2018-09-01,2018-09-02,20,50,, +2018-09-02,2018-09-03,85,50,, +2018-09-03,2018-09-04,na,na,, +2018-09-04,2018-09-05,70,50,, +2018-09-05,2018-09-06,70,50,, +2018-09-06,2018-09-07,70,50,,closed initially +2018-09-07,2018-09-08,70,50,,closed initially +2018-09-08,2018-09-09,70,50,,closed initially +2018-09-09,2018-09-10,20,50,, +2018-09-10,2018-09-11,70,70,, +2018-09-11,2018-09-12,70,50,, +2018-09-12,2018-09-13,na,na,, +2018-09-13,2018-09-14,85,80,,closed initially +2018-09-14,2018-09-15,20,70,, +2018-09-15,2018-09-16,70,70,, +2018-09-16,2018-09-17,70,70,, +2018-09-17,2018-09-18,na,na,, +2018-09-18,2018-09-19,na,na,, +2018-09-19,2018-09-20,na,na,, +2018-09-20,2018-09-21,na,na,, +2018-09-21,2018-09-22,na,na,, +2018-09-22,2018-09-23,na,na,, +2018-09-23,2018-09-24,na,na,, +2018-09-24,2018-09-25,na,na,, +2018-09-25,2018-09-26,na,na,, +2018-09-26,2018-09-27,na,na,, +2018-09-27,2018-09-28,na,na,, +2018-09-28,2018-09-29,na,na,, +2018-09-29,2018-09-30,na,na,, +2018-09-30,2018-10-01,70,70,,eng initially +2018-10-01,2018-10-02,70,70,,eng initially +2018-10-02,2018-10-03,70,50,,eng initially +2018-10-03,2018-10-04,na,na,,eng only +2018-10-04,2018-10-05,Any,Any,Any,eng initially +2018-10-05,2018-10-06,na,na,,eng only +2018-10-06,2018-10-07,na,na,,weather +2018-10-07,2018-10-08,na,na,,weather +2018-10-08,2018-10-09,na,na,,weather +2018-10-09,2018-10-10,Any,Any,Any, +2018-10-10,2018-10-11,70,50,Any, +2018-10-11,2018-10-12,70,70,Any, +2018-10-12,2018-10-13,na,na,, +2018-10-13,2018-10-14,na,na,, +2018-10-14,2018-10-15,70,70,, +2018-10-15,2018-10-16,Any,Any,, +2018-10-16,2018-10-17,85,70,, +2018-10-17,2018-10-18,70,Any,, +2018-10-18,2018-10-19,na,na,, +2018-10-19,2018-10-20,na,na,, +2018-10-20,2018-10-21,na,na,, +2018-10-21,2018-10-22,70,50,80, +2018-10-22,2018-10-23,20,50,, +2018-10-23,2018-10-24,20,50,, +2018-10-24,2018-10-25,70,50,, +2018-10-25,2018-10-26,70,50,, +2018-10-26,2018-10-27,20,70,, +2018-10-27,2018-10-28,85,Any,, +2018-10-28,2018-10-29,Any,Any,, +2018-10-29,2018-10-30,na,na,, +2018-10-30,2018-10-31,na,na,, +2018-10-31,2018-11-01,85,80,, +2018-11-01,2018-11-02,85,50,80, +2018-11-02,2018-11-03,85,50,80, +2018-11-03,2018-11-04,85,70,,closed initially +2018-11-04,2018-11-05,70,50,, +2018-11-05,2018-11-06,85,50,80, +2018-11-06,2018-11-07,Any,Any,,closed initially +2018-11-07,2018-11-08,85,70,80, +2018-11-08,2018-11-09,85,70,, +2018-11-09,2018-11-10,85,70,80, +2018-11-10,2018-11-11,Any,Any,,closed intially +2018-11-11,2018-11-12,70,50,, +2018-11-12,2018-11-13,85,50,, +2018-11-13,2018-11-14,70,50,, +2018-11-14,2018-11-15,85,80,, +2018-11-15,2018-11-16,70,Any,, +2018-11-16,2018-11-17,70,Any,,closed initially +2018-11-17,2018-11-18,85,80,, +2018-11-18,2018-11-19,na,na,, +2018-11-19,2018-11-20,20,50,50, +2018-11-20,2018-11-21,70,50,, +2018-11-21,2018-11-22,20,50,80, +2018-11-22,2018-11-23,20,70,, +2018-11-23,2018-11-24,70,80,, +2018-11-24,2018-11-25,70,50,, +2018-11-25,2018-11-26,70,70,80, +2018-11-26,2018-11-27,70,70,80,eng initially +2018-11-27,2018-11-28,85,50,, +2018-11-28,2018-11-29,70,50,,eng initially +2018-11-29,2018-11-30,70,50,, +2018-11-30,2018-12-01,70,50,, +2018-12-01,2018-12-02,70,50,, +2018-12-02,2018-12-03,20,50,, +2018-12-03,2018-12-04,20,50,, +2018-12-04,2018-12-05,Any,50,, +2018-12-05,2018-12-06,70,50,,eng initially +2018-12-06,2018-12-07,85,50,, +2018-12-07,2018-12-08,70,50,, +2018-12-08,2018-12-09,70,50,, +2018-12-09,2018-12-10,70,50,, +2018-12-10,2018-12-11,Any,80,, +2018-12-11,2018-12-12,Any,50,,eng initially +2018-12-12,2018-12-13,85,50,,eng initially +2018-12-13,2018-12-14,70,50,, +2018-12-14,2018-12-15,85,50,80,eng initially +2018-12-15,2018-12-16,85,50,, +2018-12-16,2018-12-17,85,50,, +2018-12-17,2018-12-18,85,Any,,closed initially +2018-12-18,2018-12-19,85,50,,eng initially +2018-12-19,2018-12-20,85,50,, +2018-12-20,2018-12-21,85,50,20, +2018-12-21,2018-12-22,70,50,80, +2018-12-22,2018-12-23,85,50,50, +2018-12-23,2018-12-24,70,50,20, +2018-12-24,2018-12-25,70,50,, +2018-12-25,2018-12-26,na,na,, +2018-12-26,2018-12-27,na,na,, +2018-12-27,2018-12-28,na,na,, +2018-12-28,2018-12-29,na,na,, +2018-12-29,2018-12-30,Any,Any,,closed initially +2018-12-30,2018-12-31,85,50,80, +2018-12-31,2019-01-01,Any,50,, +2019-01-01,2019-01-02,85,50,, +2019-01-02,2019-01-03,85,50,50, +2019-01-03,2019-01-04,70,50,20, +2019-01-04,2019-01-05,70,50,, +2019-01-05,2019-01-06,85,50,, +2019-01-06,2019-01-07,85,50,, +2019-01-07,2019-01-08,20,50,, +2019-01-08,2019-01-09,20,50,, +2019-01-09,2019-01-10,20,50,, +2019-01-10,2019-01-11,70,50,, +2019-01-11,2019-01-12,20,50,, +2019-01-12,2019-01-13,20,50,, +2019-01-13,2019-01-14,20,50,, +2019-01-14,2019-01-15,20,50,20, +2019-01-15,2019-01-16,20,50,, +2019-01-16,2019-01-17,70,50,, +2019-01-17,2019-01-18,85,50,, +2019-01-18,2019-01-19,85,80,,closed initially +2019-01-19,2019-01-20,70,50,, +2019-01-20,2019-01-21,70,50,50, +2019-01-21,2019-01-22,70,70,80, +2019-01-22,2019-01-23,70,50,80, +2019-01-23,2019-01-24,70,50,Any, +2019-01-24,2019-01-25,70,50,, +2019-01-25,2019-01-26,na,na,, +2019-01-26,2019-01-27,20,50,, +2019-01-27,2019-01-28,na,na,, +2019-01-28,2019-01-29,na,na,, +2019-01-29,2019-01-30,na,na,, +2019-01-30,2019-01-31,na,na,, +2019-01-31,2019-02-01,Any,50,,closed initially \ No newline at end of file diff --git a/scheduler/services/environment/data/validation/gs_initial_conditions.csv b/scheduler/services/environment/data/validation/gs_initial_conditions.csv new file mode 100644 index 00000000..da9728b9 --- /dev/null +++ b/scheduler/services/environment/data/validation/gs_initial_conditions.csv @@ -0,0 +1,334 @@ +CST,UT,IQ,CC,WV,Notes +2018-01-31,2018-02-01,na,50,, +2018-02-01,2018-02-02,70,50,, +2018-02-02,2018-02-03,70,na,, +2018-02-03,2018-02-04,na,na,, +2018-02-04,2018-02-05,na,70,, +2018-02-05,2018-02-06,na,ANY,, +2018-02-06,2018-02-07,na,na,, +2018-02-07,2018-02-08,na,na,, +2018-02-08,2018-02-09,na,50,, +2018-02-09,2018-02-10,na,na,, +2018-02-10,2018-02-11,na,na,, +2018-02-11,2018-02-12,na,na,, +2018-02-12,2018-02-13,na,na,, +2018-02-13,2018-02-14,na,na,, +2018-02-14,2018-02-15,na,50,, +2018-02-15,2018-02-16,na,50,, +2018-02-16,2018-02-17,na,50,, +2018-02-17,2018-02-18,na,na,, +2018-02-18,2018-02-19,na,80,, +2018-02-19,2018-02-20,na,50,, +2018-02-20,2018-02-21,na,na,, +2018-02-21,2018-02-22,na,na,, +2018-02-22,2018-02-23,na,na,, +2018-02-23,2018-02-24,na,50,, +2018-02-24,2018-02-25,85,na,, +2018-02-25,2018-02-26,na,na,, +2018-02-26,2018-02-27,na,50,, +2018-02-27,2018-02-28,na,ANY,, +2018-02-28,2018-03-01,na,na,, +2018-03-01,2018-03-02,70,50,, +2018-03-02,2018-03-03,70,50,, +2018-03-03,2018-03-04,85,50,, +2018-03-04,2018-03-05,na,na,, +2018-03-05,2018-03-06,70,50,, +2018-03-06,2018-03-07,85,80,, +2018-03-07,2018-03-08,85,50,, +2018-03-08,2018-03-09,70,50,, +2018-03-09,2018-03-10,70,50,, +2018-03-10,2018-03-11,70,50,, +2018-03-11,2018-03-12,70,50,, +2018-03-12,2018-03-13,ANY,na,, +2018-03-13,2018-03-14,na,na,, +2018-03-14,2018-03-15,na,na,, +2018-03-15,2018-03-16,na,na,, +2018-03-16,2018-03-17,85,na,, +2018-03-17,2018-03-18,ANY,50,, +2018-03-18,2018-03-19,60,50,, +2018-03-19,2018-03-20,85,50,, +2018-03-20,2018-03-21,70,50,, +2018-03-21,2018-03-22,70,na,, +2018-03-22,2018-03-23,70,na,, +2018-03-23,2018-03-24,na,50,, +2018-03-24,2018-03-25,ANY,50,, +2018-03-25,2018-03-26,na,na,, +2018-03-26,2018-03-27,na,na,, +2018-03-27,2018-03-28,70,na,, +2018-03-28,2018-03-29,70,50,, +2018-03-29,2018-03-30,70,50,, +2018-03-30,2018-03-31,70,na,, +2018-03-31,2018-04-01,na,na,, +2018-04-01,2018-04-02,na,na,, +2018-04-02,2018-04-03,na,na,, +2018-04-03,2018-04-04,na,50,, +2018-04-04,2018-04-05,na,na,, +2018-04-05,2018-04-06,na,na,, +2018-04-06,2018-04-07,ANY,na,, +2018-04-07,2018-04-08,na,na,, +2018-04-08,2018-04-09,na,na,, +2018-04-09,2018-04-10,na,na,, +2018-04-10,2018-04-11,na,na,, +2018-04-11,2018-04-12,na,50,, +2018-04-12,2018-04-13,85,na,, +2018-04-13,2018-04-14,na,na,, +2018-04-14,2018-04-15,na,na,, +2018-04-15,2018-04-16,na,na,, +2018-04-16,2018-04-17,70,na,, +2018-04-17,2018-04-18,ANY,80,, +2018-04-18,2018-04-19,na,na,, +2018-04-19,2018-04-20,na,na,, +2018-04-20,2018-04-21,70,na,, +2018-04-21,2018-04-22,na,na,, +2018-04-22,2018-04-23,na,na,, +2018-04-23,2018-04-24,na,70,, +2018-04-24,2018-04-25,70,80,, +2018-04-25,2018-04-26,na,ANY,, +2018-04-26,2018-04-27,70,50,, +2018-04-27,2018-04-28,na,na,, +2018-04-28,2018-04-29,na,50,, +2018-04-29,2018-04-30,na,na,, +2018-04-30,2018-05-01,na,ANY,, +2018-05-01,2018-05-02,na,ANY,, +2018-05-02,2018-05-03,na,na,, +2018-05-03,2018-05-04,na,na,, +2018-05-04,2018-05-05,na,na,, +2018-05-05,2018-05-06,na,na,, +2018-05-06,2018-05-07,na,80,, +2018-05-07,2018-05-08,ANY,na,, +2018-05-08,2018-05-09,na,na,, +2018-05-09,2018-05-10,na,na,, +2018-05-10,2018-05-11,85,80,, +2018-05-11,2018-05-12,na,50,, +2018-05-12,2018-05-13,na,50,, +2018-05-13,2018-05-14,na,ANY,, +2018-05-14,2018-05-15,na,80,, +2018-05-15,2018-05-16,na,50,, +2018-05-16,2018-05-17,20,50,, +2018-05-17,2018-05-18,na,na,, +2018-05-18,2018-05-19,na,ANY,, +2018-05-19,2018-05-20,70,70,, +2018-05-20,2018-05-21,70,70,, +2018-05-21,2018-05-22,70,70,, +2018-05-22,2018-05-23,na,na,, +2018-05-23,2018-05-24,na,na,, +2018-05-24,2018-05-25,na,na,, +2018-05-25,2018-05-26,na,na,, +2018-05-26,2018-05-27,na,80,, +2018-05-27,2018-05-28,na,na,, +2018-05-28,2018-05-29,na,na,, +2018-05-29,2018-05-30,na,na,, +2018-05-30,2018-05-31,na,na,, +2018-05-31,2018-06-01,na,80,, +2018-06-01,2018-06-02,ANY,50,, +2018-06-02,2018-06-03,85,50,, +2018-06-03,2018-06-04,ANY,50,, +2018-06-04,2018-06-05,ANY,80,, +2018-06-05,2018-06-06,ANY,50,, +2018-06-06,2018-06-07,ANY,ANY,, +2018-06-07,2018-06-08,70,50,, +2018-06-08,2018-06-09,70,50,, +2018-06-09,2018-06-10,ANY,ANY,, +2018-06-10,2018-06-11,ANY,ANY,, +2018-06-11,2018-06-12,ANY,ANY,, +2018-06-12,2018-06-13,ANY,ANY,, +2018-06-13,2018-06-14,ANY,ANY,, +2018-06-14,2018-06-15,70,70,, +2018-06-15,2018-06-16,85,ANY,, +2018-06-16,2018-06-17,85,50,, +2018-06-17,2018-06-18,70,50,, +2018-06-18,2018-06-19,70,50,, +2018-06-19,2018-06-20,70,70,, +2018-06-20,2018-06-21,70,70,, +2018-06-21,2018-06-22,na,80,, +2018-06-22,2018-06-23,na,70,, +2018-06-23,2018-06-24,ANY,70,, +2018-06-24,2018-06-25,ANY,50,, +2018-06-25,2018-06-26,85,50,, +2018-06-26,2018-06-27,70,50,, +2018-06-27,2018-06-28,70,50,, +2018-06-28,2018-06-29,ANY,50,, +2018-06-29,2018-06-30,ANY,ANY,, +2018-06-30,2018-07-01,ANY ,80,, +2018-07-01,2018-07-02,ANY,ANY,, +2018-07-02,2018-07-03,ANY,ANY,, +2018-07-03,2018-07-04,ANY,ANY,, +2018-07-04,2018-07-05,ANY,ANY,, +2018-07-05,2018-07-06,ANY,50,, +2018-07-06,2018-07-07,ANY,50,, +2018-07-07,2018-07-08,85,50,, +2018-07-08,2018-07-09,85,50,, +2018-07-09,2018-07-10,20,50,, +2018-07-10,2018-07-11,85,70,, +2018-07-11,2018-07-12,70,50,, +2018-07-12,2018-07-13,70,70,, +2018-07-13,2018-07-14,70,50,, +2018-07-14,2018-07-15,70,50,, +2018-07-15,2018-07-16,ANY,ANY,, +2018-07-16,2018-07-17,70,50,, +2018-07-17,2018-07-18,ANY,ANY,, +2018-07-18,2018-07-19,ANY,ANY,, +2018-07-19,2018-07-20,ANY,ANY,, +2018-07-20,2018-07-21,20,50,, +2018-07-21,2018-07-22,ANY,ANY,, +2018-07-22,2018-07-23,ANY,80,, +2018-07-23,2018-07-24,ANY,80,, +2018-07-24,2018-07-25,85,50,, +2018-07-25,2018-07-26,ANY,50,, +2018-07-26,2018-07-27,ANY,ANY,, +2018-07-27,2018-07-28,ANY,ANY,, +2018-07-28,2018-07-29,ANY,ANY,, +2018-07-29,2018-07-30,85,80,, +2018-07-30,2018-07-31,85,70,, +2018-07-31,2018-08-01,85,80,, +2018-08-01,2018-08-02,ANY,50, +2018-08-02,2018-08-03,ANY,ANY, +2018-08-03,2018-08-04,85,50, +2018-08-04,2018-08-05,70,50, +2018-08-05,2018-08-06,ANY,ANY, +2018-08-06,2018-08-07,ANY,50, +2018-08-07,2018-08-08,70,50, +2018-08-08,2018-08-09,85,70, +2018-08-09,2018-08-10,70,50, +2018-08-10,2018-08-11,70,50, +2018-08-11,2018-08-12,70,50, +2018-08-12,2018-08-13,ANY,ANY, +2018-08-13,2018-08-14,85,80, +2018-08-14,2018-08-15,70,50, +2018-08-15,2018-08-16,70,50, +2018-08-16,2018-08-17,70,50, +2018-08-17,2018-08-18,ANY,50, +2018-08-18,2018-08-19,ANY,80, +2018-08-19,2018-08-20,na,na,SHUTDOWN +2018-08-20,2018-08-21,na,na,SHUTDOWN +2018-08-21,2018-08-22,na,na,SHUTDOWN +2018-08-22,2018-08-23,na,na,SHUTDOWN +2018-08-23,2018-08-24,na,na,SHUTDOWN +2018-08-24,2018-08-25,na,na,SHUTDOWN +2018-08-25,2018-08-26,na,na,SHUTDOWN +2018-08-26,2018-08-27,na,na,SHUTDOWN +2018-08-27,2018-08-28,na,na,SHUTDOWN +2018-08-28,2018-08-29,na,na,SHUTDOWN +2018-08-29,2018-08-30,na,na,SHUTDOWN +2018-08-30,2018-08-31,na,na,SHUTDOWN +2018-08-31,2018-09-01,ANY,ANY, +2018-09-01,2018-09-02,70,50, +2018-09-02,2018-09-03,70,50, +2018-09-03,2018-09-04,70,50, +2018-09-04,2018-09-05,20,50, +2018-09-05,2018-09-06,70,50, +2018-09-06,2018-09-07,20,50, +2018-09-07,2018-09-08,70,50, +2018-09-08,2018-09-09,70,50, +2018-09-09,2018-09-10,70,50, +2018-09-10,2018-09-11,70,70, +2018-09-11,2018-09-12,70,80, +2018-09-12,2018-09-13,85,50, +2018-09-13,2018-09-14,85,50, +2018-09-14,2018-09-15,70,50, +2018-09-15,2018-09-16,70,50, +2018-09-16,2018-09-17,70,50, +2018-09-17,2018-09-18,ANY,ANY, +2018-09-18,2018-09-19,ANY,70, +2018-09-19,2018-09-20,ANY,ANY, +2018-09-20,2018-09-21,70,70, +2018-09-21,2018-09-22,70,50, +2018-09-22,2018-09-23,70,50, +2018-09-23,2018-09-24,70,70, +2018-09-24,2018-09-25,ANY,ANY, +2018-09-25,2018-09-26,ANY,ANY, +2018-09-26,2018-09-27,ANY,ANY, +2018-09-27,2018-09-28,ANY,ANY, +2018-09-28,2018-09-29,85,50, +2018-09-29,2018-09-30,ANY,ANY, +2018-09-30,2018-10-01,ANY,ANY, +2018-10-01,2018-10-02,70,50, +2018-10-02,2018-10-03,70,50, +2018-10-03,2018-10-04,70,80, +2018-10-04,2018-10-05,85,80, +2018-10-05,2018-10-06,85,ANY, +2018-10-06,2018-10-07,70,50, +2018-10-07,2018-10-08,ANY,ANY, +2018-10-08,2018-10-09,ANY,ANY, +2018-10-09,2018-10-10,ANY,ANY, +2018-10-10,2018-10-11,ANY,ANY, +2018-10-11,2018-10-12,ANY,ANY, +2018-10-12,2018-10-13,,, +2018-10-13,2018-10-14,ANY,ANY, +2018-10-14,2018-10-15,70,50, +2018-10-15,2018-10-16,70,50, +2018-10-16,2018-10-17,ANY,50, +2018-10-17,2018-10-18,70,50, +2018-10-18,2018-10-19,85,50, +2018-10-19,2018-10-20,ANY,50, +2018-10-20,2018-10-21,85,ANY, +2018-10-21,2018-10-22,70,50, +2018-10-22,2018-10-23,85,50, +2018-10-23,2018-10-24,ANY,50, +2018-10-24,2018-10-25,70,70, +2018-10-25,2018-10-26,ANY,50, +2018-10-26,2018-10-27,70,70, +2018-10-27,2018-10-28,70,70, +2018-10-28,2018-10-29,ANY,ANY, +2018-10-29,2018-10-30,ANY,ANY, +2018-10-30,2018-10-31,ANY,ANY, +2018-10-31,2018-11-01,85,ANY, +2018-11-01,2018-11-02,20,50, +2018-11-02,2018-11-03,70,50, +2018-11-03,2018-11-04,70,50, +2018-11-04,2018-11-05,20,50, +2018-11-05,2018-11-06,70,50, +2018-11-06,2018-11-07,70,50, +2018-11-07,2018-11-08,20,50, +2018-11-08,2018-11-09,70,50, +2018-11-09,2018-11-10,85,70, +2018-11-10,2018-11-11,ANY,80, +2018-11-11,2018-11-12,ANY,ANY, +2018-11-12,2018-11-13,ANY,ANY, +2018-11-13,2018-11-14,85,50, +2018-11-14,2018-11-15,70,50, +2018-11-15,2018-11-16,20,50, +2018-11-16,2018-11-17,85,50, +2018-11-17,2018-11-18,70,50, +2018-11-18,2018-11-19,70,50, +2018-11-19,2018-11-20,70,50, +2018-11-20,2018-11-21,85,50, +2018-11-21,2018-11-22,70,50, +2018-11-22,2018-11-23,85,50, +2018-11-23,2018-11-24,20,50, +2018-11-24,2018-11-25,70,50, +2018-11-25,2018-11-26,20,50, +2018-11-26,2018-11-27,70,50, +2018-11-27,2018-11-28,70,50, +2018-11-28,2018-11-29,70,50, +2018-11-29,2018-11-30,20,50, +2018-11-30,2018-12-01,70,50, +2018-12-01,2018-12-02,70,50, +2018-12-02,2018-12-03,85,50, +2018-12-03,2018-12-04,85,50, +2018-12-04,2018-12-05,ANY,50, +2018-12-05,2018-12-06,ANY,80, +2018-12-06,2018-12-07,85,50, +2018-12-07,2018-12-08,85,80, +2018-12-08,2018-12-09,70,50, +2018-12-09,2018-12-10,70,50, +2018-12-10,2018-12-11,ANY,50, +2018-12-11,2018-12-12,70,50, +2018-12-12,2018-12-13,85,50, +2018-12-13,2018-12-14,85,50, +2018-12-14,2018-12-15,85,50, +2018-12-15,2018-12-16,85,50, +2018-12-16,2018-12-17,85,50, +2018-12-17,2018-12-18,85,80, +2018-12-18,2018-12-19,85,50, +2018-12-19,2018-12-20,85,50, +2018-12-20,2018-12-21,70,50, +2018-12-21,2018-12-22,70,50, +2018-12-22,2018-12-23,70,50, +2018-12-23,2018-12-24,70,50, +2018-12-24,2018-12-25,20,50, +2018-12-25,2018-12-26,20,50, +2018-12-26,2018-12-27,20,50, +2018-12-27,2018-12-28,70,50, +2018-12-28,2018-12-29,70,70, +2018-12-29,2018-12-30,70,50, \ No newline at end of file diff --git a/scheduler/services/environment/ocs_env_service.py b/scheduler/services/environment/ocs_env_service.py index cde63ecb..eebb6c26 100644 --- a/scheduler/services/environment/ocs_env_service.py +++ b/scheduler/services/environment/ocs_env_service.py @@ -4,7 +4,7 @@ import bz2 from datetime import date, datetime from pathlib import Path -from typing import Dict, Final, FrozenSet +from typing import Dict, Final, FrozenSet, Optional import astropy.units as u import pandas as pd @@ -31,6 +31,11 @@ class OcsEnvService(ExternalService): _wind_speed_col: Final[str] = 'WindSpeed' _wind_dir_col: Final[str] = 'WindDir' + _night_time_col_initial: Final[str] = 'UT' + _cc_col_initial: Final[str] = 'CC' + _iq_col_initial: Final[str] = 'IQ' + _wv_col_initial: Final[str] = 'WV' + def __init__(self, sites: FrozenSet[Site] = ALL_SITES): """ Read in the pickled pandas data from the data files. @@ -41,11 +46,13 @@ def __init__(self, sites: FrozenSet[Site] = ALL_SITES): # The data per site. The pandas data structure is too complicated to fully represent. self._site_data: Dict[Site, pd.DataFrame] = {} + self._initial_conditions: Dict[Site, pd.DataFrame] = {} path = Path(ROOT_DIR) / 'scheduler' / 'services' / 'environment' / 'data' / 'validation' for site in self._sites: site_lc = site.name.lower() input_file_path = path / f'{site_lc}_weather_data.pickle.bz2' + initial_conditions_path = path / f'{site_lc}_initial_conditions.csv' logger.debug(f'Processing weather data for {site.name}...') with bz2.BZ2File(input_file_path, 'rb') as input_file: @@ -53,6 +60,13 @@ def __init__(self, sites: FrozenSet[Site] = ALL_SITES): self._site_data[site] = df logger.debug(f'Weather data for {site.name} read in: {len(self._site_data[site])} rows.') + with open(initial_conditions_path, 'r') as conditions_file: + df = pd.read_csv(conditions_file) + df[OcsEnvService._night_time_col_initial] = pd.to_datetime(df[OcsEnvService._night_time_col_initial], + errors='coerce', format='%Y-%m-%d') + self._initial_conditions[site] = df + + @staticmethod def _convert_to_variant(row) -> (datetime, VariantSnapshot): """ @@ -84,3 +98,23 @@ def get_variant_changes_for_night(self, filtered_df = df[df[OcsEnvService._night_time_stamp_col].dt.date == night_date] variant_list = filtered_df.apply(OcsEnvService._convert_to_variant, axis=1).values.tolist() return {dt: v for dt, v in variant_list} + + def get_initial_conditions(self, + site: Site, + night_date: date) -> Optional[VariantSnapshot]: + + df = self._initial_conditions[site] if site in self._initial_conditions else None + if not df.empty: + + filtered_df = df[df[OcsEnvService._night_time_col_initial].dt.date == night_date] + + df_iq = filtered_df[OcsEnvService._iq_col_initial].iloc[0] + iq = ImageQuality.IQ70 if df_iq == 'na' else (ImageQuality(int(df_iq)/100) if df_iq != 'ANY' else ImageQuality.IQANY) + df_cc = filtered_df[OcsEnvService._cc_col_initial].iloc[0] + cc = CloudCover.CC50 if df_cc == 'na' else (CloudCover(int(df_cc)/100) if df_cc != 'ANY' else CloudCover.CCANY) + + return VariantSnapshot(iq=iq, + cc=cc, + wind_dir=Angle(292, unit=u.deg), + wind_spd=3 * (u.m / u.s)) + return None