]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Corrections for 9.8 V2_3
authorYoann Audouin <yoann.audouin@edf.fr>
Thu, 6 Jan 2022 13:27:57 +0000 (14:27 +0100)
committerYoann Audouin <yoann.audouin@edf.fr>
Thu, 6 Jan 2022 13:27:57 +0000 (14:27 +0100)
doc/salome/examples/g027_domaineAmont.py
doc/salome/examples/g028_domaineAmontChevauchant.py
doc/salome/examples/h010_normalCaseManualMesh.py
doc/salome/examples/h011_normalCaseManualInterpolZ.py
doc/salome/examples/h015_normalCaseManualTelemac.py
doc/salome/examples/h016_pilesPontManualMesh.py
doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py
doc/salome/examples/h020_normalCaseChangeBathy.py
doc/salome/examples/h021_meshChangeBathy.py
src/HYDROTools/changeCoords.py
src/HYDROTools/controls.py

index 67ac53ffa529c39bffc34b49cd3a8c2b7bd358a7..a897068d7978de8fa39e6dc9d3ca21dc258ce4ac 100644 (file)
@@ -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():
index f2f1ce488d0aa64bc449ab3b7022466e899caf5e..58ec2f982582f93d7e4fa99c95bf5225faf4487a 100644 (file)
@@ -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():
index d2cf9748c96342c80111aa4334e5deed01fe4cdf..12220ffa8bba0bb34595f9afde268e51033ad792 100644 (file)
@@ -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()
index 95553402f81a1f539b24a4095a65b6eb4bb32dd4..f0be65e00175bd6d0e4a41f26400a327261262ee 100644 (file)
@@ -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)
 
index 52200debb4bdb8b1be101696b999aaa67e4d0a5c..8e757f7f2025d68ba773978d4b2d511037dc9b3b 100644 (file)
@@ -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'
index af7946ee3fd0e1ada55b2616a0562901b20bf088..f6df09ea1e6f9d883c6437661e95dbc845e04c15 100644 (file)
@@ -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()
index a287456d7f59fa69895c41eaeed56b0cd1cb6540..4df822ecf39cdb3024ba0c8ab284ca1b8ab13d67 100644 (file)
@@ -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)
 
index c9787aa93a8a39d43f30e9dc9d7ba2849bb55a78..e875ec2a63fb75f5d5570175263b8e0b0e34cc76 100644 (file)
@@ -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)
 
index 88db1a51b327b14f2b29c5ca0bb397287a44f2b2..888f20a807fba0307feca91ffc9cda033b100437 100644 (file)
@@ -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)
 
index c88036cea290d933b9e78c588676744db2a51b7c..5ce7c54b2b9ee06053eec399fc1fdfd1889f5abe 100644 (file)
@@ -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)
index a24e8b9b1da0640e63ab46b107af6d351d83d764..3653fcfae9e6933650378c2003a3784988f335c6 100644 (file)
@@ -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: