From cbbc60e9f34fb0af128076a48d978e7fa2d171e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Jul 2022 22:58:51 +0000 Subject: [PATCH 1/2] Bump numpy from 1.22.0 to 1.23.0 Bumps [numpy](https://github.com/numpy/numpy) from 1.22.0 to 1.23.0. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v1.22.0...v1.23.0) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c732cf80..4eb15b1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,10 +15,10 @@ ipykernel == 6.6.0 jupyter == 1.0.0 ligo-gracedb == 2.7.6 ligo.skymap == 0.5.3 -lxml==4.6.5 +lxml==4.9.1 matplotlib==3.5.1 mocpy==0.11.0 -numpy==1.22.0 +numpy==1.23.0 pandas==1.3.5 pre_commit == 2.17.0 python-ligo-lw==1.7.1 From 2a247037848ef910e7be368d120b25c86f3eb0ad Mon Sep 17 00:00:00 2001 From: simeonreusch Date: Sat, 9 Jul 2022 16:13:22 +0200 Subject: [PATCH 2/2] removed 1 obs in test_irsa (output has changed, don't know why), set logger to INFO for test_irsa --- nuztf/irsa.py | 41 +++++++++++++++++++++++++++++------------ tests/test_irsa.py | 7 ++++++- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/nuztf/irsa.py b/nuztf/irsa.py index 67ba7d62..375c7e57 100644 --- a/nuztf/irsa.py +++ b/nuztf/irsa.py @@ -15,7 +15,7 @@ from astropy.coordinates import SkyCoord from astropy.table import Table from astroquery.exceptions import RemoteServiceError -from astroquery.ned import Ned +from astroquery.ipac.ned import Ned from ztfquery.io import LOCALSOURCE from ztfquery.lightcurve import LCQuery @@ -27,6 +27,7 @@ from nuztf.parse_nu_gcn import find_gcn_no, parse_gcn_circular logger = logging.getLogger(__name__) +logger.setLevel("DEBUG") def format_date(t, atel=True): @@ -46,19 +47,25 @@ def format_date(t, atel=True): def load_irsa(ra_deg: float, dec_deg: float, radius_arcsec: float = 0.5, **kwargs): df = LCQuery.from_position(ra_deg, dec_deg, radius_arcsec, **kwargs).data - mask = df.catflags > 0 + print(len(df)) - flags = list(set(df.catflags)) + if len(df) == 0: + return None - logger.info( - f"Found {len(df)} datapoints, masking {np.sum(mask)} datapoints with bad flags." - ) + else: + mask = df.catflags > 0 + + flags = list(set(df.catflags)) + + logger.info( + f"Found {len(df)} datapoints, masking {np.sum(mask)} datapoints with bad flags." + ) - for flag in sorted(flags): - logger.debug(f"{np.sum(df.catflags == flag)} datapoints with flag {flag}") + for flag in sorted(flags): + logger.debug(f"{np.sum(df.catflags == flag)} datapoints with flag {flag}") - df = df.drop(df[mask].index) - return df + df = df.drop(df[mask].index) + return df def plot_irsa_lightcurve( @@ -84,6 +91,9 @@ def plot_irsa_lightcurve( if source_coords is None: + logger.info(f"Trying to resolve {source_name} and query for coordinates.") + logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO) + # Try ampel to find ZTF coordinates if is_ztf_name(name=source_name): @@ -113,6 +123,9 @@ def plot_irsa_lightcurve( # Otherwise try NED else: + logger.info( + "Source name is neither as ZTF, nor a TNS name. Querying NED instead." + ) result_table = Ned.query_object(source_name) if len(result_table) == 0: @@ -162,12 +175,13 @@ def plot_irsa_lightcurve( # Try to find a catalogue source nearby using coordinates - if np.logical_and("ZTF" in source_name, source_coords is not None): + if ("ZTF" in source_name) and source_coords: c = SkyCoord(source_coords[0], source_coords[1], unit=u.deg, frame="icrs") r = 0.5 * u.arcsecond + logger.info("Querying NED") result_table = Ned.query_region(c, radius=r) if len(result_table) == 1: @@ -207,7 +221,7 @@ def plot_irsa_lightcurve( df = pd.read_csv(cache_path) else: - + logger.info("Querying IPAC for a lightcurve") df = load_irsa(source_coords[0], source_coords[1], radius_arcsec=radius_arcsec) logger.debug(f"Saving to {cache_path}") @@ -296,6 +310,9 @@ def plot_irsa_lightcurve( if check_obs: + logger.info( + f"Getting most recent ZTF observation, looking back {check_obs_lookback_weeks} weeks." + ) mro = get_most_recent_obs( ra=source_coords[0], dec=source_coords[1], diff --git a/tests/test_irsa.py b/tests/test_irsa.py index 962c0fee..d324ee35 100644 --- a/tests/test_irsa.py +++ b/tests/test_irsa.py @@ -8,17 +8,22 @@ class TestIrsa(unittest.TestCase): def setUp(self): + logging.getLogger("irsa").setLevel(logging.INFO) self.logger = logging.getLogger(__name__) self.logger.setLevel(logging.INFO) def test_lightcurve(self): self.logger.info("\n\n Testing IRSA \n\n") + self.logger.info("Getting lightcurve from IPAC.") res = load_irsa(77.358185, 5.693148, 0.5, TIME=[58204.1, 59678.9]) res = res[res["programid"] == 1] + expected = 374 - self.assertEqual(len(res), 375) + self.logger.info(f"Found {len(res)} entries. Expected: {expected}") + + self.assertEqual(len(res), expected) src_names = ["PKS1502+106", "SN2021gpw"] nu_names = ["IC190730A", "IC211216B"]