stompy.io.local — Methods for regional and local data sources¶
Submodules¶
stompy.io.local.noaa_coops module¶
-
stompy.io.local.noaa_coops.
coops_dataset
(station, start_date, end_date, products, days_per_request=None, cache_dir=None)[source]¶ bare bones retrieval script for NOAA Tides and Currents data. In particular, no error handling yet, doesn’t batch requests, no caching, can’t support multiple parameters, no metadata, etc.
days_per_request: break up the request into chunks no larger than this many days. for hourly data, this should be less than 365. for six minute, I think the limit is 32 days.
-
stompy.io.local.noaa_coops.
coops_dataset_product
(station, product, start_date, end_date, days_per_request='M', cache_dir=None, refetch_incomplete=True, clip=True)[source]¶ Retrieve a single data product from a single station. station: string or numeric identifier for COOPS station product: string identifying the variable to retrieve, such as “water_level”.
See all_products at the top of this file.start_date,end_date: period to retrieve, as python datetime, matplotlib datenum, or numpy datetime64. days_per_request: batch the requests to fetch smaller chunks at a time. if this is an integer, then chunks will start with start_date, then start_date+days_per_request, etc.
if this is a string, it is interpreted as the frequency argument to pandas.PeriodIndex.so ‘M’ will request month-aligned chunks. this has the advantage that requests for different start dates will still be aligned to integer periods, and can reuse cached data.
- cache_dir: if specified, save each chunk as a netcdf file in this directory,
- with filenames that include the gage, period and products. The directory must already exist.
returns an xarray dataset, or None if no data could be fetched
- refetch_incomplete: if True, if a dataset is pulled from cache but appears incomplete
- with respect to the start_date and end_date, attempt to fetch it again. Not that incomplete here is meant for realtime data which has not yet been recorded, so the test is only between end_date and the last time stamp of retrieved data.
clip: if true, return only data within the requested window, even if more data was fetched.