Salome HOME
Python test scripts, second pass
authorPaul RASCLE <paul.rascle@edf.fr>
Wed, 22 May 2019 16:07:12 +0000 (18:07 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Wed, 22 May 2019 16:07:12 +0000 (18:07 +0200)
src/HYDROTools/interpolS.py
src/HYDROTools/interpolZ.py

index 914afc18ee232f5617de5845e022726488649eab..5d5886ef72ff76c724b357aff30627f9e58d7de3 100755 (executable)
@@ -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)
index ead2f43bbc8d47ef130217f0cc16d8e961625da8..4d7d93dafb5bdf22ae8b8d0d2c8e27d5caca78cb 100644 (file)
@@ -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 <fichierMaillage>.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