galapy.internal.interp

Classes

lin_interp(xv, fv)

Piecewise-linear interpolator with linear extrapolation beyond the grid.

log_interp(xv, fv)

Piecewise power-law interpolator with power-law extrapolation.

class galapy.internal.interp.lin_interp(xv, fv)

Piecewise-linear interpolator with linear extrapolation beyond the grid.

Pure-Python replacement for the former galapy.internal.interp compiled extension. Uses numpy.interp for in-range evaluation and propagates the edge slopes for out-of-range points. The public API is identical to the old C++ class so all call sites are unaffected.

Parameters:
  • xv (array-like) – Strictly increasing x-coordinates of the grid.

  • fv (array-like) – Function values at each grid point (same length as xv).

get_x()

Return a copy of the x-grid.

get_y()

Return a copy of the y-grid.

integrate(aa, bb)

Trapezoidal integral from aa to bb.

Interior grid points within (aa, bb) are included; the boundary values are obtained by evaluating the interpolant (which extrapolates linearly when aa or bb lie outside the grid).

class galapy.internal.interp.log_interp(xv, fv)

Piecewise power-law interpolator with power-law extrapolation.

Performs interpolation in log-log space (linear interpolation of log f vs log x), which is exact for power-law functions and significantly more accurate than linear interpolation for SEDs that span many orders of magnitude.

Zero or negative values in fv are replaced by _FLOOR (1e-300) before taking logarithms; get_y() always returns the original un-floored values.

Parameters:
  • xv (array-like) – Strictly positive, strictly increasing x-coordinates of the grid.

  • fv (array-like) – Function values at each grid point (same length as xv). May contain zeros; values ≤ 0 are floored for log arithmetic.

get_x()

Return a copy of the x-grid.

get_y()

Return a copy of the original (un-floored) y-grid.

integrate(aa, bb)

Integral from aa to bb using the log-space trapezoid rule.

Applies the change of variable u = log(x), giving

integral ≈ Σ (f_i x_i + f_{i+1} x_{i+1}) / 2 · log(x_{i+1}/x_i)

which is the standard trapezoid rule in log(x) space. This is more accurate than the linear-space rule for functions on log-spaced grids such as SSP wavelength arrays.

Boundary values are obtained by evaluating the interpolant (power-law extrapolation when aa or bb lie outside the grid).