From: Paul RASCLE Date: Wed, 22 May 2019 16:07:12 +0000 (+0200) Subject: Python test scripts, second pass X-Git-Tag: SH_V2_2_0~99^2~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd4c734aa2affe55dc11840465f7219db9ca556f;p=modules%2Fhydro.git Python test scripts, second pass --- diff --git a/src/HYDROTools/interpolS.py b/src/HYDROTools/interpolS.py index 914afc18..5d5886ef 100755 --- a/src/HYDROTools/interpolS.py +++ b/src/HYDROTools/interpolS.py @@ -13,12 +13,9 @@ import HYDROPy import numpy as np import MEDLoader as ml -import MEDCoupling as mc +import medcoupling as mc -# Get current study id salome.salome_init() -theStudy = salome.myStudy -theStudyId = salome.myStudyId class BadParamsError(ValueError): """Bad parameters exception""" @@ -51,7 +48,7 @@ def assignStrickler(nomCas, input_file_name, output_file_name="", med_field_name # 1. Controls # 1.1. Check calculation case - doc = HYDROPy.HYDROData_Document.Document(theStudyId) + doc = HYDROPy.HYDROData_Document.Document() case = doc.FindObjectByName(nomCas) if case is None: raise BadParamsError("Calculation case '%s' not found" % nomCas) diff --git a/src/HYDROTools/interpolZ.py b/src/HYDROTools/interpolZ.py index ead2f43b..4d7d93da 100644 --- a/src/HYDROTools/interpolZ.py +++ b/src/HYDROTools/interpolZ.py @@ -24,12 +24,10 @@ __revision__ = "V3.01" import salome salome.salome_init() -theStudy = salome.myStudy -theStudyId = salome.myStudyId import numpy as np import MEDLoader as ml -import MEDCoupling as mc +import medcoupling as mc # ----------------------------------------------------------------------------- @@ -101,21 +99,21 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int if verbose: ligne = "nomCas: %s" % nomCas - ligne += "\ninterpolMethods: " % regions_interp_method + ligne += "\ninterpolMethods: %s" % regions_interp_method if (zUndef != None ): ligne += "\nzUndef: %f" % zUndef ligne += "\nm3d: %d" % m3d print (ligne) - doc = HYDROPy.HYDROData_Document.Document(theStudyId) + doc = HYDROPy.HYDROData_Document.Document() cas = doc.FindObjectByName(nomCas) - print(( "cas : ", cas)) + print ( "cas : ", cas) custom_inter = MyInterpolator() basename = fichierMaillage[:-4] fichierFMaillage = basename + 'F.med' - print(("dicoGroupeRegion = ", dicoGroupeRegion)) + print ("dicoGroupeRegion = ", dicoGroupeRegion) ligne = "fichierMaillage = %s" % fichierMaillage ligne += "\nfichierFMaillage = %s" % fichierFMaillage if xyzFile: @@ -166,7 +164,7 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int print (ligne) # coords = meshMEDFileRead.getCoords() - #print coords + #print (coords) if verbose: nb_comp = coords.getNumberOfComponents() l_info = coords.getInfoOnComponents() @@ -228,7 +226,8 @@ def interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef=90., regions_int # vx = list() vy = list() - for nodeId in np_aux[0]: + for nid in np_aux[0]: + nodeId = nid.item() vx.append(coords[nodeId, 0]) vy.append(coords[nodeId, 1]) #print ("vx:\n", vx) @@ -385,9 +384,9 @@ def interpolZ_B(bathyName, fichierMaillage, gr_face_name, zUndef=90., interp_met Option: Z value also in Z coordinate if m3D is true return .xyz : text file with X, Y, Z values """ - doc = HYDROPy.HYDROData_Document.Document(theStudyId) + doc = HYDROPy.HYDROData_Document.Document() bathy_obj = doc.FindObjectByName(bathyName) - print(( "bathy : ", bathy_obj)) + print( "bathy : ", bathy_obj) if bathy_obj is None: print ( "bathy is None") return False