Skip to content

Commit

Permalink
Merge pull request #321 from sot/numpy-str-deprecation
Browse files Browse the repository at this point in the history
Fix numpy str FutureWarning and modernize get_ifot slightly
  • Loading branch information
taldcroft authored Feb 14, 2024
2 parents d1b8982 + 8083445 commit d882568
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kadi/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 39 additions & 6 deletions kadi/occweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -126,11 +162,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

Expand Down

0 comments on commit d882568

Please sign in to comment.