Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/setuptools-63.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonreusch authored Jul 11, 2022
2 parents 2488ab4 + ee987bc commit e94f2c9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
1 change: 0 additions & 1 deletion nuztf/irsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
57 changes: 34 additions & 23 deletions nuztf/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]])

Expand Down
2 changes: 1 addition & 1 deletion tests/test_neutrino_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
Expand Down

0 comments on commit e94f2c9

Please sign in to comment.