Skip to content

sensitivity.result

The result of a sensitivity analysis.

SensitivityResult wraps an xarray.Dataset with one variable per observable and index, <observable>.<index> (e.g. auc.ST, auc.ST_conf, [S2].normalized), over (parameter, *other dimensions, [time]): the parameters of the design, every label of the other dimensions of the scan (e.g. doses, conditions) and, for a timecourse on a grid, every time point. attrs carry the units of every variable, the method, its options and the provenance of the scan.

SensitivityResult

SensitivityResult(ds)

The indices of a sensitivity analysis, see the module.

Attributes:

Name Type Description
ds

the dataset.

Wrap a dataset of indices.

Parameters:

Name Type Description Default
ds Dataset

the dataset.

required

Raises:

Type Description
ValueError

if the dataset has no dimension parameter.

units property

units

Get the unit of every variable, of parameter and of the kept coordinates.

method property

method

Get the method of the analysis, e.g. sobol.

parameters property

parameters

Get the parameters of the indices.

observables property

observables

Get the observables, in the order of their first variable.

index

index(name, observables=None)

Stack an index of the scalar observables into (parameter, observable, ...).

A timecourse is stacked at one time point, e.g. sel(time=10).index(...), which is the state after a change at the time 10, see sel.

Parameters:

Name Type Description Default
name str

the index, e.g. ST.

required
observables Sequence[str] | None

the observables, every scalar observable which has the index by default.

None

Returns:

Type Description
DataArray

The index over (parameter, observable, *other dimensions).

Raises:

Type Description
KeyError

if no scalar observable has the index.

ValueError

if observables is empty, or a named observable has no such index or is a timecourse.

sel

sel(**indexers)

Select labels, see xarray.Dataset.sel.

A single label of parameter keeps the dimension, which a result has: sel(parameter="k1") is sel(parameter=["k1"]). A single time of a change after the start, which a timecourse has twice, selects the state after the change, see at_one_time; isel selects either.

isel

isel(**indexers)

Select positions, see xarray.Dataset.isel.

A single position of parameter keeps the dimension, as in sel.

to_dataframe

to_dataframe(name)

Get a variable as a table, a row per parameter.

Parameters:

Name Type Description Default
name str

the variable, e.g. auc.ST.

required

Returns:

Type Description
DataFrame

The table; the other dimensions are its columns.

classify

classify(name)

Classify every value of an index, see sensitivity_classification.

The thresholds are the ones of the IPCS for normalized local sensitivities, which need an index without a unit (DIMENSIONLESS_INDICES), e.g. normalized, S1 or ST.

Parameters:

Name Type Description Default
name str

the variable, e.g. auc.normalized.

required

Returns:

Type Description
DataArray

The classes as strings (high, medium, low, negligible), ""

DataArray

for NaN.

Raises:

Type Description
ValueError

if the index has a unit, e.g. raw or mu_star.

to_netcdf

to_netcdf(path)

Write the result as netCDF, the attributes as JSON.

Parameters:

Name Type Description Default
path str | Path

the file.

required

from_netcdf classmethod

from_netcdf(path)

Read a result written by to_netcdf.

Parameters:

Name Type Description Default
path str | Path

the file.

required

Returns:

Type Description
SensitivityResult

The result.

at_one_time

at_one_time(data, indexers)

Select a single time which the data has twice as its state after the change.

The time of a change after the start appears twice in a timecourse, the states before and after the change; a single time selects the state after it, as a time of a grid does (sbmlsim.result.timecourse.grid_weights).

Parameters:

Name Type Description Default
data T

the data.

required
indexers dict[str, Any]

the labels to select, by dimension.

required

Returns:

Type Description
T

The data at the time, if it has it twice, and the other indexers; else

dict[str, Any]

the data and the indexers.