Skip to content

Commit

Permalink
fixed interpolation and data export for parameter maps with NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRobsAT committed Apr 16, 2024
1 parent 233a5b5 commit abca2e5
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions pyceps/datatypes/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,22 @@ def interpolate_data(self, which):
else:
raise KeyError()

# check if there is data for interpolation
if np.isnan(data).all():
log.debug('found only NaN in data, cannot interpolate map {}'
.format(which.upper())
)
return

# remove data for redundant points
data = data[unique_ids]
# remove any points with NaN's before interpolation
mask = ~np.isnan(data)
data = data[mask]
unique_points = unique_points[mask]

interpolated = inverse_distance_weighting(unique_points,
data[unique_ids],
data,
mesh_points,
k=7)

Expand Down Expand Up @@ -843,15 +857,17 @@ def export_point_data(self, basename='', which=None, points=None):

if "IMP" in which:
data = [point.impedance for point in points]
dat_file = basename + '.ptdata.IMP.pc.dat'
writer.dump(dat_file, data)
log.info('exported point data to {}'.format(dat_file))
if not np.isnan(data).all():
dat_file = basename + '.ptdata.IMP.pc.dat'
writer.dump(dat_file, data)
log.info('exported point data to {}'.format(dat_file))

if "FRC" in which:
data = [point.force for point in points]
dat_file = basename + '.ptdata.FRC.pc.dat'
writer.dump(dat_file, data)
log.info('exported point data to {}'.format(dat_file))
if not np.isnan(data).all():
dat_file = basename + '.ptdata.FRC.pc.dat'
writer.dump(dat_file, data)
log.info('exported point data to {}'.format(dat_file))

return

Expand Down

0 comments on commit abca2e5

Please sign in to comment.