From b0d2f86632e8797e123c4bca0b0b53cb7ff3fda0 Mon Sep 17 00:00:00 2001 From: mahmud1 Date: Wed, 14 Aug 2024 18:09:36 +0200 Subject: [PATCH] mask mean amplitude to avoid zero division warning in log10 --- sarvey/coherence.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sarvey/coherence.py b/sarvey/coherence.py index 5b07adc..52b0595 100644 --- a/sarvey/coherence.py +++ b/sarvey/coherence.py @@ -93,8 +93,10 @@ def computeIfgsAndTemporalCoherence(*, path_temp_coh: str, path_ifgs: str, path_ # read slc slc = slc_stack_obj.read(datasetName='slc', box=bbox, print_msg=False) slc = slc[time_mask, :, :] - # todo: check if mean in log() is 0, then mask it to avoid computational problems. - mean_amp_img[bbox[1]:bbox[3], bbox[0]:bbox[2]] = np.log10(np.mean(np.abs(slc), axis=0)) + + mean_amp = np.mean(np.abs(slc), axis=0) + mean_amp[mean_amp == 0] = np.nan + mean_amp_img[bbox[1]:bbox[3], bbox[0]:bbox[2]] = np.log10(mean_amp) # compute ifgs ifgs = computeIfgs(slc=slc, ifg_array=ifg_array)