foxes.models.turbine_models.rotor_centre_calc¶
Classes¶
Calculates data at the rotor centre |
Module Contents¶
- class foxes.models.turbine_models.rotor_centre_calc.RotorCentreCalc(calc_vars: dict[str, str] | list[str])[source]¶
Bases:
foxes.core.TurbineModelCalculates data at the rotor centre
- Parameters:¶
- calc_vars
The variables that are calculated by the model, keys: var names, values: rotor var names
-
calculate(algo: foxes.core.algorithm.Algorithm, mdata: foxes.core.data.MData, fdata: foxes.core.data.FData, st_sel: slice | numpy.ndarray =
slice(None)) dict[str, numpy.ndarray][source]¶ The main model calculation.
This function is executed on a single chunk of data, all computations should be based on numpy arrays.
-
ensure_output_vars(algo: foxes.core.algorithm.Algorithm, fdata: foxes.core.data.FData, defaults: dict[str, Any] | None =
None) None¶ Ensure the output variables are present in the farm data.
- Parameters:¶
- algo
The calculation algorithm.
- fdata
The farm data.
- defaults
Default values for the output variables. Keys are variable names, values are scalars or array-like data with shape
(n_states, n_turbines).
-
finalize(algo: foxes.core.algorithm.Algorithm, verbosity: int =
0) None¶ Finalize the model.
- Parameters:¶
- algo
The calculation algorithm.
- verbosity
The verbosity level;
0is silent.
-
get_data(variable: str, target: str, lookup: str =
'smfp', mdata: foxes.core.data.MData | None =None, fdata: foxes.core.data.FData | None =None, tdata: foxes.core.data.TData | None =None, downwind_index: int | None =None, accept_none: False =False, accept_nan: bool =True, algo: foxes.core.algorithm.Algorithm | None =None, upcast: bool =False, selection: numpy.ndarray[Any, Any] | tuple[Any, ...] | list[Any] | None =None) numpy.ndarray[Any, Any]¶ -
get_data(variable: str, target: str, lookup: str =
'smfp', mdata: foxes.core.data.MData | None =None, fdata: foxes.core.data.FData | None =None, tdata: foxes.core.data.TData | None =None, downwind_index: int | None =None, accept_none: True =True, accept_nan: bool =True, algo: foxes.core.algorithm.Algorithm | None =None, upcast: bool =False, selection: numpy.ndarray[Any, Any] | tuple[Any, ...] | list[Any] | None =None) numpy.ndarray[Any, Any] | None Getter for a data entry in the model object or provided data sources
- Parameters:¶
- variable
The variable name used as the data key.
- target
The dimensions identifier for the output:
FC.STATE_TURBINE,FC.STATE_TARGET, orFC.STATE_TARGET_TPOINT.- lookup
The order of data sources. Combination of:
's'for self,'m'for mdata,'f'for fdata,'t'for tdata, and'w'for wake-modeling data.- mdata
The model data.
- fdata
The farm data.
- tdata
The target point data.
- downwind_index
The index in the downwind order.
- accept_none
Do not raise an error if the data entry is
None.- accept_nan
Do not raise an error if the data entry is
np.nan.- algo
The algorithm, needed for data from previous iterations.
- upcast
Ensure the target dimensions are present. If expansion is needed, the result is a read-only broadcasted view.
- selection
Apply this selection to the result, for state-turbine, state-target, or state-target-tpoint outputs.
-
initialize(algo: foxes.core.algorithm.Algorithm, loaded_data: foxes.core.model.LoadedData | None =
None, force: bool =False, verbosity: int =0) foxes.core.model.LoadedData[source]¶ Initializes the model.
- Parameters:¶
- algo
The calculation algorithm
- loaded_data
Data that has already been loaded, to be extended by this function. Keys are “coords”, a dict with entries dim_name_str -> dim_array; “data_vars”, a dict with entries name_str -> (dim_tuple, data_ndarray); and “extra_data”, a dict with non-array additional data.
- force
Overwrite existing data
- verbosity
The verbosity level, 0 = silent
- Returns:¶
- loaded_data
The loaded data, containing keys “coords”, “data_vars”, and “extra_data”. Keys are “coords”, a dict with entries dim_name_str -> dim_array; “data_vars”, a dict with entries name_str -> (dim_tuple, data_ndarray); and “extra_data”, a dict with non-array additional data.
- load_chunk_data(algo: foxes.core.algorithm.Algorithm, *data: foxes.core.data.Data) None¶
Load chunk data according to the configured load mode.
This function adds data to the model data container.
- Parameters:¶
- algo
The calculation algorithm.
- data
Input data, typically either
(mdata, fdata)for farm calculations or(mdata, fdata, tdata)for point data calculations.
-
load_data(algo: foxes.core.algorithm.Algorithm, loaded_data: LoadedData, force: bool =
False, verbosity: int =0) None¶ Load and/or create all data required for model calculations.
The function adds to loaded_data.
- Parameters:¶
- algo
The calculation algorithm.
- loaded_data
Data that has already been loaded, to be extended by this function. Keys are “coords”, a dict with entries
dim_name_str -> dim_array; “data_vars”, a dict with entriesname_str -> (dim_tuple, data_ndarray); and “extra_data”, a dict with non-array additional data.- force
Overwrite existing data.
- verbosity
The verbosity level, where 0 is silent.
- classmethod new(tmodel_type: str, *args: Any, **kwargs: Any) TurbineModel¶
Create a turbine model instance at runtime.
- Parameters:¶
- tmodel_type
The selected derived class name.
- args
Additional positional arguments for the constructor.
- kwargs
Additional keyword arguments for the constructor.
- output_coords() tuple[str, ...]¶
Gets the coordinates of all output arrays
- Returns:¶
- dims
The coordinates of all output arrays
- output_farm_vars(algo: foxes.core.algorithm.Algorithm) list[str][source]¶
The variables which are being modified by the model.
- run_calculation(algo: foxes.core.algorithm.Algorithm, *data: tuple[Any, ...], out_vars: list[str], **calc_pars: Any) Any¶
Starts the model calculation in parallel, via xarray’s apply_ufunc.
Typically this function is called by algorithms.
-
set_running(algo: foxes.core.algorithm.Algorithm, data_stash: dict[str, dict[str, Any]] | None, sel: dict[str, Any] | None =
None, isel: dict[str, Any] | None =None, verbosity: int =0) None¶ Set this model to the running state and move large data to the stash.
The stashed data is restored by
unset_runningafter the calculation has finished.- Parameters:¶
- algo
The calculation algorithm.
- data_stash
The large-data stash. This function adds entries here when provided. Keys are model names and values are dictionaries of large model data.
- sel
The subset selection dictionary.
- isel
The index subset selection dictionary.
- verbosity
The verbosity level;
0is silent.
- sub_models() list[foxes.core.model.Model][source]¶
List of all sub-models
- Returns:¶
- smdls
Names of all sub models
-
unset_running(algo: foxes.core.algorithm.Algorithm, data_stash: dict[str, dict[str, Any]] | None, sel: dict[str, Any] | None =
None, isel: dict[str, Any] | None =None, verbosity: int =0) None¶ Set this model status to not running and recover large data from stash.
- Parameters:¶
- algo
The calculation algorithm.
- data_stash
Reconstruct model data from this stash when provided. Keys are model names and values are dictionaries of large model data.
- sel
The subset selection dictionary.
- isel
The index subset selection dictionary.
- verbosity
The verbosity level;
0is silent.
- property initialized : bool¶
Initialization flag.
- Returns:¶
- initialized
True if the model has been initialized.
-
load_mode =
'preload'¶
- property model_id : int¶
Unique id based on the model type.
- Returns:¶
- int
Unique id of the model object
-
name =
'Model'¶