class foxes.models.turbine_models.Calculator(foxes.core.TurbineModel)[source]

Calculates variables based on given functions.

Attributes

in_vars: list of str

The input farm variables

out_vars: list of str

The output variables

func: Function

The function: f(in0, in1, …, algo, mdata, fdata, st_sel) -> (out0, out1, …) where inX and outY are numpy.ndarrays and st_sel is the state-turbine selection slice or array. All arrays have shape (n_states, n_turbines).

Beware that the turbine ordering in fdata is in downwind order, hence external data X of shape (n_states, n_turbines) in farm order needs to be reordered by X[ssel, order] with ssel = fdata[FV.ORDER_SSEL], order = fdata[FV.ORDER] before using it in combination with fdata variables.

Public members

Calculator(in_vars, out_vars, func, **kwargs)[source]

Constructor.

__repr__()[source]

Return repr(self).

output_farm_vars(algo)[source]

The variables which are being modified by the model.

calculate(algo, mdata, fdata, st_sel)[source]

The main model calculation.

classmethod new(tmodel_type, *args, **kwargs)[source]

Run-time turbine model factory.

output_coords()[source]

Gets the coordinates of all output arrays

ensure_output_vars(algo, fdata)[source]

Ensures that the output variables are present in the farm data.

run_calculation(algo, *data, out_vars, **calc_pars)[source]

Starts the model calculation in parallel, via xarray’s apply_ufunc.

property model_id

Unique id based on the model type.

var(v)[source]

Creates a model specific variable name.

unvar(vnm)[source]

Translates model specific variable name to origninal variable name.

property initialized

Initialization flag.

sub_models()[source]

List of all sub-models

load_data(algo, verbosity=0)[source]

Load and/or create all model data that is subject to chunking.

initialize(algo, verbosity=0, force=False)[source]

Initializes the model.

property running

Flag for currently running models

set_running(algo, data_stash, sel=None, isel=None, verbosity=0)[source]

Sets this model status to running, and moves all large data to stash.

unset_running(algo, data_stash, sel=None, isel=None, verbosity=0)[source]

Sets this model status to not running, recovering large data from stash

finalize(algo, verbosity=0)[source]

Finalizes the model.

get_data(variable, target, lookup='smfp', mdata=None, ...)[source]

Getter for a data entry in the model object or provided data sources