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():
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():
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()
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)
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()
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)
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)
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= {}
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()
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)
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'
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()
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)
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()
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)
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)
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()
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)
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()
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)
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):
"""
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()
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)
# -------------------------------------
-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
# -------------------------------------
-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) \
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: