From b0b9b9a9b5d45faeb953bf27efd28695bec7fe0c Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Sun, 8 Oct 2023 21:39:15 -0400 Subject: [PATCH 1/3] Handle no starcat from kadi observations --- mica/report/report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mica/report/report.py b/mica/report/report.py index 04cd82ae..9350f734 100644 --- a/mica/report/report.py +++ b/mica/report/report.py @@ -540,6 +540,8 @@ def main(obsid): if plan_date.cxcsec > (CxoTime.now() + 21 * u.day).secs: raise LookupError("No starcheck expected for {} lts date".format(str(plan))) mp_dir, status, mp_date = starcheck.get_mp_dir(obsid) + if status == 'no starcat': + raise LookupError("No starcat") obs_sc, mp_dir, status = get_starcheck(obsid) logger.debug("Plotting starcheck catalog to {}".format(os.path.join(outdir, 'starcheck.png'))) if obs_sc['obs']['point_ra'] is None: @@ -551,7 +553,7 @@ def main(obsid): fig.savefig(os.path.join(outdir, 'starcheck.png')) plt.close('all') except LookupError as detail: - logger.info("No starcheck catalog. Writing out OCAT info only") + logger.info("No starcheck catalog or no starcat. Writing out OCAT info only") logger.info(detail) template = jinja_env.get_template('report.html') page = template.render(obsid=obsid, From d1974a6fb365fcf1a1d35440fed4c6e6672e62c8 Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Fri, 20 Oct 2023 10:56:29 -0400 Subject: [PATCH 2/3] Conditionally handle mp_date --- mica/report/report.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mica/report/report.py b/mica/report/report.py index 9350f734..6ad49d8c 100644 --- a/mica/report/report.py +++ b/mica/report/report.py @@ -337,19 +337,20 @@ def obs_links(obsid, sequence=None, plan=None): dir_match = re.match(r'/\d{4}/(\w{3}\d{4})/ofls(\w)', mp_dir) mp_label = "{}{}".format(dir_match.group(1), dir_match.group(2).upper()) - mp_date_m = re.match(r'(\d{4}):(\d{3}):\d{2}:\d{2}:\d{2}\.\d{3}', mp_date) - if mp_date_m: - year = int(mp_date_m.group(1)) - doy = int(mp_date_m.group(2)) - - dtm = datetime.datetime(year, 1, 1) + datetime.timedelta(doy - 1) - month = dtm.strftime("%b") - dom = dtm.strftime("%d") - links['fot_daily'] = { - 'label': "Daily Plots {}:{:03d}".format(year, int(doy)), - 'link': "{root}/{year}/{upper_month}/{lower_month}{day_of_month:02d}_{doy:03d}/".format( - root=DAILY_PLOT_ROOT, year=year, upper_month=month.upper(), - lower_month=month.lower(), day_of_month=int(dom), doy=int(doy))} + if mp_date is not None: + mp_date_m = re.match(r'(\d{4}):(\d{3}):\d{2}:\d{2}:\d{2}\.\d{3}', mp_date) + if mp_date_m: + year = int(mp_date_m.group(1)) + doy = int(mp_date_m.group(2)) + + dtm = datetime.datetime(year, 1, 1) + datetime.timedelta(doy - 1) + month = dtm.strftime("%b") + dom = dtm.strftime("%d") + links['fot_daily'] = { + 'label': "Daily Plots {}:{:03d}".format(year, int(doy)), + 'link': "{root}/{year}/{upper_month}/{lower_month}{day_of_month:02d}_{doy:03d}/".format( + root=DAILY_PLOT_ROOT, year=year, upper_month=month.upper(), + lower_month=month.lower(), day_of_month=int(dom), doy=int(doy))} vv, vvid = official_vv(obsid) links['shortterm'] = {'link': guess_shortterm(mp_dir), 'label': "Short Term Sched. {}".format(mp_label)} From 24e3e0256cfa2863877aec9148c589f3ed332205 Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Fri, 20 Oct 2023 11:05:17 -0400 Subject: [PATCH 3/3] Add ER without star catalog to report test set --- mica/report/tests/test_write_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mica/report/tests/test_write_report.py b/mica/report/tests/test_write_report.py index cb38ba42..97edad1e 100644 --- a/mica/report/tests/test_write_report.py +++ b/mica/report/tests/test_write_report.py @@ -43,7 +43,7 @@ def test_write_reports(): os.unlink(fn) report.REPORT_ROOT = tempdir report.REPORT_SERVER = fn - for obsid in [20001, 15175, 54778]: + for obsid in [20001, 15175, 54778, 44077]: report.main(obsid) os.unlink(fn) shutil.rmtree(tempdir)