From f0e82e9190ad5251322605af31b28f30dd580fd1 Mon Sep 17 00:00:00 2001 From: simeonreusch Date: Mon, 11 Jul 2022 21:51:23 +0200 Subject: [PATCH 1/2] make Skyvision the default service for getting observation logs --- nuztf/irsa.py | 1 - nuztf/observations.py | 57 +++++++++++++++++++++++--------------- tests/test_observations.py | 4 +-- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/nuztf/irsa.py b/nuztf/irsa.py index 94a3c815..1329d489 100644 --- a/nuztf/irsa.py +++ b/nuztf/irsa.py @@ -323,7 +323,6 @@ def plot_irsa_lightcurve( ra=source_coords[0], dec=source_coords[1], lookback_weeks_max=check_obs_lookback_weeks, - query_irsa_for_logs=query_irsa_for_logs, ) if mro is not None: diff --git a/nuztf/observations.py b/nuztf/observations.py index 95709c42..71fbfb16 100644 --- a/nuztf/observations.py +++ b/nuztf/observations.py @@ -137,7 +137,27 @@ def get_coverage(jds: [int]) -> pd.DataFrame: return df -def get_obs_summary(t_min, t_max=None, max_days: int = None, query_irsa_for_logs=True): +def get_obs_summary(t_min, t_max=None, max_days: int = None): + """ + Get observation summary from Skyvision (or IRSA if Skyvision fails) + """ + + logger.info("Getting observation logs from skyvision.") + mns = get_obs_summary_skyvision(t_min, t_max, max_days=max_days) + + if len(mns.data) == 0: + logger.debug("Empty observation log, try IRSA instead.") + mns = get_obs_summary_irsa(t_min, t_max, max_days=max_days) + + logger.debug(f"Found {len(mns.data)} observations in total.") + + return mns + + +def get_obs_summary_irsa(t_min, t_max=None, max_days: int = None): + """ + Get observation summary from IRSA + """ if t_max is None: if max_days is None: @@ -147,30 +167,25 @@ def get_obs_summary(t_min, t_max=None, max_days: int = None, query_irsa_for_logs jds = np.arange(int(t_min.jd), int(t_max.jd) + 1) - if query_irsa_for_logs: - logger.debug("Getting coverage") - df = get_coverage(jds) - mns = MNS(df) - mns.data.query(f"obsjd >= {t_min.jd} and obsjd <= {t_max.jd}", inplace=True) - mns.data.reset_index(inplace=True) - mns.data.drop(columns=["index"], inplace=True) - logger.debug("Done") + logger.debug("Getting coverage") - if len(df) == 0: - logger.debug("Empty observation log, try skyvision instead.") - mns = get_obs_summary_skyvision(t_min, t_max, max_days=max_days) + df = get_coverage(jds) - else: - logger.info("Getting observation log from skyvision.") - mns = get_obs_summary_skyvision(t_min, t_max, max_days=max_days) + mns = MNS(df) - logger.debug(f"Found {len(mns.data)} observations in total.") + mns.data.query(f"obsjd >= {t_min.jd} and obsjd <= {t_max.jd}", inplace=True) + mns.data.reset_index(inplace=True) + mns.data.drop(columns=["index"], inplace=True) + + logger.debug("Done") return mns def get_obs_summary_skyvision(t_min, t_max=None, max_days: int = None): - """ """ + """ + Get observation summary from Skyvision + """ t_min_jd = t_min.jd t_min_date = t_min.to_value("iso", subfmt="date") @@ -218,9 +233,7 @@ def get_obs_summary_skyvision(t_min, t_max=None, max_days: int = None): return mns -def get_most_recent_obs( - ra: float, dec: float, lookback_weeks_max: int = 12, query_irsa_for_logs=True -): +def get_most_recent_obs(ra: float, dec: float, lookback_weeks_max: int = 12): """ """ fields = get_fields_containing_target(ra, dec)._data @@ -249,9 +262,7 @@ def get_most_recent_obs( with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=UserWarning) - mns = get_obs_summary( - t_min=t_min, t_max=t_max, query_irsa_for_logs=query_irsa_for_logs - ) + mns = get_obs_summary(t_min=t_min, t_max=t_max) mask = np.array([x in fields for x in mns.data["field"]]) diff --git a/tests/test_observations.py b/tests/test_observations.py index 492b17c2..ef171d41 100644 --- a/tests/test_observations.py +++ b/tests/test_observations.py @@ -5,7 +5,7 @@ import logging from astropy.time import Time from astropy import units as u -from nuztf.observations import get_obs_summary, get_obs_summary_skyvision +from nuztf.observations import get_obs_summary_irsa, get_obs_summary_skyvision class TestCoverage(unittest.TestCase): @@ -19,7 +19,7 @@ def test_lightcurve(self): t_start = Time(2458865.96, format="jd") t_end = Time(2458866.96, format="jd") - res = get_obs_summary(t_start, t_end) + res = get_obs_summary_irsa(t_start, t_end) expected = { "obsid": 111223429.0, From ee987bcb0f0bd72b5af65687639b80075b2a44e2 Mon Sep 17 00:00:00 2001 From: simeonreusch Date: Mon, 11 Jul 2022 23:00:37 +0200 Subject: [PATCH 2/2] changed neutrino scanner test (first obs after event magically changed due to switch to skyvision, here be dragons --- tests/test_neutrino_scanner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_neutrino_scanner.py b/tests/test_neutrino_scanner.py index c021e61f..da45b8d2 100644 --- a/tests/test_neutrino_scanner.py +++ b/tests/test_neutrino_scanner.py @@ -113,7 +113,7 @@ def test_scan(self): print(repr(res)) # Update the true using repr(res) - true_gcn = f"Astronomer Name (Institute of Somewhere), ............. report,\nOn behalf of the Zwicky Transient Facility (ZTF) and Global Relay of Observatories Watching Transients Happen (GROWTH) collaborations: \nWe observed the localization region of the neutrino event IceCube-200620A (Santander et. al, GCN 27997) with the Palomar 48-inch telescope, equipped with the 47 square degree ZTF camera (Bellm et al. 2019, Graham et al. 2019). We started observations in the g-band and r-band beginning at 2020-06-21 04:48 UTC, approximately 25.8 hours after event time. We covered 1.2 sq deg, corresponding to 77.7% of the reported localization region. This estimate accounts for chip gaps. Each exposure was 300s with a typical depth of 21.0 mag. \n \nThe images were processed in real-time through the ZTF reduction and image subtraction pipelines at IPAC to search for potential counterparts (Masci et al. 2019). AMPEL (Nordin et al. 2019, Stein et al. 2021) was used to search the alerts database for candidates. We reject stellar sources (Tachibana and Miller 2018) and moving objects, and apply machine learning algorithms (Mahabal et al. 2019) . We are left with the following high-significance transient candidates by our pipeline, all lying within the 90.0% localization of the skymap.\n\n+--------------------------------------------------------------------------------+\n| ZTF Name | IAU Name | RA (deg) | DEC (deg) | Filter | Mag | MagErr |\n+--------------------------------------------------------------------------------+\n| ZTF18acvhwtf | AT2020ncs | {hist_and_new_values['ZTF18acvhwtf']['ra']:011.7f} | {hist_and_new_values['ZTF18acvhwtf']['dec']:+011.7f} | r | {hist_and_new_values['ZTF18acvhwtf']['mag']:.2f} | {hist_and_new_values['ZTF18acvhwtf']['mag_err']:.2f} | {old_flag} \n| ZTF20abgvabi | AT2020ncr | 162.5306341 | +12.1461187 | g | 20.58 | 0.19 | (MORE THAN ONE DAY SINCE SECOND DETECTION) \n+--------------------------------------------------------------------------------+\n\n \n\nAmongst our candidates, \nZTF18acvhwtf was first detected on 2458461.9815278. It has a spec-z of 0.291 [{hist_and_new_values['ZTF18acvhwtf']['z_dist']:.0f} Mpc] and an abs. mag of {hist_and_new_values['ZTF18acvhwtf']['absmag']:.1f}. Distance to SDSS galaxy is {hist_and_new_values['ZTF18acvhwtf']['ned_dist_new']:.2f} arcsec. [MILLIQUAS: SDSS J104816.25+120734.7 - 'Q'-type source ({hist_and_new_values['ZTF18acvhwtf']['milliquas_dist_new']:.2f} arsec)] [TNS NAME=AT2020ncs]\nZTF20abgvabi was first detected on 2458995.6705903. WISEA J105007.28+120846.1 ['G'-type source (0.00 arsec)] [TNS NAME=AT2020ncr]\n\n\nZTF and GROWTH are worldwide collaborations comprising Caltech, USA; IPAC, USA; WIS, Israel; OKC, Sweden; JSI/UMd, USA; DESY, Germany; TANGO, Taiwan; UW Milwaukee, USA; LANL, USA; TCD, Ireland; IN2P3, France.\n\nGROWTH acknowledges generous support of the NSF under PIRE Grant No 1545949.\nAlert distribution service provided by DIRAC@UW (Patterson et al. 2019).\nAlert database searches are done by AMPEL (Nordin et al. 2019).\nAlert filtering is performed with the AMPEL Follow-up Pipeline (Stein et al. 2021).\n" + true_gcn = f"Astronomer Name (Institute of Somewhere), ............. report,\nOn behalf of the Zwicky Transient Facility (ZTF) and Global Relay of Observatories Watching Transients Happen (GROWTH) collaborations: \nWe observed the localization region of the neutrino event IceCube-200620A (Santander et. al, GCN 27997) with the Palomar 48-inch telescope, equipped with the 47 square degree ZTF camera (Bellm et al. 2019, Graham et al. 2019). We started observations in the g-band and r-band beginning at 2020-06-21 04:53 UTC, approximately 25.8 hours after event time. We covered 1.2 sq deg, corresponding to 77.7% of the reported localization region. This estimate accounts for chip gaps. Each exposure was 300s with a typical depth of 21.0 mag. \n \nThe images were processed in real-time through the ZTF reduction and image subtraction pipelines at IPAC to search for potential counterparts (Masci et al. 2019). AMPEL (Nordin et al. 2019, Stein et al. 2021) was used to search the alerts database for candidates. We reject stellar sources (Tachibana and Miller 2018) and moving objects, and apply machine learning algorithms (Mahabal et al. 2019) . We are left with the following high-significance transient candidates by our pipeline, all lying within the 90.0% localization of the skymap.\n\n+--------------------------------------------------------------------------------+\n| ZTF Name | IAU Name | RA (deg) | DEC (deg) | Filter | Mag | MagErr |\n+--------------------------------------------------------------------------------+\n| ZTF18acvhwtf | AT2020ncs | {hist_and_new_values['ZTF18acvhwtf']['ra']:011.7f} | {hist_and_new_values['ZTF18acvhwtf']['dec']:+011.7f} | r | {hist_and_new_values['ZTF18acvhwtf']['mag']:.2f} | {hist_and_new_values['ZTF18acvhwtf']['mag_err']:.2f} | {old_flag} \n| ZTF20abgvabi | AT2020ncr | 162.5306341 | +12.1461187 | g | 20.58 | 0.19 | (MORE THAN ONE DAY SINCE SECOND DETECTION) \n+--------------------------------------------------------------------------------+\n\n \n\nAmongst our candidates, \nZTF18acvhwtf was first detected on 2458461.9815278. It has a spec-z of 0.291 [{hist_and_new_values['ZTF18acvhwtf']['z_dist']:.0f} Mpc] and an abs. mag of {hist_and_new_values['ZTF18acvhwtf']['absmag']:.1f}. Distance to SDSS galaxy is {hist_and_new_values['ZTF18acvhwtf']['ned_dist_new']:.2f} arcsec. [MILLIQUAS: SDSS J104816.25+120734.7 - 'Q'-type source ({hist_and_new_values['ZTF18acvhwtf']['milliquas_dist_new']:.2f} arsec)] [TNS NAME=AT2020ncs]\nZTF20abgvabi was first detected on 2458995.6705903. WISEA J105007.28+120846.1 ['G'-type source (0.00 arsec)] [TNS NAME=AT2020ncr]\n\n\nZTF and GROWTH are worldwide collaborations comprising Caltech, USA; IPAC, USA; WIS, Israel; OKC, Sweden; JSI/UMd, USA; DESY, Germany; TANGO, Taiwan; UW Milwaukee, USA; LANL, USA; TCD, Ireland; IN2P3, France.\n\nGROWTH acknowledges generous support of the NSF under PIRE Grant No 1545949.\nAlert distribution service provided by DIRAC@UW (Patterson et al. 2019).\nAlert database searches are done by AMPEL (Nordin et al. 2019).\nAlert filtering is performed with the AMPEL Follow-up Pipeline (Stein et al. 2021).\n" print(res)