Skip to content

Commit

Permalink
Bugfix for fetching COOPS prediction results
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA committed Sep 11, 2023
1 parent bdecbc8 commit 0025af3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions searvey/coops.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,15 @@ def data(self) -> DataFrame:
response = requests.get(self.URL, params=self.query)
data = response.json()
fields = ["t", "v", "s", "f", "q"]
if "error" in data or "data" not in data:
if "error" in data or not ("data" in data or "predictions" in data):
if "error" in data:
self.__error = data["error"]["message"]
data = DataFrame(columns=fields)
else:
data = DataFrame(data["data"], columns=fields)
key = "data"
if "predictions" in data:
key = "predictions"
data = DataFrame(data[key], columns=fields)
data[data == ""] = numpy.nan
data = data.astype(
{"v": numpy.float32, "s": numpy.float32, "f": "string", "q": "string"},
Expand Down

0 comments on commit 0025af3

Please sign in to comment.