Skip to content
Snippets Groups Projects
Commit dfab4226 authored by paul.tresson_ird.fr's avatar paul.tresson_ird.fr
Browse files

remove nan during projection fit and replace with mean value during inference....

remove nan during projection fit and replace with mean value during inference. should fix #14 for projections
parent a61bae8e
No related branches found
No related tags found
No related merge requests found
...@@ -233,6 +233,9 @@ class ReductionAlgorithm(QgsProcessingAlgorithm): ...@@ -233,6 +233,9 @@ class ReductionAlgorithm(QgsProcessingAlgorithm):
random_indices = np.random.choice(nsamples, size=self.subset, replace=False) random_indices = np.random.choice(nsamples, size=self.subset, replace=False)
fit_raster = fit_raster[random_indices,:] fit_raster = fit_raster[random_indices,:]
# remove nans
fit_raster = fit_raster[~np.isnan(fit_raster).any(axis=1)]
feedback.pushInfo(f"Mean raster : {np.mean(raster)}") feedback.pushInfo(f"Mean raster : {np.mean(raster)}")
feedback.pushInfo(f"Standart dev : {np.std(raster)}") feedback.pushInfo(f"Standart dev : {np.std(raster)}")
fit_raster = (fit_raster-np.mean(raster))/np.std(raster) fit_raster = (fit_raster-np.mean(raster))/np.std(raster)
...@@ -279,6 +282,8 @@ class ReductionAlgorithm(QgsProcessingAlgorithm): ...@@ -279,6 +282,8 @@ class ReductionAlgorithm(QgsProcessingAlgorithm):
joblib.dump(proj, out_path) joblib.dump(proj, out_path)
feedback.pushInfo(f'Inference over raster\n') feedback.pushInfo(f'Inference over raster\n')
raster = (raster-np.mean(raster))/np.std(raster)
np.nan_to_num(raster) # NaN to zero after normalisation
proj_img = proj.transform(raster.reshape(-1, raster.shape[-1])) proj_img = proj.transform(raster.reshape(-1, raster.shape[-1]))
if self.method=='PCA' : if self.method=='PCA' :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment