DataProvider

class glotaran.optimization.data_provider.DataProvider(scheme: Scheme, dataset_group: DatasetGroup)[source]

Bases: object

A class to provide prepared data for optimization.

Initialize a data provider for a scheme and a dataset_group.

Parameters:
  • scheme (Scheme) – The optimization scheme.

  • dataset_group (DatasetGroup) – The dataset group.

Methods Summary

add_model_weight

Add model weight to data.

get_axis_slice_from_interval

Get a slice of indices from a min max tuple and for an axis.

get_data

Get data for a dataset.

get_flattened_data

Get flattened data for a dataset.

get_flattened_weight

Get flattened weight for a dataset.

get_from_dataset

Get a copy of data from a dataset with dimensions (model, global).

get_global_axis

Get the global axis for a dataset.

get_global_dimension

Get the global dimension for a dataset.

get_model_axis

Get the model axis for a dataset.

get_model_dimension

Get the model dimension for a dataset.

get_weight

Get weight for a dataset.

infer_global_dimension

Infer the name of the global dimension from tuple of dimensions.

Methods Documentation

add_model_weight(model: Model, dataset_label: str, model_dimension: str, global_dimension: str)[source]

Add model weight to data.

Parameters:
  • model (Model) – The model.

  • dataset_label (str) – The label of the data.

  • model_dimension (str) – The model dimension.

  • global_dimension (str) – The global dimension.

static get_axis_slice_from_interval(interval: tuple[float, float], axis: ArrayLike) slice[source]

Get a slice of indices from a min max tuple and for an axis.

Parameters:
  • interval (tuple[float, float]) – The min max tuple.

  • axis (ArrayLike) – The axis to slice.

Returns:

The slice of indices.

Return type:

slice

get_data(dataset_label: str) ArrayLike[source]

Get data for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The data.

Return type:

ArrayLike

get_flattened_data(dataset_label: str) ArrayLike[source]

Get flattened data for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The flattened data.

Return type:

ArrayLike

get_flattened_weight(dataset_label: str) ArrayLike | None[source]

Get flattened weight for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The flattened weight.

Return type:

ArrayLike | None

static get_from_dataset(dataset: xr.Dataset, name: str, model_dimension: str, global_dimension: str) ArrayLike | None[source]

Get a copy of data from a dataset with dimensions (model, global).

Parameters:
  • dataset (xr.Dataset) – The dataset to retrieve from.

  • name (str) – The name of the data to retrieve.

  • model_dimension (str) – The model dimension.

  • global_dimension (str) – The global dimension.

Returns:

The copy of the data. None if name is not present in dataset.

Return type:

ArrayLike | None

get_global_axis(dataset_label: str) ArrayLike[source]

Get the global axis for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The global axis.

Return type:

ArrayLike

get_global_dimension(dataset_label: str) str[source]

Get the global dimension for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The global dimension.

Return type:

str

get_model_axis(dataset_label: str) ArrayLike[source]

Get the model axis for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The model axis.

Return type:

ArrayLike

get_model_dimension(dataset_label: str) str[source]

Get the model dimension for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The model dimension.

Return type:

str

get_weight(dataset_label: str) ArrayLike | None[source]

Get weight for a dataset.

Parameters:

dataset_label (str) – The label of the data.

Returns:

The weight.

Return type:

ArrayLike | None

static infer_global_dimension(model_dimension: str, dimensions: tuple[str]) str[source]

Infer the name of the global dimension from tuple of dimensions.

Parameters:
  • model_dimension (str) – The model dimension.

  • dimensions (tuple[str]) – The dimensions tuple to infer from.

Returns:

The inferred name of the global dimension.

Return type:

str