From bd4c734aa2affe55dc11840465f7219db9ca556f Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Wed, 22 May 2019 18:07:12 +0200 Subject: [PATCH] Python test scripts, second pass --- src/HYDROTools/interpolS.py | 7 ++----- src/HYDROTools/interpolZ.py | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) 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 -- 2.39.2