diff --git a/notebooks_tsqr/NightLog.ipynb b/notebooks_tsqr/NightLog.ipynb index 064b1f6..abbb8e3 100644 --- a/notebooks_tsqr/NightLog.ipynb +++ b/notebooks_tsqr/NightLog.ipynb @@ -88,8 +88,11 @@ "source": [ "# Normalize Parameters (both explicit Times Squares params, in implicit ones)\n", "limit = 5000 # YAGNI for Auto get more if this isn't enough to get all requested DAYS\n", + "response_timeout = 3.05 # seconds, how long to wait for connection\n", + "read_timeout = 20 # seconds\n", + "timeout = (float(response_timeout), float(read_timeout))\n", "\n", - "date = ut.get_datetime_from_day_obs_str(day_obs)\n", + "date = ut.get_datetime_from_dayobs_str(day_obs)\n", "# date: is EXCLUSIVE (upto, but not including)\n", "days = int(number_of_days)\n", "\n", @@ -98,13 +101,7 @@ "min_date = date - dt.timedelta(days=days - 1)\n", "max_date = date + dt.timedelta(days=1)\n", "min_day_obs = min_date.strftime(\"%Y-%m-%d\") # Inclusive\n", - "max_day_obs = max_date.strftime(\"%Y-%m-%d\") # prep for Exclusive\n", - "\n", - "\n", - "response_timeout = 3.05 # seconds, how long to wait for connection\n", - "read_timeout = 20 # seconds\n", - "timeout = (float(response_timeout), float(read_timeout))\n", - "# TODO remove this dummy change" + "max_day_obs = max_date.strftime(\"%Y-%m-%d\") # prep for Exclusive" ] }, { @@ -229,7 +226,7 @@ "outputs": [], "source": [ "# Display various almanac values (for moon, sun)\n", - "rep.AlmanacReport().day_obs_report(day_obs=min_day_obs)" + "rep.AlmanacReport().day_obs_report(min_day_obs)" ] }, { @@ -247,20 +244,10 @@ "id": "14", "metadata": {}, "outputs": [], - "source": [ - "server" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "15", - "metadata": {}, - "outputs": [], "source": [ "# Display data from Night Report log.\n", "nr_adapter = sad.NightReportAdapter(\n", - " server_url=server, min_date=min_date, max_date=max_date\n", + " server_url=server, min_dayobs=min_day_obs, max_dayobs=max_day_obs\n", ")\n", "#!rep.adapter_overview(nr_adapter)\n", "\n", @@ -288,7 +275,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -297,7 +284,7 @@ }, { "cell_type": "markdown", - "id": "17", + "id": "16", "metadata": {}, "source": [ "# Exposure Log" @@ -306,15 +293,13 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "17", "metadata": {}, "outputs": [], "source": [ "# Display data from Exposure log. Display time log.\n", "exposure_adapter = sad.ExposurelogAdapter(\n", - " server_url=server,\n", - " min_date=min_date,\n", - " max_date=max_date,\n", + " server_url=server, min_dayobs=min_day_obs, max_dayobs=max_day_obs\n", ")\n", "exposure_rep = rep.ExposurelogReport(adapter=exposure_adapter)\n", "\n", @@ -339,7 +324,7 @@ }, { "cell_type": "markdown", - "id": "19", + "id": "18", "metadata": {}, "source": [ "# Narrative Log\n" @@ -348,15 +333,13 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "19", "metadata": {}, "outputs": [], "source": [ "# Get data from Narrative log. Display time log.\n", "narrative_adapter = sad.NarrativelogAdapter(\n", - " server_url=server,\n", - " min_date=min_date,\n", - " max_date=max_date,\n", + " server_url=server, min_dayobs=min_day_obs, max_dayobs=max_day_obs\n", ")\n", "narrrative_rep = rep.NarrativelogReport(adapter=narrative_adapter)\n", "\n", @@ -367,7 +350,7 @@ }, { "cell_type": "markdown", - "id": "21", + "id": "20", "metadata": {}, "source": [ "# Developer Only Section" @@ -376,7 +359,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -388,7 +371,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -401,7 +384,7 @@ }, { "cell_type": "markdown", - "id": "24", + "id": "23", "metadata": {}, "source": [ "# Finale" @@ -410,7 +393,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "24", "metadata": {}, "outputs": [], "source": [ diff --git a/python/lsst/ts/logging_and_reporting/reports.py b/python/lsst/ts/logging_and_reporting/reports.py index bdfda50..d8cec60 100644 --- a/python/lsst/ts/logging_and_reporting/reports.py +++ b/python/lsst/ts/logging_and_reporting/reports.py @@ -121,7 +121,7 @@ def day_obs_report(self, day_obs): def almanac_as_dataframe(self, day_obs): # This display superfluous header: "0, 1" - return pd.DataFrame(alm.Almanac(day_obs=day_obs).as_dict).T + return pd.DataFrame(alm.Almanac(dayobs=day_obs).as_dict).T class NightlyLogReport(Report): diff --git a/python/lsst/ts/logging_and_reporting/source_adapters.py b/python/lsst/ts/logging_and_reporting/source_adapters.py index ce549a5..ca7ae27 100644 --- a/python/lsst/ts/logging_and_reporting/source_adapters.py +++ b/python/lsst/ts/logging_and_reporting/source_adapters.py @@ -108,16 +108,10 @@ def __init__( # status[endpoint] = dict(endpoint_url, number_of_records, error) # e.g. status['messages'] = dict(endpoint_url='.../messages?...', ...) self.status = dict() - self.store_dayobs_range(max_dayobs=max_dayobs, min_dayobs=min_dayobs) - def store_dayobs_range( - self, - max_dayobs=None, # EXCLUSIVE: default=Today other=YYYY-MM-DD - min_dayobs=None, # INCLUSIVE: default=max_dayobs - 1 day - ): + # Store dayobs range self.max_date = ut.dayobs2dt(max_dayobs or "TODAY") self.max_dayobs = ut.datetime_to_dayobs(self.max_date) - if min_dayobs: self.min_date = ut.dayobs2dt(min_dayobs) else: @@ -274,11 +268,6 @@ def __init__( limit=None, ): super().__init__(max_dayobs=max_dayobs, min_dayobs=min_dayobs) - #! if min_date: - #! self.min_date = min_date - #! self.max_date = max_date - #! self.min_dayobs = ut.datetime_to_dayobs(min_date) - #! self.max_dayobs = ut.datetime_to_dayobs(max_date) self.server = server_url if server_url else SourceAdapter.server self.limit = SourceAdapter.limit if limit is None else limit @@ -566,7 +555,8 @@ def get_instruments(self): error = str(err) else: # Flatten the lists - self.instruments = list(itertools.chain.from_iterable(recs.values())) + vals = recs.values() + self.instruments = list(itertools.chain.from_iterable(vals)) status = dict( endpoint_url=url, number_of_records=len(recs), @@ -649,17 +639,6 @@ def get_records( ) return status - # dayobs:: YYYMMDD (int or str) - # Use almanac begin of night values for dayobs. - # Use almanac end of night values for dayobs + 1. - def OLD_night_tally_observation_gaps(self, dayobs, instrument="LSSTComCam"): - almanac = alm.Almanac(dayobs=dayobs) - total_observable_hours = almanac.night_hours - # recs = self.get_night_exposures(instrument, dayobs) - recs = self.records - total = total_observable_hours + len(recs) # TODO temporarily silly - return total - # Our goals is something like this (DM-46102) # # Ref Hours @@ -678,7 +657,6 @@ def OLD_night_tally_observation_gaps(self, dayobs, instrument="LSSTComCam"): # Use almanac begin of night values for day_obs. # Use almanac end of night values for day_obs + 1. def night_tally_observation_gaps(self, dayobs): - total_exposure_hours = dict() # d[instrument] = val instrument_tally = dict() # d[instrument] = tally_dict almanac = alm.Almanac(dayobs=dayobs) total_observable_hours = almanac.night_hours @@ -700,7 +678,7 @@ def night_tally_observation_gaps(self, dayobs): # get_detector_reads()?? UNKNOWN SOURCE # ?(e,f) # Composition to combine Exposure and Efd (blackboard) - # edf.get_targets() => "slewTime" # (d,g,h) + # edf.get_targets() => "slewTime" # (d,g,h) return instrument_tally def get_observation_gaps(self, instruments=None):