From: Paul RASCLE Date: Fri, 15 Nov 2019 15:05:58 +0000 (+0100) Subject: fix interpolz bathy when no Z coordinate, fix zUndef test X-Git-Tag: SH_V2_2_0~99^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1dd8384006c38bb778e3ab7ed23584596db9b18d;p=modules%2Fhydro.git fix interpolz bathy when no Z coordinate, fix zUndef test --- diff --git a/src/HYDROTools/interpolZ.py b/src/HYDROTools/interpolZ.py index e5ef8fd1..81a802be 100644 --- a/src/HYDROTools/interpolZ.py +++ b/src/HYDROTools/interpolZ.py @@ -61,7 +61,7 @@ Constructor # ----------------------------------------------------------------------------- -def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_interp_method=None, m3d=True, xyzFile=False, verbose=False): +def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=-100., regions_interp_method=None, m3d=True, xyzFile=False, verbose=False): """ interpolZ takes a 2D (x,y) mesh and calls the active instance of module HYDRO to interpolate the bathymetry/altimetry on the mesh nodes, to produce the Z value of each node. @@ -73,7 +73,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int Key: face group name Value: region name in the HYDRO Case zUndef: Z value to use for nodes outside the regions (there must be none if the case is correct). - default value is 90. + default value is -100. interpolMethod: integer value or dict if integer : 0 = nearest point on bathymetry @@ -273,10 +273,10 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int # or the mesh is displayed, it makes huge gap. To prevent this artefact, a more # convenient "undefined" value is set. This new undefined value is given by the user. # -# zUndefThreshold: the default value is -9000. It is tied with the value -9999. given +# zUndefThreshold: the default value is zUndef +10. It is tied with the value -100. given # by the interpolation when no value is defined. # - zUndefThreshold = -9000. + zUndefThreshold = zUndef +10. if verbose: ligne = "zUndefThreshold: %f" % zUndefThreshold print (ligne) @@ -286,9 +286,6 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int if verbose: ligne = ".. Number of nodes below the minimum: %d" % len(np_aux_z[0]) print (ligne) - if len(np_aux_z[0]): - for iaux in np_aux_z[0]: - bathy[iaux] = zUndef # # 6. Option : xyz file # @@ -360,7 +357,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int return statz -def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=90., interp_method=0, m3d=True, xyzFile=False, verbose=False): +def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=-100., interp_method=0, m3d=True, xyzFile=False, verbose=False): """ interpolZ_B takes a 2D (x,y) mesh and calls the active instance of module HYDRO to interpolate the bathymetry/altimetry on the mesh nodes, to produce the Z value of each node. @@ -370,7 +367,7 @@ def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=90., interp_met fichierMaillage: med file name produced by SMESH, corresponding to the HYDRO case gr_face_name: face group name zUndef: Z value to use for nodes outside the regions (there must be none if the case is correct). - default value is 90. + default value is -100. interp_method: interpolation method 0 = nearest point on bathymetry 1 = linear interpolation @@ -445,9 +442,12 @@ def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=90., interp_met # tb_aux = np.zeros(nbnodes, dtype=np.bool) # - #bathy = np.zeros(nbnodes, dtype=np.float) - #bathy.fill(zUndef) - bathy = coords[:,2].toNumPyArray() + bathy = np.zeros(nbnodes, dtype=np.float) + bathy.fill(zUndef) + if (coords.getNumberOfComponents() >2): + bathy = coords[:,2].toNumPyArray() + else: + print("=== WARNING! === Mesh has no altitude component z, z will be filled with zUndef = %s outside the group!"%zUndef) # # 4.1. Mesh of the group @@ -517,10 +517,10 @@ def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=90., interp_met # or the mesh is displayed, it makes huge gap. To prevent this artefact, a more # convenient "undefined" value is set. This new undefined value is given by the user. # -# zUndefThreshold: the default value is -9000. It is tied with the value -9999. given +# zUndefThreshold: the default value is zUndef +10. It is tied with the value -100. given # by the interpolation when no value is defined. # - zUndefThreshold = -9000. + zUndefThreshold = zUndef + 10. if verbose: ligne = "zUndefThreshold: %f" % zUndefThreshold print (ligne) @@ -530,9 +530,6 @@ def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=90., interp_met if verbose: ligne = ".. Number of nodes below the minimum: %d" % len(np_aux_z[0]) print (ligne) - if len(np_aux_z[0]): - for iaux in np_aux_z[0]: - bathy[iaux] = zUndef # # 6. Option : xyz file #