awherepy.agronomics

A module to access and retrieve aWhere agronomics data.

awherepy.agronomics.get_agronomic_norms(key, secret, kwargs=None)[source]

Gets historical agronomic norms data from the aWhere API.

API reference: https://docs.awhere.com/knowledge-base-docs/agronomics/

Parameters
  • key (str) – API key for a valid aWhere API application.

  • secret (str) – API secret for a valid aWhere API application.

  • kwargs (dict, optional) –

    Keyword arguments for different query parameters. Running the function without kwargs will use the default values. Arguments include:

    input_type: str

    Type of data, agronomics API by geolocation or API by field. Valid options include ‘location’ and ‘field’. Default value is ‘location’.

    location: tuple of float

    Tuple containing the location (longitude, latitude) that the API gets data from. For use with the ‘location’ input_type. Default value is (-105.648222, 40.313250), for Bear Lake, CO.

    field_id: str

    Field ID for a valid aWhere field associated with the input API key/secret. For use with the ‘field’ input_type. Default value is None.

    start_date: str

    Start date for the agronomic norms data to be retrieved. Formatted ‘MM-DD’. All days of the year are valid, from ‘01-01’ to ‘12-31’. Default value is ‘01-01’.

    end_date: str

    End date for the agronomic norms data to be retrieved. Formatted ‘MM-DD’. All days of the year are valid, from ‘01-01’ to ‘12-31’. Default value is None.

    limit: int

    Number of results in the API response per page. Used with offset kwarg to sort through pages of results (cases where the number of results exceeds the limit per page). Applicable when the number of results exceeds 1. Maximum value is 10. Default value is 10.

    offset: int

    Number of results in the API response to skip. Used with limit kwarg to sort through pages of results (cases where the number of results exceeds the limit per page). Applicable when the number of results exceeds 1. Default value is 0 (start with first result).

Returns

norms_gdf – Geotdataframe(s) containing the historical agronomic norms data for the specified location or aWhere field, for the specified date(s). Single-day inputs return a single geodataframe. Multi-day inputs return a tuple of geodataframes (total norms, daily norms).

Return type

geopandas geodataframe or tuple of geodataframes

Example

>>> # Imports
>>> import os
>>> import awherepy as aw
>>> import awherepy.agronomics as awa
>>> # Get aWhere API key and secret
>>> awhere_api_key = os.environ.get('AWHERE_API_KEY')
>>> awhere_api_secret = os.environ.get('AWHERE_API_SECRET')
>>> # Get historical norms with default kwargs (Bear Lake, CO)
>>> bear_lake_norms = awa.get_agronomic_norms(
...     key=awhere_api_key, secret=awhere_api_secret)
>>> # Check number of entries in geodataframe
>>> len(bear_lake_norms)
1
>>> # Define non-default kwargs (Manchester Center, Vermont)
>>> # Define kwargs for Manchester, Vermont
>>> vt_kwargs = {
...     'location': (-73.0723269, 43.1636875),
...     'start_date': '05-10',
...     'end_date': '05-19'
... }
>>> # Get historical norms for Manchester, Vermont
>>> vt_total_norms, vt_daily_norms = awa.get_agronomic_norms(
...     key=awhere_api_key,
...     secret=awhere_api_secret,
...     kwargs=vt_kwargs
... )
>>> # Check number entries in geodataframe
>>> len(vt_total_norms)
10
awherepy.agronomics.get_agronomic_values(key, secret, kwargs=None)[source]

Gets historical agronomic values (forecast and observed) data from the aWhere API.

API reference: https://docs.awhere.com/knowledge-base-docs/agronomics/

Parameters
  • key (str) – API key for a valid aWhere API application.

  • secret (str) – API secret for a valid aWhere API application.

  • kwargs (dict, optional) –

    Keyword arguments for different query parameters. Running the function without kwargs will use the default values. Arguments include:

    input_type: str

    Type of data, agronomics API by geolocation or API by field. Valid options include ‘location’ and ‘field’. Default value is ‘location’.

    location: tuple of float

    Tuple containing the location (longitude, latitude) that the API gets data from. For use with the ‘location’ input_type. Default value is (-105.648222, 40.313250), for Bear Lake, CO.

    field_id: str

    Field ID for a valid aWhere field associated with the input API key/secret. For use with the ‘field’ input_type. Default value is None.

    start_date: str

    Start date for the agronomic values data to be retrieved. Formatted ‘YYYY-MM-DD’. All days of the year are valid, from ‘YYYY-01-01’ to ‘YYYY-12-31’. Default value is the current day.

    end_date: str

    End date for the agronomic values data to be retrieved. Formatted ‘MM-DD’. All days of the year are valid, from ‘YYYY-01-01’ to ‘YYYY-12-31’. Default value is None.

    limit: int

    Number of results in the API response per page. Used with offset kwarg to sort through pages of results (cases where the number of results exceeds the limit per page). Applicable when the number of results exceeds 1. Maximum value is 10. Default value is 10.

    offset: int

    Number of results in the API response to skip. Used with limit kwarg to sort through pages of results (cases where the number of results exceeds the limit per page). Applicable when the number of results exceeds 1. Default value is 0 (start with first result).

Returns

values_gdf – Geotdataframe(s) containing the agronomics data (forecast or observed) data for the specified location or aWhere field, for the specified date(s). Single-day inputs return a single geodataframe. Multi-day inputs return a tuple of geodataframes (total values, daily values).

Return type

geopandas geodataframe or tuple of geodataframes

Example

>>> # Imports
>>> import os
>>> import awherepy as aw
>>> import awherepy.agronomics as awa
>>> # Get aWhere API key and secret
>>> awhere_api_key = os.environ.get('AWHERE_API_KEY')
>>> awhere_api_secret = os.environ.get('AWHERE_API_SECRET')
>>> # Get historical norms with default kwargs (Bear Lake, CO)
>>> bear_lake_values = awa.get_agronomic_values(
...     key=awhere_api_key, secret=awhere_api_secret)
>>> # Check number of entries in geodataframe
>>> len(bear_lake_norms)
1
>>> # Define non-default kwargs (Manchester Center, Vermont)
>>> # Define kwargs for Manchester, Vermont
>>> vt_kwargs = {
...     'location': (-73.0723269, 43.1636875),
...     'start_date': '2020-05-10',
...     'end_date': '2020-05-19'
... }
>>> # Get historical norms for Manchester, Vermont
>>> vt_total_values, vt_daily_values = awa.get_agronomic_values(
...     key=awhere_api_key,
...     secret=awhere_api_secret,
...     kwargs=vt_kwargs
... )
>>> # Check number entries in geodataframe
>>> len(vt_total_norms)
10