From 82a946fd7d549ed51568e7f88af38fd33540038c Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 14 Feb 2024 06:41:35 -0500 Subject: [PATCH 1/2] Fix numpy.str FutureWarning --- kadi/events/models.py | 2 +- kadi/occweb.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/kadi/events/models.py b/kadi/events/models.py index b746c997..7f3ba0a6 100644 --- a/kadi/events/models.py +++ b/kadi/events/models.py @@ -2367,7 +2367,7 @@ class DsnComm(IFotEvent): "soe", "station", ] - ifot_types = {"DSN_COMM.bot": "str", "DSN_COMM.eot": "str"} + ifot_types = {"DSN_COMM.bot": str, "DSN_COMM.eot": str} lookback = 21 # days of lookback lookback_delete = 7 # Remove all comms in database prior to 7 days ago to account diff --git a/kadi/occweb.py b/kadi/occweb.py index 69bdc7dd..e750b730 100644 --- a/kadi/occweb.py +++ b/kadi/occweb.py @@ -126,11 +126,8 @@ def get_ifot( text = re.sub(r"\r\n", " ", text) lines = [x for x in text.split("\t\n") if x.strip()] - converters = { - key: [ascii.convert_numpy(getattr(np, type_))] for key, type_ in types.items() - } dat = ascii.read( - lines, format="tab", guess=False, converters=converters, fill_values=None + lines, format="tab", guess=False, converters=types, fill_values=None ) return dat From 80834453bf4d9dc7dac0b9a5d8ae73e6bde8c375 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 14 Feb 2024 06:43:20 -0500 Subject: [PATCH 2/2] Moderize get_ifot a bit --- kadi/occweb.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/kadi/occweb.py b/kadi/occweb.py index e750b730..7860eef7 100644 --- a/kadi/occweb.py +++ b/kadi/occweb.py @@ -13,7 +13,6 @@ from pathlib import Path import configobj -import numpy as np import requests from astropy.io import ascii from astropy.table import Table @@ -99,10 +98,47 @@ def get_url(page, timeout=TIMEOUT): def get_ifot( - event_type, start=None, stop=None, props=[], columns=[], timeout=TIMEOUT, types={} + event_type, + start=None, + stop=None, + props=None, + columns=None, + timeout=TIMEOUT, + types=None, ): + """Get the iFOT event table for a given event type. + + Parameters + ---------- + event_type : str + Event type (e.g. "ECLIPSE", "LOADSEG", "CAP") + start : str, CxoTimeLike + Start time for query + stop : str, CxoTimeLike + Stop time for query + props : list of str + List of iFOT properties to return + columns : list of str + List of columns to return + timeout : float + Timeout for the request + types : dict + Dictionary of column types + + Returns + ------- + dat : astropy.table.Table + Table of iFOT events + """ start = DateTime("1998:001:12:00:00" if start is None else start) stop = DateTime(stop) + if props is None: + props = [] + if columns is None: + columns = [] + if types is None: + types = {} + event_props = ".".join([event_type] + props) params = odict(