elphick.geomet.utils.interp2.mass_preserving_interp_2d
- elphick.geomet.utils.interp2.mass_preserving_interp_2d(specific_mass_intervals, interval_edges=None, precision=None, mass_dry='mass_dry')[source]
Interpolate 2D interval data with zero mass loss using pchip
This function applies mass-preserving up-sampling to 2D interval data. The function will: For example if the first dimension is size and the second is density:
Convert to specific mass
Accumulate along both dimensions
- For every first (size) dimension value
fit a monotonic spline for the values of the second (density) dimension
interpolate the second (density) dimension to the supplied (density) grid
- For every value on the second (density) upsampled (supplied) grid:
fit a monotonic spline to the values of the first (size) dimension
interpolate the first (size) dimension to the supplied (size) grid
Decumulate along both dimensions
Convert to composition
The above steps are repeated for every component, starting with dry mass and ending with the last component.
- Parameters:
specific_mass_intervals (
DataFrame
) – Dataframe with two pd.IntervalIndexes, representing specific mass intervals.interval_edges (
Optional
[dict
[str
,Iterable
[float
]]]) – Dict of the values of the new grid (interval edges) for each dimension, keyed by index name (dimension). If None, the grid will be a rectilinear grid using unique values from the index.precision (
Optional
[int
]) – Number of decimal places to round the index (edge) values.mass_dry (
str
) – The dry mass column, not optional. Consider solve_mass_moisture prior to this call if needed.
- Return type:
DataFrame
Returns: