Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Oct 30, 2024
1 parent f32e967 commit b299fe8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 51 deletions.
58 changes: 32 additions & 26 deletions notebooks_tsqr/ExposureDetail.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"# day_obs values: TODAY, YESTERDAY, YYYY-MM-DD\n",
"# Report on observing nights that start upto but not included this day.\n",
"#!day_obs = '2024-09-25' # Value to use for local testing (Summit)\n",
"day_obs = \"TODAY\" # TODO Change to 'YESTERDAY' to test with default before push\n",
"day_obs = \"2024-09-25\" # TODO Change to 'YESTERDAY' to test with default before push\n",
"\n",
"# Total number of days of data to display (ending on day_obs)\n",
"number_of_days = \"1\" # TODO Change to '1' to test with default before push\n",
"\n",
"instrument = \"LSSTComCam\"\n",
"instrument = \"LATISS\"\n",
"observation_reason = \"ALL\"\n",
"observation_type = \"ALL\"\n",
"science_program = \"ALL\""
Expand All @@ -33,6 +33,7 @@
"outputs": [],
"source": [
"import os\n",
"import datetime as dt\n",
"import pandas as pd\n",
"\n",
"# When running under Times Square, install pkg from github.\n",
Expand Down Expand Up @@ -78,19 +79,41 @@
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"# Normalize Parameters (both explicit Times Squares params, in implicit ones)\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",
"# Thus: [min_day_obs,max_day_obs)\n",
"# Format: string, YYYY-MM-DD\n",
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"src_exp = sad.ExposurelogAdapter(\n",
" server_url=server,\n",
" min_dayobs=None, # INCLUSIVE: default=Yesterday\n",
" max_dayobs=None, # EXCLUSIVE: default=Today other=YYYY-MM-DD\n",
" min_dayobs=min_day_obs,\n",
" max_dayobs=max_day_obs,\n",
" limit=5000,\n",
")"
")\n",
"\n",
"print({k: len(v) for k, v in src_exp.exposures.items()})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -106,20 +129,10 @@
},
{
"cell_type": "markdown",
"id": "4",
"metadata": {},
"source": [
"-----------------"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"print(f\"{instrument=}, {science_program=}, {observation_reason=}, {observation_type=}\")"
"-----------------"
]
},
{
Expand All @@ -129,16 +142,9 @@
"metadata": {},
"outputs": [],
"source": [
"print(f\"{server=}\")"
"print(src_exp)\n",
"print(f\"{instrument=}, {science_program=}, {observation_reason=}, {observation_type=}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
22 changes: 9 additions & 13 deletions notebooks_tsqr/NightLog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@
"# date: is EXCLUSIVE (upto, but not including)\n",
"days = int(number_of_days)\n",
"\n",
"# Experimental Features config\n",
"exp_tally = \"true\" # default: true\n",
"exp_parsing = \"true\" # default: true\n",
"experimental = dict()\n",
"experimental[\"exposure_type_tally\"] = exp_tally == \"true\"\n",
"experimental[\"error_parsing\"] = exp_parsing == \"true\"\n",
"\n",
"# Thus: [min_day_obs,max_day_obs)\n",
"# Format: string, YYYY-MM-DD\n",
"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"
"max_day_obs = max_date.strftime(\"%Y-%m-%d\") # prep for Exclusive\n",
"\n",
"# Experimental Features config\n",
"exp_tally = \"true\" # default: true\n",
"exp_parsing = \"true\" # default: true\n",
"experimental = dict()\n",
"experimental[\"exposure_type_tally\"] = exp_tally == \"true\"\n",
"experimental[\"error_parsing\"] = exp_parsing == \"true\""
]
},
{
Expand All @@ -113,11 +113,7 @@
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"# Read records from (almost) all sources\n",
Expand Down
27 changes: 15 additions & 12 deletions python/lsst/ts/logging_and_reporting/source_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ def analytics(self, recs, categorical_fields=None):
)

def __str__(self):
return f"{self.service}-{self.primary_endpoint} [{self.endpoints}]"
return (
f"{self.server}: "
f"{self.min_dayobs} to {self.max_dayobs} [{self.limit}] "
f"{self.service} endpoints={self.endpoints}"
)


# END: class SourceAdapter
Expand Down Expand Up @@ -743,17 +747,16 @@ def exposure_detail(
)
)
]
# if len(recs) == 0:
# msg = (
# f"No matching records after appling filters "
# f"to {len(self.exposures[instrument])} exposures "
# f"for {instrument=!r}."
# )
# return msg

# #!df = pd.DataFrame(self.exposures[instrument])[fields]
df = pd.DataFrame(recs)[fields]
return ut.wrap_dataframe_columns(df)
print(
f"DEBUG exp_src.exposure_detail(): "
f"{len(self.exposures[instrument])} => {len(recs)} "
)

if len(recs) > 0:
df = pd.DataFrame(recs)[fields]
return ut.wrap_dataframe_columns(df)
else:
return pd.DataFrame()

def check_endpoints(self, timeout=None, verbose=True):
to = timeout or self.timeout
Expand Down

0 comments on commit b299fe8

Please sign in to comment.