3 from MEDLoader import MEDLoader
6 #filename = "madnex_field.med"
7 filename = "timeseries.med"
8 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
10 # Read the source meshes
11 meshNames = MEDLoader.GetMeshNames(filepath)
13 # Set to True if the meshes and fields data must be loaded. Otherwise,
14 # only theire descriptions will be loaded.
15 READ_PHYSICAL_DATA=False
17 for meshName in meshNames:
21 # At this step, one can load the mesh of name meshName (but it is
22 # not an obligation to continue to explore the metadata)
23 meshDimRelToMax = 0 # 0 = no restriction
24 if READ_PHYSICAL_DATA:
25 mesh = MEDLoader.ReadUMeshFromFile(filepath,meshName,meshDimRelToMax)
26 # Note that the read function required the parameter
27 # meshDimRelToMax. This parameter discreminates the meshdim you
28 # are interested to relatively to the maximal dimension of cells
29 # contained in the mesh in file (then its value could be 0, -1, -2
30 # or -3 depending on the max dimension of the mesh. 0 means "no
33 # Read the names of the fields that rely on this mesh
34 fieldNames = MEDLoader.GetAllFieldNamesOnMesh(filepath,meshName)
36 for fieldName in fieldNames:
40 # A field name could identify several MEDCoupling fields, that
41 # differ by their spatial discretization on the mesh (values on
42 # cells, values on nodes, ...). This spatial discretization is
43 # specified by the TypeOfField that is an integer value in this
50 # As a consequence, before loading values of a field, we have
51 # to determine the types of spatial discretization defined for
52 # this field and to chooose one.
54 listOfTypes = MEDLoader.GetTypesOfField(filepath,meshName,fieldName)
55 for typeOfDiscretization in listOfTypes:
56 print " %s"%typeOfDiscretization
58 # Then, we can get the iterations associated to this field on
59 # this type of spatial discretization:
60 fieldIterations = MEDLoader.GetFieldIterations(typeOfDiscretization,
65 # Then, we can access to the physical data for each
66 # iteration of this field
67 for fieldIteration in fieldIterations:
68 itNumber = fieldIteration[0]
69 itOrder = fieldIteration[1]
70 print " (%s,%s)"%(itNumber,itOrder)
72 if READ_PHYSICAL_DATA:
73 medCouplingField = MEDLoader.ReadField(typeOfDiscretization,
80 print medCouplingField