Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cv2 issue on datarmor #101

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading