weatherdotgov.agent module¶
-
class
weatherdotgov.agent.
WeatherDotGovAgent
(**kwargs)[source]¶ Bases:
volttron.platform.agent.base_weather.BaseWeatherAgent
Concrete implementation of the base weather agent for querying the NOAA/weather.gov weather api.
-
static
generate_response_error
(url, response_code)[source]¶ raises a descriptive runtime error based on the response code returned by a service. :param url: actual url used for requesting data from weather.gov :param response_code: Http response code returned by a service following a request
-
get_api_description
(service_name)[source]¶ Provides the api description string for a given api service. Primarily used during concrete agent startup. :param service_name: name of the api service :return: string describing the function of the api endpoint, along with rpc call usage for the weather agent.
-
static
get_gridpoints_str
(location_dict)[source]¶ Converts a location dictionary using gridpoints format into string format to be used in a request url. :param location_dict: location dictionary for the upcoming request. Expects gridpoint format :return: url formatted location string
-
static
get_lat_long_str
(location_dict)[source]¶ Converts a location dictionary using lat/long format into string format to be used in a request url. :param location_dict: location dictionary for the upcoming request. Expects lat/long :return: url formatted location string
-
get_location_string
(location)[source]¶ Generic conversion of location dictionary into corresponding string format for request url. :param location: location dictionary formatted as for a specific request. :return: string representation of location dictionary for request url.
-
get_point_name_defs_file
()[source]¶ Constructs the point name mapping dict from the mapping csv. :return: dictionary containing a mapping of service point names to standard point names with optional
-
static
get_station_str
(location_dict)[source]¶ Converts a location dictionary using station format into string format to be used in a request url. :param location_dict: location dictionary for the upcoming request. Expects station id :return: url formatted location string
-
get_update_interval
(service_name)[source]¶ Get the timedelta between api service updates. :param service_name: name of service stored in api_services :return: datetime.timedelta object representing the time between the api’s service updates
-
query_current_weather
(location)[source]¶ Abstract method for sending/receiving requests for current weather data from an api service :param location: location for which to query the remote api :return: dictionary containing a single record of current weather data
-
query_forecast_service
(service, location, quantity, forecast_start)[source]¶ Queries a remote api service. Available services are determined per weather agent implementation :param service: The desired service end point to query :param location: The desired location for retrieval of weather records :param quantity: number of records to fetch from the service :param forecast_start: forecast results that are prior to this
timestamp will be filtered by base weather agent
- Returns
A list of time series forecast records to be processed and
stored
-
query_hourly_forecast
(location)[source]¶ Abstract method for sending/receiving requests for forecast weather data from an api service :param location: location for which to query the remote api :return: list of dictionaries containing weather data corresponding to forecast timestamp
-
query_hourly_historical
(location, start_date, end_date)[source]¶ Unimplemented method stub :param location: no format currently determined for history. :param start_date: Starting date for historical weather period. :param end_date: Ending date for historical weather period. :return: NotImplementedError
-
validate_location
(service_name, location)[source]¶ Intermediate method for validating location dicts passed by rpc calls. Validity depends on the service being requested. :param service_name: name of the api service which the location dictionary is intended to be used for. :param location: location dictionary to validate for the api service :return: boolean indicating whether the location/service combination is valid for the weather api.
-
validate_location_formats
(accepted_formats, location)[source]¶ Regular expression comparision to validate the various location dictionary formats :param accepted_formats: string representations of the acceptable location formats for an api service :param location: location dictionary to validate for the api service :return: boolean representing the validity of the location
-
static
-
weatherdotgov.agent.
weather_agent
(config_path, **kwargs)[source]¶ Used for instantiating the WeatherDotGov agent. :param config_path: string formatted file path to use for configuring the agent. :param kwargs: keyword arguments passed during instantiation. :return: an instance of the WeatherDotGov Agent