From dbe9168f4a5acb910003f78ba69397b9c00053d8 Mon Sep 17 00:00:00 2001 From: Alexey Pechnikov Date: Thu, 25 Jan 2024 21:32:37 +0700 Subject: [PATCH] Convert regression data and weight datasets to float64 datatype because to resolve Google Colab related issue --- pygmtsar/pygmtsar/Stack_detrend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmtsar/pygmtsar/Stack_detrend.py b/pygmtsar/pygmtsar/Stack_detrend.py index 6db2503e..db2ff9a8 100644 --- a/pygmtsar/pygmtsar/Stack_detrend.py +++ b/pygmtsar/pygmtsar/Stack_detrend.py @@ -196,13 +196,13 @@ def regression(data, variables, weight=None, valid_pixels_threshold=1000, algori #print ('variables', variables) def regression_block(data, variables, weight, algorithm, **kwargs): - data_values = data.ravel() + data_values = data.ravel().astype(np.float64) variables_values = variables.reshape(-1, variables.shape[-1]).T #assert 0, f'TEST: {data_values.shape}, {variables_values.shape}, {weight.shape}' nanmask_data = np.isnan(data_values) nanmask_values = np.any(np.isnan(variables_values), axis=0) if weight.size > 1: - weight_values = weight.ravel() + weight_values = weight.ravel().astype(np.float64) nanmask_weight = np.isnan(weight_values) nanmask = nanmask_data | nanmask_values | nanmask_weight else: @@ -231,7 +231,7 @@ def regression_block(data, variables, weight, algorithm, **kwargs): model[~nanmask_values] = regr.predict(variables_values[:, ~nanmask_values].T) del variables_values, regr del nanmask_data, nanmask_values, nanmask_weight, nanmask - return model.reshape(data.shape) + return model.reshape(data.shape).astype(np.float32) # xarray wrapper model = xr.apply_ufunc(