Skip to content

Commit

Permalink
maybe fixed exposure query
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Oct 8, 2024
1 parent d173de2 commit 0df8e06
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 30 deletions.
8 changes: 2 additions & 6 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"import datetime as dt\n",
Expand Down Expand Up @@ -304,7 +300,7 @@
"exposure_rep = rep.ExposurelogReport(adapter=allsrc.exp_src)\n",
"\n",
"# Overview\n",
"exposure_rep.overview\n",
"exposure_rep.overview()\n",
"\n",
"# Exposure Tally\n",
"md(f\"## Exposure Tally for all Instruments\")\n",
Expand Down
17 changes: 11 additions & 6 deletions python/lsst/ts/logging_and_reporting/almanac.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ def __init__(self, *, dayobs=None, site="Rubin"):
# Allow formats: int, YYYY-MM-DD, YYYYMMDD
dobs = str(dayobs).replace("-", "")
astro_day = dt.datetime.strptime(dobs, "%Y%m%d").date()
astro_date = dt.datetime.strptime(dobs, "%Y%m%d")

with warnings.catch_warnings(action="ignore"):
self.loc = astropy.coordinates.EarthLocation.of_site(site)
self.observer = Observer(self.loc, timezone="Chile/Continental")
self.astro_day = astro_day
day1 = dt.timedelta(days=1)
self.astro_midnight = Time(
dt.datetime.combine(self.astro_day + day1, dt.time(0, 15)),
format="datetime",
scale="utc",
location=self.loc,
self.astro_midnight = self.observer.midnight(
Time(
astro_date,
format="datetime",
scale="utc",
location=self.loc,
),
which="next",
)
self.get_moon()
self.get_sun()
Expand Down Expand Up @@ -96,6 +99,7 @@ def as_dict(self):
"Moon Illumination": f"{self.moon_illum:.0%}",
"Astronomical Twilight (morning)": self.ast_twilight_morning.iso,
"Astronomical Twilight (evening)": self.ast_twilight_evening.iso,
"Solar Midnight": self.astro_midnight.iso,
"Nautical Twilight (morning)": self.nau_twilight_morning.iso,
"Nautical Twilight (evening)": self.nau_twilight_evening.iso,
"Civil Twilight (morning)": self.civ_twilight_morning.iso,
Expand All @@ -110,6 +114,7 @@ def as_dict(self):
"Moon Illumination": "(% illuminated)",
"Astronomical Twilight (evening)": "(-18 degrees)",
"Astronomical Twilight (morning)": "(-18 degrees)",
"Solar Midnight": "",
"Nautical Twilight (evening)": "(-12 degrees)",
"Nautical Twilight (morning)": "(-12 degrees)",
"Civil Twilight (evening)": "(-6 degrees)",
Expand Down
22 changes: 8 additions & 14 deletions python/lsst/ts/logging_and_reporting/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ def overview(self):
error = status["error"]
more = "(There may be more.)" if count >= adapter.limit else ""
result = error if error else f"Got {count} records. "
mdlist(
[
f"## Overview for Service: `{adapter.service}` [{count}]",
f'- Endpoint: {status["endpoint_url"]}',
]
)

print(md(f"## Overview for Service: `{adapter.service}` [{count}]"))
print(md(f'- Endpoint: {status["endpoint_url"]}'))
print(f"- {result} {more}")

def time_log_as_markdown(
Expand All @@ -100,6 +97,10 @@ def time_log_as_markdown(
url = adapter.get_status().get("endpoint_url")
title = log_title if log_title else ""
if records:
md(
f"## Time Log for {self.source_adapter.min_date} "
f"to {self.source_adapter.max_date}"
)
md(f"### {title}")
table = self.source_adapter.day_table("date_added")
mdlist(table)
Expand Down Expand Up @@ -160,19 +161,12 @@ def block_tickets_as_markdown(

class ExposurelogReport(Report):

# date, time, obs_id, message_text
def time_log_as_markown(self, records, title="# Exposure Log"):
pass # TODO use "day_table"

def daily_observation_gap(self, min_day_obs, max_day_obs):
pass


class NarrativelogReport(Report):

# date, time, message_text
def time_log_as_markown(self, records, title="# Exposure Log"):
pass # TODO use "day_table"
pass


class NightObsReport(Report):
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/ts/logging_and_reporting/source_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ def get_instruments(self):
def get_exposures(self, instrument, registry=1):
qparams = dict(instrument=instrument, registery=registry)
if self.min_dayobs:
qparams["min_dayobs"] = ut.dayobs_int(self.min_dayobs)
qparams["min_day_obs"] = ut.dayobs_int(self.min_dayobs)
if self.max_dayobs:
qparams["max_dayobs"] = ut.dayobs_int(self.max_dayobs)
qparams["max_day_obs"] = ut.dayobs_int(self.max_dayobs)
url = f"{self.server}/{self.service}/exposures?{urlencode(qparams)}"
recs = []
error = None
Expand Down Expand Up @@ -605,9 +605,9 @@ def get_records(
if instruments:
qparams["instruments"] = instruments
if self.min_dayobs:
qparams["min_dayobs"] = ut.dayobs_int(self.min_dayobs)
qparams["min_day_obs"] = ut.dayobs_int(self.min_dayobs)
if self.max_dayobs:
qparams["max_dayobs"] = ut.dayobs_int(self.max_dayobs)
qparams["max_day_obs"] = ut.dayobs_int(self.max_dayobs)
if exposure_flags:
qparams["exposure_flags"] = exposure_flags
if self.limit:
Expand Down

0 comments on commit 0df8e06

Please sign in to comment.