Skip to content

flixopt.stats_accessor

Xarray accessor for statistics and transformations (.fxstats).

Classes

DatasetStatsAccessor

DatasetStatsAccessor(xarray_obj: Dataset)

Statistics/transformation accessor for any xr.Dataset. Access via dataset.fxstats.

Provides data transformation methods that return new datasets. Chain with .plotly for visualization.

Examples:

Duration curve::

ds.fxstats.to_duration_curve().plotly.line()

Functions

to_duration_curve
to_duration_curve(*, normalize: bool = True) -> xr.Dataset

Transform dataset to duration curve format (sorted values).

Values are sorted in descending order along the 'time' dimension. The time coordinate is replaced with duration (percentage or index).

Parameters:

Name Type Description Default
normalize bool

If True, x-axis shows percentage (0-100). If False, shows timestep index.

True

Returns:

Type Description
Dataset

Transformed xr.Dataset with duration coordinate instead of time.

Example

ds.fxstats.to_duration_curve().plotly.line(title='Duration Curve')