foxes.core.states.ExtendedStates¶
- class foxes.core.states.ExtendedStates[source]¶
Bases:
States
States extended by point data models.
- Parameters:
states (foxes.core.States) – The base states to start from
point_models (list of foxes.core.PointDataModel, optional) – The point models, executed after states
- states¶
The base states to start from
- Type:
foxes.core.States
- pmodels¶
The point models, including states as first model
- Type:
foxes.core.PointDataModelList
Methods
__init__
(states[, point_models])append
(model)Add a model to the list
calculate
(algo, mdata, fdata, pdata)"
finalize
(algo[, verbosity])Finalizes the model.
get_data
(variable, data[, st_sel, upcast, ...])Getter for a data entry in either the given data source, or the model object.
index
()The index list
initialize
(algo[, verbosity])Initializes the model.
output_point_vars
(algo)The variables which are being modified by the model.
run_calculation
(algo, *data, out_vars, ...)Starts the model calculation in parallel, via xarray's apply_ufunc.
size
()The total number of states.
var
(v)Creates a model specific variable name.
weights
(algo)The statistical weights of all states.
Attributes
Initialization flag.
Unique id based on the model type.
- append(model)[source]¶
Add a model to the list
- Parameters:
model (foxes.core.PointDataModel) – The model to add
- calculate(algo, mdata, fdata, pdata)[source]¶
” The main model calculation.
This function is executed on a single chunk of data, all computations should be based on numpy arrays.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
mdata (foxes.core.Data) – The model data
fdata (foxes.core.Data) – The farm data
pdata (foxes.core.Data) – The point data
- Returns:
results – The resulting data, keys: output variable str. Values: numpy.ndarray with shape (n_states, n_points)
- Return type:
- finalize(algo, verbosity=0)[source]¶
Finalizes the model.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
verbosity (int) – The verbosity level
- get_data(variable, data, st_sel=None, upcast=None, data_prio=False, accept_none=False)¶
Getter for a data entry in either the given data source, or the model object.
- Parameters:
variable (str) – The variable, serves as data key
data (dict) – The data source
st_sel (numpy.ndarray of bool, optional) – If given, get the specified state-turbine subset
upcast (str, optional) – Either ‘farm’ or ‘points’, broadcasts potential scalar data to numpy.ndarray with dimensions (n_states, n_turbines) or (n_states, n_points), respectively
data_prio (bool) – First search the data source, then the object
accept_none (bool) – Do not throw an error if data entry is None or np.nan
- index()[source]¶
The index list
- Returns:
indices – The index labels of states, or None for default integers
- Return type:
array_like
- initialize(algo, verbosity=0)[source]¶
Initializes the model.
This includes loading all required data from files. The model should return all array type data as part of the idata return dictionary (and not store it under self, for memory reasons). This data will then be chunked and provided as part of the mdata object during calculations.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
verbosity (int) – The verbosity level, 0 = silent
- Returns:
idata – The dict has exactly two entries: data_vars, a dict with entries name_str -> (dim_tuple, data_ndarray); and coords, a dict with entries dim_name_str -> dim_array
- Return type:
- property initialized¶
Initialization flag.
- Returns:
True if the model has been initialized.
- Return type:
- property model_id¶
Unique id based on the model type.
- Returns:
Unique id of the model object
- Return type:
- run_calculation(algo, *data, out_vars, **calc_pars)¶
Starts the model calculation in parallel, via xarray’s apply_ufunc.
Typically this function is called by algorithms.
- Parameters:
- Returns:
results – The calculation results
- Return type:
xarray.Dataset
- var(v)¶
Creates a model specific variable name.