Class Methods and Shortcut Functions

class usgs.gage(site_code=None, time_period='P7D', url_params={})[source]
__init__(site_code=None, time_period='P7D', url_params={})[source]
Parameters:
  • site_code – A USGS Site code for the gage this object represents. See the USGS documentation
  • time_period – A compatible period string as specified in the USGS time period documentation - this parameter only accepts “period” values as explained in that documentation. If you would like to specify a time range using startDT and endDT please use the url_params argument. If you specify both, current behavior uses the time period as being more specific. An exception will not be raised.
  • url_params – A dictionary of other parameters to pass to the USGS server in key/value format. They will be automatically added to the query. Case sensitive. For a full list of parameters, see the USGS web service documentation
retrieve(return_pandas=False, automerge=True)[source]

Retrieves data from the server based upon class configuration. Returns the a list of dicts by default, with keys set by the returned data from the server. If return_pandas is True, returns a pandas data frame.

Parameters:
  • return_pandas – specifies whether or not to return the pandas object. When True, returns a pandas object. When False, returns the default list of dicts. If True and you have not installed pandas, will raise ValueError
  • automerge – Not yet implemented! Warning! Intent is that when returning a pandas table, automerge will allow you to run multiple separate requests for the same gage (different time series with gaps, etc) and merge them into a single result for the gage
check_params(params=('site_code', ))[source]

Makes sure that we have the base level of information necessary to run a query to prevent lazy setup errors

usgs.retrieve_flow(gage_id=None, return_pandas=False)[source]

Helper function that initializes the gage for you, runs the necessary methods, and returns the table (list of dicts). Takes no date limiters so default is used. If you need to specify dates, please use the gage class.

Parameters:
  • gage_id – The USGS id for the gage
  • return_pandas – specifies whether or not to return the pandas object. When True, returns a pandas object. When False, returns the default list of dicts. If True and you have not installed pandas, will raise ValueError

Project Versions

Previous topic

USGS API Wrapper documentation

This Page