Skip to content

Commit

Permalink
narrative attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Oct 23, 2024
1 parent 80e75ca commit 5035d7e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
12 changes: 9 additions & 3 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"days = int(number_of_days)\n",
"\n",
"# Experimental Features config\n",
"exp_tally = \"false\" # default: true\n",
"exp_tally = \"true\" # default: true\n",
"exp_parsing = \"true\" # default: true\n",
"experimental = dict()\n",
"experimental[\"exposure_type_tally\"] = exp_tally == \"true\"\n",
Expand Down Expand Up @@ -347,9 +347,13 @@
"if experimental.get(\"exposure_type_tally\"):\n",
" md(\"### Experimental Exposure field Tally ENABLED\")\n",
" counts = uniform_field_counts(allsrc.exp_src.exposures[\"LATISS\"])\n",
" tkeys = sum([list(tally.keys()) for tally in counts.values()], [])\n",
" column_map = {tkey: tkey.replace(\"_\", \" \") for tkey in tkeys}\n",
" for fname, tally in counts.items():\n",
" md(f\"#### Tally of values for Field: {fname}\")\n",
" display(pd.DataFrame.from_dict(tally, orient=\"index\"))\n",
" df = pd.DataFrame.from_dict(tally, orient=\"index\").T\n",
" df = df.rename(columns=column_map) # allow wrap of column header\n",
" display(df)\n",
"else:\n",
" md(\"### Experimental Exposure field Tally DISASBLED\")"
]
Expand Down Expand Up @@ -383,7 +387,9 @@
"metadata": {},
"source": [
"## Narrative Log\n",
"(Now \"linked things\" from /narrativelog/messages.urls)"
"(Now \"linked things\" from /narrativelog/messages.urls)\n",
"\n",
"| Date Time | Time Lost | Time Lost Type |"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/ts/logging_and_reporting/all_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,6 @@ def uniform_field_counts(records):
facets, ignored = get_facets(records)
del facets["day_obs"]
del facets["instrument"]
del facets["target_name"]
del facets["group_name"]
return {k: dict(Counter([r[k] for r in records])) for k in facets.keys()}
1 change: 0 additions & 1 deletion python/lsst/ts/logging_and_reporting/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def mdfragmentlink(url, remove="!/"):


def htmlcode(text, fgcolor="black", bgcolor="LightGray", size="1em"):
# BLACK prevents me from breaking string into multilines nicely
style = ""
style += f"color: {fgcolor}; "
style += f"background-color: {bgcolor}; "
Expand Down
6 changes: 5 additions & 1 deletion python/lsst/ts/logging_and_reporting/source_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,16 @@ def obs_date(rec):
for tele, g0 in itertools.groupby(recs, key=obs_night):
for rec in g0:
rec_dt = dt.datetime.fromisoformat(rec[datetime_field])
attrstr = ""
attrstr += f"**{rec_dt}**"
attrstr += f" | {rec.get('time_lost')}"
attrstr += f" | {rec.get('time_lost_type')}"
new = rec.get("error_message")
if new:
msg = new
else:
msg = rep.htmlcode(rec["message_text"].strip())
table.append(f"- **{rec_dt}**")
table.append(f"- {attrstr}")
table.append("\n" + msg + "\n")

if rec.get("urls"):
Expand Down

0 comments on commit 5035d7e

Please sign in to comment.