task_geo.data_sources.noaa.noaa_api_connector module

Connector to the NOAA API.

Contributors:

The journal article describing GHCN-Daily is: Menne, M.J., I. Durre, R.S. Vose, B.E. Gleason, and T.G. Houston, 2012: An overview of the Global Historical Climatology Network-Daily Database. Journal of Atmospheric and Oceanic Technology, 29, 897-910, doi:10.1175/JTECH-D-11-00103.1.

To acknowledge the specific version of the dataset used, please cite: Menne, M.J., I. Durre, B. Korzeniewski, S. McNeal, K. Thomas, X. Yin, S. Anthony, R. Ray, R.S. Vose, B.E.Gleason, and T.G. Houston, 2012: Global Historical Climatology Network - Daily (GHCN-Daily), Version 3.26 NOAA National Climatic Data Center. http://doi.org/10.7289/V5D21VHZ [2020/03/30].

Functions

get_parse_response(urls)

Calls the urls in urls, return responses and errors

get_request_urls(country, start_date[, …])

Encodes the parameters the URL to make a GET request

get_stations_by_country(country)

Get all stations for a given country code.

noaa_api_connector(countries, start_date[, …])

Get data from NOAA API.

task_geo.data_sources.noaa.noaa_api_connector.get_parse_response(urls)[source]

Calls the urls in urls, return responses and errors

Parameters

urls (list[str]) – Urls as generated by get_request_urls.

Returns

The first element of the tuple is a list of dictionary with all the responses. The second element is a list with all the exceptions raised during the calls.

Return type

tuple[list[dict], list[Exception]]

task_geo.data_sources.noaa.noaa_api_connector.get_request_urls(country, start_date, end_date=None, metrics=None)[source]

Encodes the parameters the URL to make a GET request

Parameters
  • country (str) – FIPS Country code

  • start_date (datetime) –

  • end_date (datetime) – Defaults to today

  • metrics (list[str]) – Optional.List of metrics to retrieve,valid values are: TMIN: Minimum temperature. TMAX: Maximum temperature. TAVG: Average of temperature. SNOW: Snowfall (mm). SNWD: Snow depth (mm). PRCP: Precipitation.

Returns

str

task_geo.data_sources.noaa.noaa_api_connector.get_stations_by_country(country)[source]

Get all stations for a given country code.

Parameters

country (str) –

Returns

list[str]

task_geo.data_sources.noaa.noaa_api_connector.noaa_api_connector(countries, start_date, end_date=None, metrics=None)[source]

Get data from NOAA API.

Parameters
  • countries (list[str]) – List of FIPS country codes to retrieve.

  • start_date (datetime) –

  • end_date (datetime) –

  • metrics (list[str]) – Optional.List of metrics to retrieve,valid values are: TMIN: Minimum temperature. TMAX: Maximum temperature. TAVG: Average of temperature. SNOW: Snowfall (mm). SNWD: Snow depth (mm).

Returns

tuple[list[dict], list[Exception]]