comet_maths.interpolation.interpolation.interpolate_1d_along_example

comet_maths.interpolation.interpolation.interpolate_1d_along_example#

comet_maths.interpolation.interpolation.interpolate_1d_along_example(x_i: ndarray, y_i: ndarray, x_hr: ndarray, y_hr: ndarray, x: ndarray, relative: bool | None = True, method: str | None = 'linear', method_hr: str | None = 'linear', unc_methods: List[str] | None = None, unc_methods_hr: List[str] | None = None, u_y_i: ndarray | None = None, corr_y_i: ndarray | str | None = None, u_y_hr: ndarray | None = None, corr_y_hr: ndarray | str | None = None, min_scale: float | None = 0.3, extrapolate: str | None = 'nearest', return_uncertainties: bool | None = False, return_corr: bool | None = False, include_model_uncertainties: bool | None = True, add_model_error: bool | None = False, plot_residuals: bool | None = False, MCsteps: int | None = 100, parallel_cores: int | None = 4) ndarray | Tuple[ndarray, ndarray] | Tuple[ndarray, ndarray, ndarray][source]#

Method for interpolating between datapoints by following an example. The example can come from either models or higher-resolution observations. Here the example is assumed to have an unknown normalisation or poor absolute calibration, yet the low resolution data has a more precise calibration (and can thus be used to constrain the high-resolution model).

Parameters:
  • x_i – Independent variable quantity x for the low resolution data

  • y_i – measured variable quantity y for the low resolution data

  • x_hr – Independent variable quantity x for the high resolution data

  • y_hr – measured variable quantity y for the high resolution data

  • x – Independent variable quantity x for which we are trying to obtain the measurand y

  • relative – Boolean to indicate whether a relative normalisation (True) or absolute normalisation (False) should be used. Defaults to True.

  • method – Sting to indicate which interpolation method should be used to interpolate between normalised data (core interpolation step within the approach). Defaults to Gaussian Progress Regression.

  • method_hr – String to indicate which interpolation method should be used to interpolate between high resolution measurements. Defaults to cubic spline interpolation.

  • unc_methods – interpolation methods to use in the calculation of the model error for interpolation between normalised data. Not used for gpr. Defaults to None, in which case a standard list is used for each interpolation method.

  • unc_methods_hr – interpolation methods to use in the calculation of the model error for interpolation between high resolution measurements. Not used for gpr. Defaults to None, in which case a standard list is used for each interpolation method.

  • u_y_i – uncertainties on y_i, defaults to None

  • corr_y_i – error correlation matrix for u_y_i (can be “rand” for random, “syst” for systematic, or a custom 2D error correlation matrix), defaults to None

  • u_y_hr – uncertainties on y_hr, defaults to None

  • corr_y_hr – error correlation matrix for u_y_hr (can be “rand” for random, “syst” for systematic, or a custom 2D error correlation matrix), defaults to None

  • min_scale – minimum bound on the scale parameter in the gaussian process regression. Only used if gpr is selected as method. Defaults to 0.3

  • extrapolate – extrapolation method, which can be set to “extrapolate” (in which case extrapolation is used using interpolation method defined in “method”), “nearest” (in which case nearest values are used for extrapolation), or “linear” (in which case linear extrapolation is used). Defaults to “extrapolate”.

  • return_uncertainties – Boolean to indicate whether interpolation uncertainties should be calculated and returned. Defaults to False

  • return_corr – Boolean to indicate whether interpolation error-correlation matrix should be calculated and returned. Defaults to False

  • include_model_uncertainties – Boolean to indicate whether model uncertainties should be added to output uncertainties to account for interpolation uncertainties. Not used for gpr. Defaults to True

  • add_model_error – Boolean to indicate whether model error should be added to interpolated values to account for interpolation errors (useful in Monte Carlo approaches). Defaults to False

  • plot_residuals – Boolean to indicate whether a plot of the residuals should be made (and stored as residuals.png). Defaults to False

  • MCsteps – number of MC iterations. Defaults to 100

  • parallel_cores – number of CPU to be used in parallel processing. Defaults to 4

Returns:

The measurand y evaluated at the values x (interpolated values), optionally with correlation and uncertainties if specified