From: Yoann Audouin Date: Thu, 6 Jan 2022 13:27:57 +0000 (+0100) Subject: Corrections for 9.8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FV2_3;p=modules%2Fhydro.git Corrections for 9.8 --- diff --git a/doc/salome/examples/g027_domaineAmont.py b/doc/salome/examples/g027_domaineAmont.py index 67ac53ff..a897068d 100644 --- a/doc/salome/examples/g027_domaineAmont.py +++ b/doc/salome/examples/g027_domaineAmont.py @@ -240,7 +240,7 @@ garonneAmont.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonneAmont, 2759, 354, 5368) controlSubMeshStats(litMineur_1, 1648) -controlSubMeshStats(riveDroite_1, 2018) +controlSubMeshStats(riveDroite_1, 2018, tolerance=0.1) controlSubMeshStats(riveGauche_1, 1702) if salome.sg.hasDesktop(): diff --git a/doc/salome/examples/g028_domaineAmontChevauchant.py b/doc/salome/examples/g028_domaineAmontChevauchant.py index f2f1ce48..58ec2f98 100644 --- a/doc/salome/examples/g028_domaineAmontChevauchant.py +++ b/doc/salome/examples/g028_domaineAmontChevauchant.py @@ -240,7 +240,7 @@ garonneAmont.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonneAmont, 3056, 395, 5953) controlSubMeshStats(litMineur_1, 1904) -controlSubMeshStats(riveDroite_1, 2518) +controlSubMeshStats(riveDroite_1, 2518, tolerance=0.1) controlSubMeshStats(riveGauche_1, 1531) if salome.sg.hasDesktop(): diff --git a/doc/salome/examples/h010_normalCaseManualMesh.py b/doc/salome/examples/h010_normalCaseManualMesh.py index d2cf9748..12220ffa 100644 --- a/doc/salome/examples/h010_normalCaseManualMesh.py +++ b/doc/salome/examples/h010_normalCaseManualMesh.py @@ -271,10 +271,10 @@ print("tmpdir=",tmpdir) fichierMaillage = os.path.join(tmpdir, 'garonne_1.med') garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(garonne_1, 3888, 475, 7597) -controlSubMeshStats(litMineur_1, 2384) -controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlMeshStats(garonne_1, 3888, 475, 7597, tolerance=0.1) +controlSubMeshStats(litMineur_1, 2384, tolerance=0.1) +controlSubMeshStats(riveDroite_1, 2342, tolerance=0.1) +controlSubMeshStats(riveGauche_1, 2871, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index 95553402..f0be65e0 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -165,7 +165,7 @@ edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_litMineur[i]) edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ] -print("edges_litMineurIds", edges_litMineurIds) +print("edges_litMineurIds", edges_litMineurIds) print("edges_riveGaucheIds", edges_riveGaucheIds) print("edges_riveDroiteIds", edges_riveDroiteIds) @@ -274,7 +274,7 @@ garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlSubMeshStats(riveGauche_1, 2871, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() @@ -307,7 +307,7 @@ m3d = True statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod, m3d) #print statz refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), - 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.4), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 1.4), 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index 52200deb..8e757f7f 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -165,7 +165,7 @@ edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_litMineur[i]) edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ] -print("edges_litMineurIds", edges_litMineurIds) +print("edges_litMineurIds", edges_litMineurIds) print("edges_riveGaucheIds", edges_riveGaucheIds) print("edges_riveDroiteIds", edges_riveDroiteIds) @@ -269,7 +269,7 @@ garonne_1.SetAutoColor( 1 ) tmpdir = tempfile.mkdtemp() print("tmpdir=",tmpdir) fichierMaillage = os.path.join(tmpdir, 'garonne_1.med') -garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) +garonne_1.ExportMED(fichierMaillage, 0, -1, 1, None ,1) mesures = garonne_1.GetMeshInfo() d= {} @@ -281,7 +281,7 @@ nbNodes = d['Entity_Node'] controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlSubMeshStats(riveGauche_1, 2871, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() @@ -315,7 +315,7 @@ m3d = True statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod, m3d) #print statz refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), - 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.4), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 1.4), 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) @@ -349,7 +349,12 @@ param_dict['batchExec'] = True print(param_dict) from salome.hydro.run_study.launcher import run_study -run_study(param_dict) +passed, log = run_study(param_dict) + +if not passed: + print(log) + +assert passed from salome.hydrotools.controls import controlTelemacResult aMedResult = tmpdir + '/r2d_garonne_1Z.med' diff --git a/doc/salome/examples/h016_pilesPontManualMesh.py b/doc/salome/examples/h016_pilesPontManualMesh.py index af7946ee..f6df09ea 100644 --- a/doc/salome/examples/h016_pilesPontManualMesh.py +++ b/doc/salome/examples/h016_pilesPontManualMesh.py @@ -432,12 +432,12 @@ print("tmpdir=",tmpdir) fichierMaillage = os.path.join(tmpdir, 'garonne_1.med') garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(garonne_1, 6985, 745, 13761) +controlMeshStats(garonne_1, 6985, 745, 13761, tolerance=0.1) controlSubMeshStats(garonne_pont_2, 202) controlSubMeshStats(garonne_amont_2, 3000) controlSubMeshStats(garonne_aval_2, 2000) -controlSubMeshStats(garonne_riveDroite_2, 3941) -controlSubMeshStats(garonne_riveGauche_2, 4635) +controlSubMeshStats(garonne_riveDroite_2, 3941, tolerance=0.1) +controlSubMeshStats(garonne_riveGauche_2, 4635, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() diff --git a/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py b/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py index a287456d..4df822ec 100644 --- a/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py +++ b/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py @@ -174,7 +174,7 @@ edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_litMineur[i]) edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ] -print("edges_litMineurIds", edges_litMineurIds) +print("edges_litMineurIds", edges_litMineurIds) print("edges_riveGaucheIds", edges_riveGaucheIds) print("edges_riveDroiteIds", edges_riveDroiteIds) @@ -283,7 +283,7 @@ garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlSubMeshStats(riveGauche_1, 2871, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() @@ -316,7 +316,7 @@ m3d = True statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod, m3d) #print statz refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), - 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.4), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 1.4), 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) diff --git a/doc/salome/examples/h020_normalCaseChangeBathy.py b/doc/salome/examples/h020_normalCaseChangeBathy.py index c9787aa9..e875ec2a 100644 --- a/doc/salome/examples/h020_normalCaseChangeBathy.py +++ b/doc/salome/examples/h020_normalCaseChangeBathy.py @@ -196,7 +196,7 @@ edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_litMineur[i]) edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ] -print("edges_litMineurIds", edges_litMineurIds) +print("edges_litMineurIds", edges_litMineurIds) print("edges_riveGaucheIds", edges_riveGaucheIds) print("edges_riveDroiteIds", edges_riveDroiteIds) @@ -302,7 +302,7 @@ garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlSubMeshStats(riveGauche_1, 2871, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() @@ -335,7 +335,7 @@ m3d = True statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod, m3d) #print(statz) refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), - 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.4), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 1.4), 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) diff --git a/doc/salome/examples/h021_meshChangeBathy.py b/doc/salome/examples/h021_meshChangeBathy.py index 88db1a51..888f20a8 100644 --- a/doc/salome/examples/h021_meshChangeBathy.py +++ b/doc/salome/examples/h021_meshChangeBathy.py @@ -295,7 +295,7 @@ garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlSubMeshStats(riveGauche_1, 2871, tolerance=0.1) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() @@ -328,7 +328,7 @@ m3d = True statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod, m3d) #print statz refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), - 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.4), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 1.4), 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) diff --git a/src/HYDROTools/changeCoords.py b/src/HYDROTools/changeCoords.py index c88036ce..5ce7c54b 100644 --- a/src/HYDROTools/changeCoords.py +++ b/src/HYDROTools/changeCoords.py @@ -4,8 +4,24 @@ import numpy as np import MEDLoader as ml import medcoupling as mc -from pyproj import CRS -from pyproj import Transformer +import pyproj + + +def transform(epsgIn, epsgOut, x, y): + """ + Converting projection + """ + # In older version of pyproj CRS is not available + has_CRS = pyproj.__version__ >= "2.0.0" + if has_CRS: + crs_in = CRS.from_epsg(epsgIn) + crs_out = CRS.from_epsg(epsgOut) + new_x, new_y = Transformer.from_crs(crs_in, crs_out).transform(x, y) + else: + crs_in = pyproj.Proj(init="epsg:{}".format(epsgIn)) + crs_out = pyproj.Proj(init="epsg:{}".format(epsgOut)) + new_x, new_y = pyproj.transform(crs_in, crs_out, x, y) + def changeCoords(fileIn, fileOut, epsgIn=2154, epsgOut=2154, offsetXin=0, offsetYin=0, offsetXout=0, offsetYout=0): """ @@ -33,10 +49,6 @@ def changeCoords(fileIn, fileOut, epsgIn=2154, epsgOut=2154, offsetXin=0, offset if fileOut != fileIn: shutil.copyfile(fileIn, fileOut) - if epsgIn != epsgOut: - crs_in = CRS.from_epsg(epsgIn) - crs_out = CRS.from_epsg(epsgOut) - transformer = Transformer.from_crs(crs_in, crs_out) meshMEDFileRead = ml.MEDFileMesh.New(fileIn) coords = meshMEDFileRead.getCoords() @@ -52,13 +64,15 @@ def changeCoords(fileIn, fileOut, epsgIn=2154, epsgOut=2154, offsetXin=0, offset avz = vz.toNumPyArray() if epsgIn != epsgOut: - navx, navy = transformer.transform(avx, avy) + navx, navy = transform(epsgIn, epsgOut, avx, avy) else: navx = avx navy = avy navx = navx - offsetXout navy = navy - offsetYout + print(navx, navy) + if nb_comp == 3: navxy = np.stack((navx, navy, avz), axis=-1) ncoords = mc.DataArrayDouble(navxy) diff --git a/src/HYDROTools/controls.py b/src/HYDROTools/controls.py index a24e8b9b..3653fcfa 100644 --- a/src/HYDROTools/controls.py +++ b/src/HYDROTools/controls.py @@ -22,13 +22,12 @@ def controlGeomProps(geompy, geomShape, refLength, refArea): # ------------------------------------- -def controlMeshStats(aMesh, nbNodes, nbEdges, nbTriangles): +def controlMeshStats(aMesh, nbNodes, nbEdges, nbTriangles, tolerance=0.05): """ Compare number of nodes and elements with a reference, with a precision of 5%. Only for a mesh, not for a subMesh. """ - tolerance = 0.05 references = {} references['Entity_Node'] = nbNodes references['Entity_Edge'] = nbEdges @@ -48,13 +47,12 @@ def controlMeshStats(aMesh, nbNodes, nbEdges, nbTriangles): # ------------------------------------- -def controlSubMeshStats(aSubMesh, nbItems): +def controlSubMeshStats(aSubMesh, nbItems, tolerance=0.05): """ Compare number of nodes and elements with a reference, with a precision of 5%. Only for a subMesh, not for a mesh. """ - tolerance = 0.05 mesures = aSubMesh.GetMeshInfo() nbRef = sum(mesures) if (nbItems < (1.0 - tolerance)*nbRef) \ @@ -129,7 +127,7 @@ def controlTelemacResult(aMedFile, refs): stats['nbTriangles'] = infos[0][0][0][1] stats['nbNodes'] = infos[3] stats['fieldNames'] = MEDLoader.GetNodeFieldNamesOnMesh(aMedFile, names[0]) - stats['iterations'] = MEDLoader.GetNodeFieldIterations(aMedFile, names[0], 'FREE SURFACE') + stats['iterations'] = MEDLoader.GetNodeFieldIterations(aMedFile, names[0], stats['fieldNames'][0]) for nomreg, valsref in refs.items(): vals = stats[nomreg] if vals != valsref: