Skip to content

Commit

Permalink
add telescope column to Exposure log
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Sep 17, 2024
1 parent 83a61e0 commit 04abf5d
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 113 deletions.
120 changes: 58 additions & 62 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
{
"cell_type": "markdown",
"id": "0",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"# Initialization"
]
Expand Down Expand Up @@ -114,7 +112,7 @@
"import lsst.ts.logging_and_reporting.source_adapters as sad\n",
"import lsst.ts.logging_and_reporting.almanac as alm\n",
"import lsst.ts.logging_and_reporting.reports as rep \n",
"from lsst.ts.logging_and_reporting.reports import md,mdlist"
"from lsst.ts.logging_and_reporting.reports import md,mdlist, NightlyLogReport"
]
},
{
Expand Down Expand Up @@ -160,19 +158,14 @@
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"# Display overview of Report context \n",
"md(f'''\n",
"Report for **{date}** covering the previous **{days}** observing night(s).\n",
"- Run on logs from **{server}/**\n",
"- Using *Prototype* Logging and Reporting Version: **{lrversion}**\n",
"- {enable_efd=}\n",
"''')"
]
},
Expand Down Expand Up @@ -204,29 +197,24 @@
"id": "12",
"metadata": {},
"source": [
"# Nightly Report"
"# Night Report"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"# Get data from Night Report log. Display nightly Jira BLOCKS.\n",
"nr_adapter = sad.NightReportAdapter(server_url=server)\n",
"nr_adapter = sad.NightReportAdapter(server_url=server,\n",
" limit=limit,\n",
" min_day_obs=min_day_obs,\n",
" max_day_obs=max_day_obs,)\n",
"nr_url = nr_adapter.source_url\n",
"try:\n",
" nr_recs,nr_url = nr_adapter.get_reports(\n",
" limit=limit,\n",
" min_day_obs=min_day_obs,\n",
" max_day_obs=max_day_obs,\n",
" )\n",
" nr_recs,nr_url = nr_adapter.get_reports()\n",
"except Exception as err:\n",
" nr_recs = []\n",
" msg = f'ERROR getting records from {nr_url=}: {err=}'\n",
Expand All @@ -248,6 +236,10 @@
"else:\n",
" md(f'No jira BLOCK tickets found.', color='lightblue')\n",
" md(f'Used: [API Data]({nr_url})')\n",
"\n",
"# Display time log\n",
"nr_rep = NightlyLogReport(min_day_obs=min_day_obs, max_day_obs=max_day_obs)\n",
"nr_rep.time_log_as_markdown(nr_recs, nr_adapter, nr_url)\n",
" "
]
},
Expand All @@ -263,22 +255,19 @@
"cell_type": "code",
"execution_count": null,
"id": "15",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"# Get data from Exposure log. Display time log.\n",
"exposure_adapter = sad.ExposurelogAdapter(server_url=server)\n",
"exposure_adapter = sad.ExposurelogAdapter(\n",
" server_url=server,\n",
" limit=limit,\n",
" min_day_obs=min_day_obs,\n",
" max_day_obs=max_day_obs,\n",
")\n",
"exposure_url = exposure_adapter.source_url\n",
"try:\n",
" exposure_recs,url = exposure_adapter.get_messages(\n",
" limit=limit,\n",
" min_day_obs=min_day_obs,\n",
" max_day_obs=max_day_obs,\n",
" )\n",
" exposure_recs,url = exposure_adapter.get_messages()\n",
"except Exception as err:\n",
" exposure_recs = []\n",
" msg = f'ERROR getting records from {url=}: {err=}'\n",
Expand All @@ -297,19 +286,23 @@
"cell_type": "code",
"execution_count": null,
"id": "16",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"len(exposure_recs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"metadata": {},
"outputs": [],
"source": [
"# Display Observation gaps\n",
"if usdf == os.environ.get('EXTERNAL_INSTANCE_URL'):\n",
" md(f\"**Warning:** The `/exposures/` endpoint is not yet functional on SERVER=usdf.\", color='red')\n",
"gaps = exposure_adapter.get_observation_gaps(min_day_obs=min_day_obs,\n",
" max_day_obs=max_day_obs\n",
" )\n",
"gaps = exposure_adapter.get_observation_gaps()\n",
"if gaps:\n",
" md(f'### Date vs Observation Gap (minutes) for all Instruments')\n",
" for instrument, day_gaps in gaps.items():\n",
Expand All @@ -325,7 +318,7 @@
},
{
"cell_type": "markdown",
"id": "17",
"id": "18",
"metadata": {},
"source": [
"# Narrative Log\n"
Expand All @@ -334,28 +327,25 @@
{
"cell_type": "code",
"execution_count": null,
"id": "18",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"id": "19",
"metadata": {},
"outputs": [],
"source": [
"# Get data from Narrative log. Display time log.\n",
"narrative_adapter = sad.NarrativelogAdapter(server_url=server)\n",
"narrative_adapter = sad.NarrativelogAdapter(\n",
" server_url=server,\n",
" limit=limit,\n",
" min_day_obs=min_day_obs,\n",
" max_day_obs=max_day_obs,\n",
")\n",
"narrative_url = narrative_adapter.source_url\n",
"try:\n",
" # date like '2000-01-02 12:00:00'\n",
" # str(datetime(2000, 1, 2, 12, 0, 0))\n",
" min_date = str(datetime.strptime(min_day_obs,'%Y%m%d'))\n",
" max_date = str(datetime.strptime(max_day_obs,'%Y%m%d'))\n",
" #!print(f'Get data from {narrative_url}: {min_date} to {max_date}')\n",
" narrative_recs,url = narrative_adapter.get_messages(\n",
" limit=limit,\n",
" min_date_end=min_date,\n",
" max_date_end=max_date\n",
" )\n",
" narrative_recs,url = narrative_adapter.get_messages()\n",
"except Exception as err:\n",
" narrative_recs = []\n",
" msg = f'ERROR getting records from {url}: {err=}'\n",
Expand All @@ -378,16 +368,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "19",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"id": "20",
"metadata": {},
"outputs": [],
"source": [
"# Conditionally display our current ability to connect to all needed endpoints.\n",
"if not os.environ.get('EXTERNAL_INSTANCE_URL'):\n",
"if False and not os.environ.get('EXTERNAL_INSTANCE_URL'):\n",
" md('# Dashboard')\n",
" md('(This is not done when running under Times Square.)')\n",
" %run ./dashboard.ipynb"
Expand All @@ -396,7 +382,17 @@
{
"cell_type": "code",
"execution_count": null,
"id": "20",
"id": "21",
"metadata": {},
"outputs": [],
"source": [
"print(f'Finished {str(datetime.now())}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22",
"metadata": {},
"outputs": [],
"source": []
Expand Down
20 changes: 16 additions & 4 deletions notebooks_tsqr/dashboard.ipynb
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# Logger Source API Dashboard\n",
"For all of these to work, the following must be enabled:\n",
"- Tucson VPN\n",
"- Summit VPN\n",
"- User has access to USDF-dev (SLAC)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -13,7 +25,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -26,7 +38,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -38,7 +50,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"id": "4",
"metadata": {},
"outputs": [],
"source": []
Expand Down
16 changes: 15 additions & 1 deletion python/lsst/ts/logging_and_reporting/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,21 @@ def __init__(self, *,
min_day_obs=None, # INCLUSIVE: default=Yesterday
max_day_obs=None, # EXCLUSIVE: default=Today
):
pass # TODO
self.min_day_obs = min_day_obs
self.max_day_obs = max_day_obs

def time_log_as_markdown(self, records, source_adapter, url,
log_title=None,
):
service = source_adapter.service
title = log_title if log_title else ''
if records:
md(f'### {title}')
table = source_adapter.day_table(records, 'date_added')
mdlist(table)
else:
md(f'No {service} records found.', color='lightblue')
md(f'Used [API Data]({url})')

class AlmanacReport(Report):
# moon rise,set,illumination %
Expand Down
Loading

0 comments on commit 04abf5d

Please sign in to comment.