lightcurvelynx.utils.bicubic_interp
The BicubicInterpolator is used by SALT models.
It is adapted from sncosmo’s BicubicInterpolator class (but implemented in JAX): https://github.com/sncosmo/sncosmo/blob/v2.10.1/sncosmo/salt2utils.pyx
Classes
An object that performs bicubic interpolation over a 2-d grid. |
|
A helper class that represents values for an axis of bicubic interpolation |
Functions
|
Create the unraveled arrays representing the grid of points from each access. |
Module Contents
- expand_to_cross_products(x_vals, y_vals)[source]
Create the unraveled arrays representing the grid of points from each access.
- Parameters:
x_vals (array-like) – A length N array of the x values.
y_vals (array-like) – A length M array of the y values.
- Returns:
all_x (JAX array) – A length N * M array of the x values.
all_y (JAX array) – A length N * M array of the y values.
- class BicubicInterpolator(x_vals, y_vals, z_vals)[source]
An object that performs bicubic interpolation over a 2-d grid.
- Parameters:
x_vals (array-like) – The values along the x-axis of the grid. The values must be sorted and at regular step sizes.
y_vals (array-like) – The values along the y-axis of the grid. The values must be sorted and at regular step sizes.
z_vals (array-like) – The values along the z-axis of the grid.
- classmethod from_grid_file(filename, scale_factor=1.0)[source]
Load the grid data from an ASCII file and create a BicubicInterpolator.
- Parameters:
filename (str) – The name of the grid file.
scale_factor (float) – A multiplicative scale factor for the z values. Default: 1.0
- __call__(x_q, y_q)[source]
Evaluate the bicubic interpolation at a grid of points.
- Parameters:
x_q (array-like) – The N-length array of x values.
y_q (array-like) – The M-length array of y values.
- Returns:
results – An N x M array of interpolated values for each (x, y) pair.
- Return type:
jaxlib.xla_extension.ArrayImpl
- class BicubicAxis(values)[source]
A helper class that represents values for an axis of bicubic interpolation with restrictions on acceptable data to match the SALT2 and SALT3 models.
Restrictions include:
Data must contain at least 3 values.
Data must be sorted.
Data must be spaced at regular steps.
- regular_steps
Indicates whether the axis uses regularly sized steps.
- Type:
bool
- step_size
The step size of the range.
- Type:
float
- find_indices(query_pts)[source]
Finds the first index before each of the query values with the n - 1 index in each dimension mapped to n - 2:
values[idx[i]] <= query_pts[i] < values[idx[i] + 1] for all i where idx[i] > 0 and idx[i] < n - 2.
- Parameters:
query_pts (array-like) – The values of the query points.
- Returns:
idx – A pair of arrays with the indices.
- Return type:
JAX Array