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:

  1. Convert to specific mass

  2. Accumulate along both dimensions

  3. For every first (size) dimension value
    1. fit a monotonic spline for the values of the second (density) dimension

    2. interpolate the second (density) dimension to the supplied (density) grid

  4. For every value on the second (density) upsampled (supplied) grid:
    1. fit a monotonic spline to the values of the first (size) dimension

    2. interpolate the first (size) dimension to the supplied (size) grid

  5. Decumulate along both dimensions

  6. 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: