Skip to content

Commit

Permalink
LineLevel that is robust to unknown values
Browse files Browse the repository at this point in the history
  • Loading branch information
markotoplak committed Sep 27, 2024
1 parent 8f87074 commit 5db528b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pySNOM/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ def __init__(self, method='median', datatype=DataTypes.Phase):

def transform(self, data):
if self.method == 'median':
norm = np.median(data, axis=1, keepdims=True)
norm = np.nanmedian(data, axis=1, keepdims=True)
elif self.method == 'mean':
norm = np.mean(data, axis=1, keepdims=True)
norm = np.nanmean(data, axis=1, keepdims=True)
elif self.method == 'difference':
if self.datatype == DataTypes.Amplitude:
norm = np.median(data[1:] / data[:-1], axis=1, keepdims=True)
norm = np.nanmedian(data[1:] / data[:-1], axis=1, keepdims=True)
else:
norm = np.median(data[1:] - data[:-1], axis=1, keepdims=True)
norm = np.nanmedian(data[1:] - data[:-1], axis=1, keepdims=True)
data = data[:-1] # difference does not make sense for the last row
else:
if self.datatype == DataTypes.Amplitude:
Expand Down

0 comments on commit 5db528b

Please sign in to comment.