diff --git a/grdwindinversion/gradientFeatures.py b/grdwindinversion/gradientFeatures.py index 43806e9..a122a62 100644 --- a/grdwindinversion/gradientFeatures.py +++ b/grdwindinversion/gradientFeatures.py @@ -1,5 +1,4 @@ import xsarsea.gradients -import cv2 import xarray as xr import xarray as xr from scipy.ndimage import binary_dilation @@ -55,6 +54,7 @@ def _compute_gradients(self): None """ + self.gradients = xsarsea.gradients.Gradients( self.xr_dataset_100['sigma0_detrend'], windows_sizes=self.windows_sizes, @@ -111,8 +111,14 @@ def get_heterogeneity_mask(self, config): sig = xr.where(sig <= 0, 1e-15, sig) # map incidence for detrend - incidence = xr.DataArray(data=cv2.resize( - self.xr_dataset_100.incidence.values, sig.shape[::-1], cv2.INTER_NEAREST), dims=sig.dims, coords=sig.coords) + # incidence = xr.DataArray(data=cv2.resize( + # self.xr_dataset_100.incidence.values, sig.shape[::-1], cv2.INTER_NEAREST), dims=sig.dims, coords=sig.coords) + + incidence = self.xr_dataset_100.incidence.interp( + line=sig.coords['line'], + sample=sig.coords['sample'], + method="nearest" # Équivaut à INTER_NEAREST + ) sigma0_detrend = xsarsea.sigma0_detrend(sig, incidence) diff --git a/grdwindinversion/inversion.py b/grdwindinversion/inversion.py index 158c14d..4cae8f1 100644 --- a/grdwindinversion/inversion.py +++ b/grdwindinversion/inversion.py @@ -1,3 +1,17 @@ +## To place here in the code to not have errors with cv2. +## if placed in main => error .. +import os +os.environ["OMP_NUM_THREADS"] = "1" +os.environ["OPENBLAS_NUM_THREADS"] = "1" +os.environ["MKL_NUM_THREADS"] = "1" +os.environ["VECLIB_MAXIMUM_THREADS"] = "1" +os.environ["NUMEXPR_NUM_THREADS"] = "1" +try : + import cv2 +except: + import cv2 +cv2.setNumThreads(1) + import tempfile import traceback @@ -602,7 +616,7 @@ def preprocess(filename, outdir, config_path, overwrite=False, add_gradientsfeat add_nrcs_model = config_base["add_nrcs_model"] add_nrcs_model = False logging.warning( - f'Force this variable to be false, before fixing the issue' + f'Force add_nrcs_model to be false, before fixing an issue' ) else: add_nrcs_model = False diff --git a/grdwindinversion/main.py b/grdwindinversion/main.py index d9456d6..af10d4d 100644 --- a/grdwindinversion/main.py +++ b/grdwindinversion/main.py @@ -25,6 +25,12 @@ def processor_starting_point(): help="En cas d'activation, désactive la génération du .csv") args = parser.parse_args() + + + + + + fmt = '%(asctime)s %(levelname)s %(filename)s(%(lineno)d) %(message)s' if args.verbose: logging.basicConfig(level=logging.DEBUG, format=fmt,