Skip to content

Commit

Permalink
Convert regression data and weight datasets to float64 datatype becau…
Browse files Browse the repository at this point in the history
…se to resolve Google Colab related issue
  • Loading branch information
AlexeyPechnikov committed Jan 25, 2024
1 parent 3d49e29 commit dbe9168
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pygmtsar/pygmtsar/Stack_detrend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit dbe9168

Please sign in to comment.