Skip to content

Commit

Permalink
Resolve issue revoltek#135
Browse files Browse the repository at this point in the history
  • Loading branch information
tikk3r committed Oct 19, 2022
1 parent 23af7fe commit d9c41de
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions losoto/operations/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,18 @@ def run( soltab, outsoltab, axisToRegrid, newdelta, delta='', maxFlaggedWidth=0,
# If there are at least two unflagged points, interpolate with mask
if log:
vals = np.log10(vals)
new_vals[selection] = np.interp(new_axisvals, orig_axisvals[unflagged],
print(selection)
print(type(selection))
new_vals[tuple(selection)] = np.interp(new_axisvals, orig_axisvals[unflagged],
vals[unflagged], left=np.nan, right=np.nan)

# For the weights, interpolate without the mask
new_weights[selection] = np.round(np.interp(new_axisvals, orig_axisvals, weights,
new_weights[tuple(selection)] = np.round(np.interp(new_axisvals, orig_axisvals, weights,
left=np.nan, right=np.nan))

# Check for flagged gaps
if maxFlaggedWidth > 1:
inv_weights = new_weights[selection].astype(bool).squeeze()
inv_weights = new_weights[tuple(selection)].astype(bool).squeeze()
rank = len(inv_weights.shape)
connectivity = nd.generate_binary_structure(rank, rank)
mask_labels, count = nd.label(~inv_weights, connectivity)
Expand All @@ -165,7 +167,7 @@ def run( soltab, outsoltab, axisToRegrid, newdelta, delta='', maxFlaggedWidth=0,
if gapsize <= maxFlaggedWidth:
# Unflag narrow gaps
selection[axisind] = ind[0]
new_weights[selection] = 1.0
new_weights[tuple(selection)] = 1.0

# Write new soltab
solset = soltab.getSolset()
Expand Down

0 comments on commit d9c41de

Please sign in to comment.