From 9cb821c5a61237be89c4362f3e193821c4adefd9 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Tue, 11 Apr 2017 09:53:38 +0200 Subject: [PATCH] correction cas tests et traces --- .../h011_normalCaseManualInterpolZ.py | 11 ++---- .../examples/h014_caseDigueManualInterpolZ.py | 37 +++---------------- .../examples/h015_normalCaseManualTelemac.py | 5 ++- .../examples/h017_interpolationLineaire.py | 7 +--- .../examples/h018_streamInterpolation.py | 5 ++- src/HYDROData/HYDROData_CalculationCase.cxx | 2 +- src/HYDROData/HYDROData_Entity.cxx | 4 +- src/HYDROTools/controls.py | 24 +++++++----- src/HYDROTools/interpolZ.py | 13 +++++-- 9 files changed, 47 insertions(+), 61 deletions(-) diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index ec0a17ec..74231688 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -359,8 +359,6 @@ geompy.addToStudyInFather( HYDRO_garonne_1, bordDroiteDomaine, 'bordDroiteDomain # --- basic properties control: edges length, surfaces controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061) -#controlGeomProps(geompy, litMineur, 30337.5484919, 3263628.55399) -#controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) @@ -443,10 +441,6 @@ SectionsGaronne_3 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMES garonne_1.SetAutoColor( 1 ) garonne_1.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -#controlMeshStats(garonne_1, 1763, 180, 3360) -#controlSubMeshStats(litMineur_2, 48) -#controlSubMeshStats(riveDroite_1, 1360) -#controlSubMeshStats(riveGauche_1, 1952) controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_2, 2384) controlSubMeshStats(riveDroite_1, 2342) @@ -478,7 +472,10 @@ zUndef = 90 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) -refstatz = {'riveDroite': (10.88, 32.61), 'riveGauche': (7.72, 71.86, 0.5), 'litMineur': (2.06, 25.41)} +#print statz +refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.2), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.2), + 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" diff --git a/doc/salome/examples/h014_caseDigueManualInterpolZ.py b/doc/salome/examples/h014_caseDigueManualInterpolZ.py index d5469b30..d7b99c23 100644 --- a/doc/salome/examples/h014_caseDigueManualInterpolZ.py +++ b/doc/salome/examples/h014_caseDigueManualInterpolZ.py @@ -421,20 +421,6 @@ SectionsDigue = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) geompy.UnionIDs(SectionsDigue, [40, 35]) geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' ) -# --- recreate subshapes already exported from HYDRO to get access from Python -#garonne_2_domaineEtendu_Outer = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(garonne_2_domaineEtendu_Outer, [4, 11, 17, 24, 26, 28, 14, 19, 20, 22, 31, 39, 41, 33, 35, 37]) -#garonne_2_digue_Left_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(garonne_2_digue_Left_Bank, [43]) -#garonne_2_digue_Outlet = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(garonne_2_digue_Outlet, [46]) -#garonne_2_digue_Inlet = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(garonne_2_digue_Inlet, [50]) -#garonne_2_litMineur_Outer = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(garonne_2_litMineur_Outer, [7, 9]) -#garonne_2_digue_Right_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(garonne_2_digue_Right_Bank, [48]) - controlGeomProps(geompy, riveGauche, 39490.835288, 35845737.590926) controlGeomProps(geompy, digue, 10341.466108, 103090.760662) controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) @@ -496,12 +482,6 @@ isDone = garonne_2.SplitQuadObject( garonne_2, 1 ) isDone = garonne_2.ReorientObject( garonne_2 ) # --- geometrical groups of edges -#garonne_2_litMineur_Outer_1 = garonne_2.GroupOnGeom(garonne_2_litMineur_Outer,'garonne_2_litMineur_Outer',SMESH.EDGE) -#garonne_2_domaineEtendu_Outer_1 = garonne_2.GroupOnGeom(garonne_2_domaineEtendu_Outer,'garonne_2_domaineEtendu_Outer',SMESH.EDGE) -#aval_1 = garonne_2.GroupOnGeom(aval,'aval',SMESH.EDGE) -#amont_1 = garonne_2.GroupOnGeom(amont,'amont',SMESH.EDGE) -#bordGaucheDomaine_1 = garonne_2.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.EDGE) -#bordDroiteDomaine_1 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.EDGE) SectionsGaronne_2 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE) SectionsDigue_2 = garonne_2.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.EDGE) @@ -512,16 +492,10 @@ riveDroite_1 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE) digue_1 = garonne_2.GroupOnGeom(digue,'digue',SMESH.FACE) # --- geometrical groups of nodes -#garonne_2_litMineur_Outer_2 = garonne_2.GroupOnGeom(garonne_2_litMineur_Outer,'garonne_2_litMineur_Outer',SMESH.NODE) -#garonne_2_domaineEtendu_Outer_2 = garonne_2.GroupOnGeom(garonne_2_domaineEtendu_Outer,'garonne_2_domaineEtendu_Outer',SMESH.NODE) riveGauche_2 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE) litMineur_3 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.NODE) riveDroite_2 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE) digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE) -#aval_2 = garonne_2.GroupOnGeom(aval,'aval',SMESH.NODE) -#amont_2 = garonne_2.GroupOnGeom(amont,'amont',SMESH.NODE) -#bordGaucheDomaine_2 = garonne_2.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.NODE) -#bordDroiteDomaine_2 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE) SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) @@ -536,11 +510,6 @@ except OSError: garonne_2.SetAutoColor( 1 ) garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -#controlMeshStats(garonne_2, 5247, 717, 10075) -#controlSubMeshStats(litMineur_2, 2384) -#controlSubMeshStats(riveDroite_1, 2348) -#controlSubMeshStats(riveGauche_1, 5343) -#controlSubMeshStats(digue_1, 0) controlMeshStats(garonne_2, 6190, 691, 12201) controlSubMeshStats(litMineur_2, 2384) controlSubMeshStats(riveDroite_1, 2400) @@ -574,7 +543,11 @@ zUndef = 90 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) -refstatz = {'riveDroite': (10.88, 32.61), 'riveGauche': (7.72, 71.86, 0.5), 'litMineur': (2.06, 25.41), 'digue': (14.10,27.09)} +#print statz +refstatz = {'riveDroite': (10.88, 32.61, 24.09, 5.13, 17.57, 31.33, 0.2), + 'riveGauche': (7.72, 71.39, 21.59, 8.37, 16.71, 35.71, 0.2), + 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78), + 'digue': (14.10, 27.09, 22.01, 2.56, 18.15, 25.02)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index fb40ad44..a7bb594e 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -475,7 +475,10 @@ zUndef = 80 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) -refstatz = {'riveDroite': (10.88, 32.61), 'riveGauche': (7.72, 71.86, 0.5), 'litMineur': (2.06, 25.41)} +#print statz +refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.2), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.2), + 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" diff --git a/doc/salome/examples/h017_interpolationLineaire.py b/doc/salome/examples/h017_interpolationLineaire.py index 471471e1..88e77ad7 100644 --- a/doc/salome/examples/h017_interpolationLineaire.py +++ b/doc/salome/examples/h017_interpolationLineaire.py @@ -282,10 +282,6 @@ import SALOMEDS geompy = geomBuilder.New(theStudy) -#geomObj_1 = geompy.CreateGroup(HYDRO_etude, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(geomObj_1, [7, 9]) -#geomObj_3 = geompy.CreateGroup(HYDRO_etude, geompy.ShapeType["EDGE"]) -#geompy.UnionIDs(geomObj_3, [4, 11, 17, 24, 26, 28, 14, 19, 20, 22, 31, 39, 41, 33, 35, 37]) etude_domaine_Outer = geompy.CreateGroup(HYDRO_etude_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(etude_domaine_Outer, [3, 6, 8, 10]) domaine = geompy.CreateGroup(HYDRO_etude_1, geompy.ShapeType["FACE"]) @@ -369,7 +365,8 @@ zUndef = 90 # --- Z interpolation Z sur la bathymetrie/altimetrie aux noeuds du maillage statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod) -refstatz = {'domaine': (27.101, 168.257)} +#print statz +refstatz = {'domaine': (27.10, 168.28, 91.77, 46.047, 28.637, 161.17)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" diff --git a/doc/salome/examples/h018_streamInterpolation.py b/doc/salome/examples/h018_streamInterpolation.py index f606b7dc..04cb1ba4 100644 --- a/doc/salome/examples/h018_streamInterpolation.py +++ b/doc/salome/examples/h018_streamInterpolation.py @@ -474,7 +474,10 @@ zUndef = 110 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) -refstatz = {'riveDroite': (99.8278, 100.8), 'riveGauche': (100.0, 100.0), 'litMineur': (80.4541, 100.8)} +#print statz +refstatz = {'riveDroite': (99.83, 100.80, 100.09, 0.21, 99.98, 100.64), + 'riveGauche': (100.0, 100.0, 100.0, 0.0, 100.0, 100.0), + 'litMineur': (80.45, 100.80, 92.85, 4.83, 84.43, 100.0)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index c8e80a8e..6db6d646 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -804,7 +804,7 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& } else { - DEBTRACE("aZoneInterpolator == NULL"); + //DEBTRACE("aZoneInterpolator == NULL"); aResAltitude = aMergeAltitude->GetAltitudeForPoint( thePoint ); } } diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 79444df5..a8222673 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -489,7 +489,7 @@ void HYDROData_Entity::SetReferenceObjects( const HYDROData_SequenceOfObjects& t Handle(HYDROData_Entity) HYDROData_Entity::GetReferenceObject( const int theTag, const int theIndex ) const { - DEBTRACE("GetReferenceObject " << theTag << " " << theIndex); + //DEBTRACE("GetReferenceObject " << theTag << " " << theIndex); Handle(HYDROData_Entity) aRes; Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false ); @@ -579,7 +579,7 @@ void HYDROData_Entity::ClearReferenceObjects( const int theTag ) Handle(TDataStd_ReferenceList) HYDROData_Entity::getReferenceList( const int theTag, const bool theIsCreate ) const { - DEBTRACE("getReferenceList " << theTag << " " << theIsCreate); + //DEBTRACE("getReferenceList " << theTag << " " << theIsCreate); TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag ); Handle(TDataStd_ReferenceList) aRefs; diff --git a/src/HYDROTools/controls.py b/src/HYDROTools/controls.py index ff1f418e..72246bc4 100644 --- a/src/HYDROTools/controls.py +++ b/src/HYDROTools/controls.py @@ -67,22 +67,28 @@ def controlSubMeshStats(aSubMesh, nbItems): def controlStatZ(statz,refstatz): """ - Compare min and max of z of regions with a reference, - with a precision of 0.05m by default. + Compare min, max, mean, standard deviation, percentile 5 and 95 of z of regions with a reference, + with a precision of 0.05m by default and 1.0m for min and max. """ for nomreg, valsref in refstatz.iteritems(): vals = statz[nomreg] - tolerance =0.05 - if len(valsref) > 2: - tolerance = valsref[2] - if abs(vals[0] - valsref[0]) > tolerance \ - or abs(vals[1] - valsref[1]) > tolerance: + tolerance =0.1 + if len(valsref) > 6: + tolerance = valsref[6] + if abs(vals[0] - valsref[0]) > 10*tolerance \ + or abs(vals[1] - valsref[1]) > 10*tolerance \ + or abs(vals[2] - valsref[2]) > tolerance \ + or abs(vals[3] - valsref[3]) > tolerance \ + or abs(vals[4] - valsref[4]) > 10*tolerance \ + or abs(vals[5] - valsref[5]) > 10*tolerance : print nomreg - print "value: ", vals, " reference: ", valsref, "tolerance: ", tolerance + print "value: ", vals + print "reference: ", valsref, "tolerance for mean, std dev: ", tolerance, "and ", 10*tolerance, "for other values" raise ValueError("z interpolation error") else: print nomreg - print "value: ", vals, " reference: ", valsref, "tolerance: ", tolerance, " OK" + print "value: ", vals + print "reference: ", valsref, "tolerance for mean, std dev: ", tolerance, "and ", 10*tolerance, "for other values: OK" import MEDLoader diff --git a/src/HYDROTools/interpolZ.py b/src/HYDROTools/interpolZ.py index 946ad23d..bf6a48ee 100644 --- a/src/HYDROTools/interpolZ.py +++ b/src/HYDROTools/interpolZ.py @@ -36,6 +36,8 @@ salome.salome_init() theStudy = salome.myStudy theStudyId = salome.myStudyId +import numpy as np + # ----------------------------------------------------------------------------- from med import medfile @@ -225,9 +227,14 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef, interpolMethod vx.append(xyz[0]) vy.append(xyz[1]) vz = cas.GetAltitudesForPoints( vx, vy, region, interpolMethod ) - minz = min(vz) - maxz = max(vz) - statz[grp.GetName()] = (minz, maxz) + minz = np.amin(vz) + maxz = np.amax(vz) + meanz = np.mean(vz) + stdz = np.std(vz) + v05z = np.percentile(vz,05) + v95z = np.percentile(vz,95) + + statz[grp.GetName()] = (minz, maxz, meanz, stdz, v05z, v95z) for i,nodeId in enumerate(nodesIds): -- 2.39.2