6 return collections.defaultdict(tree)
13 filename = "timeseries.med"
14 filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),filename)
17 from MEDLoader import MEDLoader
18 meshNames = MEDLoader.GetMeshNames(filepath)
20 meshDimRelToMax = 0 # 0 = no restriction
22 for meshName in meshNames:
23 mesh = MEDLoader.ReadUMeshFromFile(filepath,meshName,meshDimRelToMax)
24 meshDict[meshName] = mesh
26 fieldNames = MEDLoader.GetAllFieldNamesOnMesh(filepath,meshName)
27 for fieldName in fieldNames:
28 listOfTypes = MEDLoader.GetTypesOfField(filepath,meshName,fieldName)
29 for typeOfDiscretization in listOfTypes:
30 fieldIterations = MEDLoader.GetFieldIterations(typeOfDiscretization,
34 for fieldIteration in fieldIterations:
35 itNumber = fieldIteration[0]
36 itOrder = fieldIteration[1]
38 field = MEDLoader.ReadField(typeOfDiscretization,
49 [typeOfDiscretization]\
50 [itNumber][itOrder] = field
53 # Q: use a list of structures whose an attribute could be a
54 # MEDCoupling field? Or a tree that you cross using attribute and
55 # whose leaves are the MEDCoupling fields?
56 # R: I think that the default structure should be a simple list that
57 # store objects whith properties that corresponds to the metadata (and
58 # if loaded the MEDCouplingField or Mesh). Then for specific request,
59 # a BTree could be create to organize the search (for example if we
60 # request all the fields for a given iteration step, then we should
61 # use the iteration step as a first classifaction switch of the tree
63 print fieldTree.keys()
66 for meshName in fieldTree.keys():
68 for fieldName in fieldTree[meshName].keys():
70 for fieldType in fieldTree[meshName][fieldName].keys():
72 for itNumber in fieldTree[meshName][fieldName][fieldType].keys():
73 for itOrder in fieldTree[meshName][fieldName][fieldType][itNumber].keys():
74 print " (%s,%s)"%(itNumber,itOrder)
75 print fieldTree[meshName][fieldName][fieldType][itNumber][itOrder]