Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug with unevenly spaced input #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions pypret/mesh_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def interpolate(self, axis1=None, axis2=None, degree=2, sorted=False):
uncertainty = np.take(uncertainty, idx, axis=i)
dataf = RegularGridInterpolator(tuple(orig_axes), data,
bounds_error=False, fill_value=0.0)
# Resample the axes to be evenly spaced
axes = [np.linspace(axis[0],axis[-1],len(axis),endpoint=True) for axis in axes]
grid = lib.build_coords(*axes)
self.data = dataf(grid)
self.axes = axes
Expand Down
3 changes: 2 additions & 1 deletion pypret/retrieval/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ..pulse_error import pulse_error
from .. import lib
from ..pnps import BasePNPS
from math import isclose

# global dictionary that contains all PNPS classes
_RETRIEVER_CLASSES = {}
Expand Down Expand Up @@ -106,7 +107,7 @@ def retrieve(self, measurement, initial_guess, weights=None,

def _retrieve_begin(self, measurement, initial_guess, weights):
pnps = self.pnps
if not np.all(pnps.process_w == measurement.axes[1]):
if not np.allclose(pnps.process_w, measurement.axes[1], rtol=1e-6):
raise ValueError("Measurement has to lie on simulation grid!")
# Store measurement
self.measurement = measurement
Expand Down