Skip to content

Commit

Permalink
Merge pull request #101 from vincelhx/main
Browse files Browse the repository at this point in the history
fix cv2 issue on datarmor
  • Loading branch information
vincelhx authored Jan 21, 2025
2 parents 004d4b4 + b0c31ca commit b49dbfd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
12 changes: 9 additions & 3 deletions grdwindinversion/gradientFeatures.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import xsarsea.gradients
import cv2
import xarray as xr
import xarray as xr
from scipy.ndimage import binary_dilation
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
16 changes: 15 additions & 1 deletion grdwindinversion/inversion.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions grdwindinversion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b49dbfd

Please sign in to comment.