linopy.piecewise.Slopes#
- class linopy.piecewise.Slopes(values, y0=0.0, align='pieces', dim=None)#
Per-piece slopes + initial y-value, deferred until an x grid is known.
Used as the second element of a tuple in
add_piecewise_formulation(). When anySlopestuple is present, exactly one other tuple must carry explicit breakpoints — that tuple’s values are the x grid against which allSlopesare integrated:m.add_piecewise_formulation( (power, [0, 30, 60, 100]), # the x grid (fuel, Slopes([1.2, 1.4, 1.7], y0=0)), # integrated against power )
With two or more non-
Slopestuples there is no canonical x axis, and the call raisesValueError. Resolve theSlopesexplicitly viato_breakpoints()in that case, or for any standalone use:bp = Slopes([1.2, 1.4, 1.7], y0=0).to_breakpoints([0, 30, 60, 100])
- Parameters:
values (
BreaksLike) – Per-piece slopes. 1D for shared breakpoints; 2D (DataFrame / dict / DataArray with entity dim) for per-entity slopes.y0 (
float,dict,pd.Series, orDataArray, default0.0) – y-value at the first breakpoint. Scalar broadcasts to all entities; dict/Series/DataArray provides per-entity values.align (
{"pieces", "leading"}, default"pieces") – Alignment ofvaluesrelative to the x grid."pieces":len(values) == len(x_points) - 1;values[i]is the slope betweenx[i]andx[i+1]."leading":len(values) == len(x_points);values[0]must be NaN and is dropped,values[i]fori>=1is the slope betweenx[i-1]andx[i]. Useful when a marginal value is tabulated alongside each breakpoint with the first row’s marginal undefined.
dim (
str, optional) – Entity dimension name. Required whenvaluesis apd.DataFrameordict.
- Warns:
EvolvingAPIWarning –
Slopesis part of the newly-added piecewise API. Its constructor signature and dispatch semantics may be refined. Silence withwarnings.filterwarnings("ignore", category=linopy.EvolvingAPIWarning).
- __init__(values, y0=0.0, align='pieces', dim=None)#
Methods
__init__(values[, y0, align, dim])to_breakpoints(x_points)Resolve to a breakpoint
xarray.DataArray, given an x grid.Attributes
valuesy0aligndim