GClunies / noaa_coops

A Python wrapper for the NOAA CO-OPS Tides & Currents Data and Metadata APIs.
Apache License 2.0
82 stars 28 forks source link

KeyError saying "['flags', 'QC', 'date_time'] not found in axis" when downloading tide gage data before 1995 #33

Closed lassiterdc closed 1 year ago

lassiterdc commented 2 years ago

Hello, when I try to run the following code, I get a KeyError saying "['flags', 'QC', 'date_time'] not found in axis". This only occurs when the begin_date year is 1994 or earlier indicating to me that the format of the data changed around that time for this station. Any suggestions? My goal is to download the complete record of this tide gage starting 7/1/1927.

import noaa_coops as nc

sta = nc.Station(8638610)

lat, lon = sta.lat_lon

data_wl = sta.get_data(begin_date="19940526",
                    end_date="19950526",
                    product="water_level",
                    datum="NAVD",
                    units="english",
                    time_zone="lst"
    )
GClunies commented 1 year ago

Was able to reproduce. This is sort of related to #44. Need to better handle when the CO-OPS API does not return data for large data requests.

lassiterdc commented 1 year ago

To see if the size of the data request mattered, I retested trying to download just one day in 1994. This also failed and I am getting a new error.

import noaa_coops as nc

sta = nc.Station("8638610")

lat, lon = sta.lat_lon

data_wl = sta.get_data(begin_date="19940526",
                    end_date="19940527",
                    product="water_level",
                    datum="NAVD",
                    units="english",
                    time_zone="lst"
    )
COOPSAPIError: No data was found. This product may not be offered at this station at the requested time.
GClunies commented 1 year ago

@lassiterdc see my comment here: https://github.com/GClunies/noaa_coops/issues/44#issuecomment-1513367153

TLDR - try using product=hourly_height instead of product=water_level.

lassiterdc commented 1 year ago

I see, thanks a lot!