Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions comet_maths/interpolation/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import matplotlib.pyplot as plt
import numpy as np
import punpy

import comet_maths as cm

Expand Down Expand Up @@ -204,7 +203,7 @@ def interpolate_1d(
:param x: Independent variable quantity x for which we are trying to obtain the measurand y
:param method: interpolation method to be used, defaults to linear
:param unc_methods: interpolation methods to use in the calculation of the model error. Not used for gpr. Defaults to None, in which case a standard list is used for each interpolation method.
:param u_y_i: uncertainties on y_i, defaults to None
:param u_y_i: uncertainties on y_i, defaults to None. Using non-trivial uncertainties requires the punpy module.
:param corr_y_i: error correlation matrix (can be "rand" for random, "syst" for systematic, or a custom 2D error correlation matrix), defaults to None
:param 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
:param 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".
Expand Down Expand Up @@ -326,6 +325,7 @@ def interpolate_1d(
y_corr = None

else:
import punpy
prop = punpy.MCPropagation(MCsteps, parallel_cores=1)
intp = Interpolator(
unc_methods=unc_methods, add_model_error=include_model_uncertainties
Expand Down Expand Up @@ -485,7 +485,7 @@ def gaussian_process_regression(
:param x_i: Independent variable quantity x (coordinate data of y_i)
:param y_i: measured variable quantity y (data to interpolate)
:param x: Independent variable quantity x for which we are trying to obtain the measurand y
:param u_y_i: uncertainties on y_i, defaults to None
:param u_y_i: uncertainties on y_i, defaults to None. Using non-trivial uncertainties requires the punpy module.
:param corr_y_i: error correlation matrix (can be "rand" for random, "syst" for systematic, or a custom 2D error correlation matrix), defaults to None
:param kernel: kernel to be used in the gpr interpolation. Defaults to "RBF".
:param min_scale: minimum bound on the scale parameter in the gaussian process regression. Defaults to 0.01
Expand Down Expand Up @@ -542,6 +542,7 @@ def gaussian_process_regression(
u_y_out = cm.uncertainty_from_covariance(cov_simple)

else:
import punpy
prop = punpy.MCPropagation(MCsteps, parallel_cores=parallel_cores)
intp = Interpolator(
method="gpr",
Expand Down Expand Up @@ -661,7 +662,7 @@ def interpolate_1d_along_example(
:param method_hr: String to indicate which interpolation method should be used to interpolate between high resolution measurements. Defaults to cubic spline interpolation.
:param 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.
:param 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.
:param u_y_i: uncertainties on y_i, defaults to None
:param u_y_i: uncertainties on y_i, defaults to None. Using non-trivial uncertainties requires the punpy module.
:param 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
:param u_y_hr: uncertainties on y_hr, defaults to None
:param 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
Expand Down Expand Up @@ -735,6 +736,7 @@ def interpolate_1d_along_example(
return y_out

else:
import punpy
prop = punpy.MCPropagation(MCsteps, parallel_cores=parallel_cores)
intp = Interpolator(
relative=relative,
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ sphinx_design
ipython
sphinx_autosummary_accessors
sphinx_book_theme

# for interpolations with uncertainties
punpy>=1.0.0
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def read(filename):
"scikit-learn>=1.6.1",
"numdifftools",
"scipy>=1.15.2",
"punpy>=1.0.4",
"matplotlib>=3.10.1",
],
extras_require={
Expand All @@ -43,6 +42,9 @@ def read(filename):
"ipython",
"sphinx_autosummary_accessors",
],
"interpolation": [
"punpy>=1.0.4",
],
},
classifiers=[
"Development Status :: 2 - Pre-Alpha",
Expand Down
Loading