Skip to content

Commit

Permalink
snap
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Nov 22, 2024
2 parents d102a5c + 34e007b commit 93c22b1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
41 changes: 21 additions & 20 deletions notebooks_tsqr/ExposureDetail.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"if os.environ.get(\"EXTERNAL_INSTANCE_URL\"):\n",
" dev_msg = (\n",
" 'Installing \"lsst.ts.logging_and_reporting\" from github using \"prototype\" branch. \\n'\n",
" 'TODO: Make the need for this go away by getting Logging_and_Reporting installed in RSP.'\n",
" \"TODO: Make the need for this go away by getting Logging_and_Reporting installed in RSP.\"\n",
" )\n",
" !pip install --upgrade git+https://github.com/lsst-ts/ts_logging_and_reporting.git@prototype > /dev/null 2>&1\n",
"else:\n",
" dev_msg = 'Imported lsst.ts.logging_and_reporting from local packages.'\n",
" dev_msg = \"Imported lsst.ts.logging_and_reporting from local packages.\"\n",
"#! import lsst.ts.logging_and_reporting.source_adapters as sad\n",
"import lsst.ts.logging_and_reporting.utils as ut\n",
"from lsst.ts.logging_and_reporting.reports import md\n",
Expand All @@ -68,9 +68,9 @@
") # TODO try with \"usdf\" before push (else \"summit\")\n",
"\n",
"# Normalize Parameters (both explicit Times Squares params and implicit ones)\n",
"observation_reason = None if observation_reason=='ALL' else observation_reason\n",
"observation_type = None if observation_type=='ALL' else observation_type\n",
"science_program = None if science_program=='ALL' else science_program\n",
"observation_reason = None if observation_reason == \"ALL\" else observation_reason\n",
"observation_type = None if observation_type == \"ALL\" else observation_type\n",
"science_program = None if science_program == \"ALL\" else science_program\n",
"params = dict(\n",
" day_obs=day_obs,\n",
" instrument=instrument,\n",
Expand All @@ -91,7 +91,7 @@
"date = ut.get_datetime_from_dayobs_str(day_obs)\n",
"# date: is EXCLUSIVE (upto, but not including)\n",
"days = 1\n",
"verbose=False\n",
"verbose = False\n",
"\n",
"# Thus: [min_day_obs,max_day_obs)\n",
"# Format: string, YYYY-MM-DD\n",
Expand All @@ -114,7 +114,7 @@
" server_url=server,\n",
" min_dayobs=min_day_obs,\n",
" max_dayobs=max_day_obs,\n",
" verbose=verbose, \n",
" verbose=verbose,\n",
" limit=5000,\n",
")\n",
"allrep = AllReports(allsrc=allsrc)\n",
Expand All @@ -138,18 +138,19 @@
"metadata": {},
"outputs": [],
"source": [
"df = src_exp.exposure_detail(instrument=instrument,\n",
" science_program=science_program,\n",
" observation_reason=observation_reason,\n",
" observation_type=observation_type\n",
" )\n",
"df = src_exp.exposure_detail(\n",
" instrument=instrument,\n",
" science_program=science_program,\n",
" observation_reason=observation_reason,\n",
" observation_type=observation_type,\n",
")\n",
"if observation_reason:\n",
" md(f'# Observation Reason: {observation_reason}')\n",
" md(f\"# Observation Reason: {observation_reason}\")\n",
"if observation_type:\n",
" md(f'# Observation Type: {observation_type}')\n",
" md(f\"# Observation Type: {observation_type}\")\n",
"if science_program:\n",
" md(f'# Science Program: {science_program}')\n",
"md(f'The number of exposures in this filtered result is {len(df.index)}')\n",
" md(f\"# Science Program: {science_program}\")\n",
"md(f\"The number of exposures in this filtered result is {len(df.index)}\")\n",
"display(HTML(df.to_html(index=False)))"
]
},
Expand Down Expand Up @@ -188,9 +189,9 @@
"metadata": {},
"outputs": [],
"source": [
"display(params) \n",
"display(params)\n",
"print(src_exp)\n",
"print(f'{instrument=}, {science_program=}, {observation_reason=}, {observation_type=}')"
"print(f\"{instrument=}, {science_program=}, {observation_reason=}, {observation_type=}\")"
]
},
{
Expand All @@ -200,7 +201,7 @@
"metadata": {},
"outputs": [],
"source": [
"print({k: len(v) for k,v in src_exp.exposures.items()})"
"print({k: len(v) for k, v in src_exp.exposures.items()})"
]
},
{
Expand All @@ -210,7 +211,7 @@
"metadata": {},
"outputs": [],
"source": [
"#src_exp.exposures['LATISS']"
"# src_exp.exposures['LATISS']"
]
},
{
Expand Down
38 changes: 19 additions & 19 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
"if os.environ.get(\"EXTERNAL_INSTANCE_URL\"):\n",
" dev_msg = (\n",
" 'Installing \"lsst.ts.logging_and_reporting\" from github using \"prototype\" branch. \\n'\n",
" 'TODO: Make the need for this go away by getting Logging_and_Reporting installed in RSP.'\n",
" \"TODO: Make the need for this go away by getting Logging_and_Reporting installed in RSP.\"\n",
" )\n",
" !pip install --upgrade git+https://github.com/lsst-ts/ts_logging_and_reporting.git@prototype > /dev/null 2>&1\n",
"else:\n",
" dev_msg = 'Imported lsst.ts.logging_and_reporting from local packages.'\n",
" dev_msg = \"Imported lsst.ts.logging_and_reporting from local packages.\"\n",
"from lsst.ts.logging_and_reporting.all_sources import AllSources\n",
"from lsst.ts.logging_and_reporting.all_reports import AllReports\n",
"import lsst.ts.logging_and_reporting.utils as ut\n",
Expand All @@ -83,8 +83,8 @@
"# Set default env to \"usdf\" and try before PUSH to repo.\n",
"# The default provided here is for local testing. Under Times Square it is ignored.\n",
"server = os.environ.get(\n",
" \"EXTERNAL_INSTANCE_URL\", \n",
" ut.Server.usdf) # TODO try with \"usdf\" before push (also \"summit\")"
" \"EXTERNAL_INSTANCE_URL\", ut.Server.usdf\n",
") # TODO try with \"usdf\" before push (also \"summit\")"
]
},
{
Expand All @@ -99,10 +99,10 @@
"if error:\n",
" print(error)\n",
"\n",
"date = ut.get_datetime_from_dayobs_str(usable['day_obs'])\n",
"date = ut.get_datetime_from_dayobs_str(usable[\"day_obs\"])\n",
"# date: is EXCLUSIVE (upto, but not including)\n",
"days = usable['number_of_days']\n",
"verbose = usable['verbose']\n",
"days = usable[\"number_of_days\"]\n",
"verbose = usable[\"verbose\"]\n",
"\n",
"# Thus: [min_day_obs,max_day_obs)\n",
"# Format: string, YYYY-MM-DD\n",
Expand All @@ -125,9 +125,9 @@
" server_url=server,\n",
" min_dayobs=min_day_obs,\n",
" max_dayobs=max_day_obs,\n",
" verbose=verbose, \n",
" verbose=verbose,\n",
" limit=5000,\n",
" exclude_instruments = [] # TODO change to empty list before push\n",
" exclude_instruments=[], # TODO change to empty list before push\n",
")\n",
"allrep = AllReports(allsrc=allsrc)"
]
Expand All @@ -149,7 +149,9 @@
"source": [
"instrum_str = \", \".join(list(allsrc.exp_src.instruments.keys()))\n",
"md(f\"# Showing data for {min_date.date()} to {max_date.date()} for {instrum_str}\")\n",
"md(f\"Most recently run on: **{dt.datetime.now().replace(microsecond=0).isoformat(sep=' ')}**\")"
"md(\n",
" f\"Most recently run on: **{dt.datetime.now().replace(microsecond=0).isoformat(sep=' ')}**\"\n",
")"
]
},
{
Expand Down Expand Up @@ -384,12 +386,12 @@
"source": [
"# Exposure Report\n",
"for instrum in allsrc.exp_src.exposures.keys():\n",
" md(f'#### {instrum}: {len(allsrc.exp_src.exposures[instrum])} total exposures')\n",
" md(f\"#### {instrum}: {len(allsrc.exp_src.exposures[instrum])} total exposures\")\n",
" df_dict = allsrc.fields_count_exposure(instrum)\n",
" for field_name,df in df_dict.items():\n",
" for field_name, df in df_dict.items():\n",
" if df.empty:\n",
" continue\n",
" md('##### ' + field_name.title().replace('_',' '))\n",
" md(\"##### \" + field_name.title().replace(\"_\", \" \"))\n",
" display(HTML(df.style.hide().to_html(escape=False)))"
]
},
Expand Down Expand Up @@ -481,7 +483,8 @@
"- {have_consdb = }\n",
"- {dev_msg}\n",
"- {allsrc.nig_src.timeout=}\n",
"\"\"\")"
"\"\"\"\n",
")"
]
},
{
Expand All @@ -501,10 +504,7 @@
"outputs": [],
"source": [
"df = pd.DataFrame(allsrc.get_data_status())\n",
"table = df.to_html(\n",
" index=False, \n",
" render_links=True,\n",
" escape=False)\n",
"table = df.to_html(index=False, render_links=True, escape=False)\n",
"display(HTML(table))"
]
},
Expand Down Expand Up @@ -601,7 +601,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(f'Elapsed time (excluding code import): {timer.toc:.1f} seconds')\n",
"print(f\"Elapsed time (excluding code import): {timer.toc:.1f} seconds\")\n",
"print(f\"Finished {str(dt.datetime.now().replace(microsecond=0))} UTC\")"
]
}
Expand Down
10 changes: 5 additions & 5 deletions notebooks_tsqr/dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"source": [
"# Narrativelog components\n",
"dash = Dashboard()\n",
"endpoint = 'https://usdf-rsp-dev.slac.stanford.edu/narrativelog/messages'\n",
"endpoint = \"https://usdf-rsp-dev.slac.stanford.edu/narrativelog/messages\"\n",
"fields = [\n",
" 'components',\n",
" 'primary_software_components',\n",
" 'primary_hardware_components',\n",
" \"components\",\n",
" \"primary_software_components\",\n",
" \"primary_hardware_components\",\n",
"]\n",
"samples = dash.get_big_sample(endpoint,10000,fields)\n",
"samples = dash.get_big_sample(endpoint, 10000, fields)\n",
"len(samples)"
]
},
Expand Down

0 comments on commit 93c22b1

Please sign in to comment.