h2integrate.resource.wind.openmeteo_wind#
Classes
|
Configuration class to download wind resource data from Open-Meteo Weather API. |
|
- class h2integrate.resource.wind.openmeteo_wind.OpenMeteoHistoricalWindAPIConfig(*, latitude, longitude, timezone, use_fixed_resource_location=True, resource_year, dataset_desc='openmeteo_archive', resource_type='wind', valid_intervals=NOTHING, resource_data={}, resource_filename='', resource_dir=None)#
Configuration class to download wind resource data from Open-Meteo Weather API.
- Parameters:
resource_year (int) -- Year to use for resource data. Must been between 1940 the year before the current calendar year. (inclusive).
resource_data (dict | object, optional) -- Dictionary of user-input resource data. Defaults to an empty dictionary.
resource_dir (str | Path, optional) -- Folder to save resource files to or load resource files from. Defaults to "".
resource_filename (str, optional) -- Filename to save resource data to or load resource data from. Defaults to None.
latitude (float)
longitude (float)
timezone (int | float)
use_fixed_resource_location (bool)
dataset_desc (str)
resource_type (str)
valid_intervals (list[int])
- dataset_desc#
description of the dataset, used in file naming. For this dataset, the dataset_desc is "openmeteo_archive".
- Type:
str
- resource_type#
type of resource data downloaded, used in folder naming. For this dataset, the resource_type is "wind".
- Type:
str
- valid_intervals#
time interval(s) in minutes that resource data can be downloaded in. For this dataset, valid_intervals is 60 minutes.
- Type:
list[int]
- resource_year: int#
- dataset_desc: str#
- resource_type: str#
- valid_intervals: list[int]#
- resource_data: dict | object#
- resource_filename: Path | str#
- resource_dir: Path | str | None#
- class h2integrate.resource.wind.openmeteo_wind.OpenMeteoHistoricalWindResource(**kwargs)#
- setup()#
Declare inputs and outputs.
- Available attributes:
name pathname comm options
- create_filename(latitude, longitude)#
Create default filename to save downloaded data to. Filename is formatted as "{latitude}_{longitude}_{resource_year}_openmeteo_archive_{interval}min_{tz_desc}_tz.csv" where "tz_desc" is "utc" if the timezone is zero, or "local" otherwise.
- Parameters:
latitude (float) -- latitude corresponding to location for resource data
longitude (float) -- longitude corresponding to location for resource data
- Returns:
str -- filename for resource data to be saved to or loaded from.
- create_url(latitude, longitude)#
Create url for data download.
- Parameters:
latitude (float) -- latitude corresponding to location for resource data
longitude (float) -- longitude corresponding to location for resource data
- Returns:
str -- url to use for API call.
- download_data(url, fpath)#
Download data from url to a file.
- Parameters:
url (dict) -- input parameters for API call.
fpath (Path | str) -- filepath to save data to.
- Returns:
bool -- True if data was downloaded successfully, False if error was encountered.
- load_data(fpath)#
Load data from a file and format as a dictionary that:
follows naming convention described in WindResourceBaseAPIModel.
is converted to standardized units described in WindResourceBaseAPIModel.
This method does the following steps:
load the data, separate out scalar data and timeseries data
remove unused data
- Rename the data columns to standardized naming convention and create dictionary of
OpenMDAO compatible units for the data. Calls format_timeseries_data() method.
Convert data to standardized units. Calls compare_units_and_correct() method
- Parameters:
fpath (str | Path) -- filepath to file containing the data
- Returns:
dict -- dictionary of data in standardized units and naming convention. Time information is found in the 'time' key.
- format_timeseries_data(data)#
Convert data to a dictionary with keys that follow the standardized naming convention and create a dictionary containing the units for the data.
- Parameters:
data (pd.DataFrame) -- Dataframe of timeseries data.
- Returns:
2-element tuple containing
- data (dict): data dictionary with keys following the standardized naming
convention.
- data_units (dict): dictionary with same keys as data and values as the
data units in OpenMDAO compatible format.
- compute(inputs, outputs, discrete_inputs, discrete_outputs)#
Compute outputs given inputs. The model is assumed to be in an unscaled state.
An inherited component may choose to either override this function or to define a compute_primal function.
- Parameters:
inputs (Vector) -- Unscaled, dimensional input variables read via inputs[key].
outputs (Vector) -- Unscaled, dimensional output variables read via outputs[key].
discrete_inputs (dict-like or None) -- If not None, dict-like object containing discrete input values.
discrete_outputs (dict-like or None) -- If not None, dict-like object containing discrete output values.