class foxes.core.Algorithm(foxes.core.Model)[source]

Abstract base class for algorithms.

Algorithms collect required objects for running calculations, and contain the calculation functions which are meant to be called from top level code.

Attributes

mbook: foxes.models.ModelBook

The model book

farm: foxes.WindFarm

The wind farm

chunks: dict

The chunks choice for running in parallel with dask, e.g. {“state”: 1000} for chunks of 1000 states

verbosity: int

The verbosity level, 0 means silent

dbook: foxes.DataBook

The data book, or None for default

Public members

Algorithm(mbook, farm, chunks, verbosity, dbook=None)[source]

Constructor.

print(*args, vlim=1, **kwargs)[source]

Print function, based on verbosity.

chunked(ds)[source]
initialize()[source]

Initializes the algorithm.

property idata_mem

The current idata memory

store_model_data(model, idata, force=False)[source]

Store model data

get_model_data(model)[source]

Gets model data from memory

del_model_data(model)[source]

Remove stored model data

update_n_turbines()[source]

Reset the number of turbines, according to self.farm

get_models_idata()[source]

Returns idata object of models

get_models_data(idata=None)[source]

Creates xarray from model input data.

new_point_data(points, states_indices=None)[source]

Creates a point data xarray object, containing only points.

finalize(clear_mem=False)[source]

Finalizes the algorithm.

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

Run-time algorithm factory.

__repr__()[source]

Return repr(self).

property model_id

Unique id based on the model type.

var(v)[source]

Creates a model specific 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.

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

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

data_to_store(name, algo, data)[source]

Adds data from mdata to the local store, intended for iterative runs.

from_data_or_store(name, algo, data, ret_dims=False, safe=False)[source]

Get data from mdata or local store