Giter Club home page Giter Club logo

Comments (3)

GClunies avatar GClunies commented on May 30, 2024 1

@wrightky deleting my previous comment so it does not mislead others.

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

The issue here is that while the CO-OPS API product hourly_height is available prior to 1996 ...

from pprint import pprint
import noaa_coops as nc

station = nc.Station("8771510")

hourly_height = station.get_data(
    begin_date="19951201 00:00",
    end_date="19951231 00:00",
    product="hourly_height",
    datum="MSL",
    units="english",
    time_zone="gmt",
)
pprint(hourly_height)
#                      hourly_height  sigma flags
# date_time
# 1995-12-01 00:00:00         -0.207    0.0   0,0
# 1995-12-01 01:00:00         -0.016    0.0   0,0
# 1995-12-01 02:00:00          0.223    0.0   0,0
# 1995-12-01 03:00:00          0.384    0.0   0,0
# 1995-12-01 04:00:00          0.535    0.0   0,0
# ...                            ...    ...   ...
# 1995-12-27 19:00:00         -1.476    0.0   0,0
# 1995-12-27 22:00:00         -1.375    0.0   0,0
# 1995-12-27 23:00:00         -0.886    0.0   0,0
# 1995-12-30 17:00:00          0.673    0.0   0,0
# 1995-12-30 19:00:00          0.692    0.0   0,0

... the product water_level is NOT available. NOAA confirmed that no station has water levels prior to 1996. I am adding some checks on the arguments provided to station.get_data() and updating the error messages when the API returns no data, particularly for water level data so that the user is directed to try the hourly_height product instead.

water_level = station.get_data(
        begin_date="19951201 00:00",
        end_date="19951231 00:00",
        product="water_level",
        datum="MSL",
        units="english",
        time_zone="gmt",
    )

# Traceback (most recent call last):
#   File "/Users/gclunies/Repos/noaa_coops/noaa_coops/station.py", line 1023, in <module>
#     data2 = station.get_data(
#   File "/Users/gclunies/Repos/noaa_coops/noaa_coops/station.py", line 693, in get_data
#     df = self._make_api_request(data_url, product)
#   File "/Users/gclunies/Repos/noaa_coops/noaa_coops/station.py", line 425, in _make_api_request
#     raise COOPSAPIError(message=err_msg)
# noaa_coops.station.COOPSAPIError: CO-OPS API returned an error: No data was found. This product may not be offered at this station at the requested time.
# 
# NOTE: `water_levels` product is only available from 1996 and onwards.

So what you see in the CO-OPS website is data for the hourly_height product, not water_level. In fact, the API completely ignores the interval parameter when requesting water_level data which is always reported on the 6-min interval.

image

from noaa_coops.

wrightky avatar wrightky commented on May 30, 2024

Ah! This makes perfect sense, and seems obvious in retrospect. I did not realize there was a formal distinction in the API between "hourly water level" and "hourly height" – not a super user-friendly distinction, but at least a simple one to fix. Looking back at the data inventory, I can see now that 6-minute water levels start on 1996-01-01, which should have been a clue as to what was happening.

Thank you for looking into this, I'm glad that the solution is straightforward. If possible, I suppose it would be a helpful enhancement if the combined choices of product='water_level', interval='h', and date<1996 would auto-redirect to a request for hourly_height, but an informative error message would also do the job. Thanks again!

from noaa_coops.

GClunies avatar GClunies commented on May 30, 2024

addressed in #47

from noaa_coops.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.