Changeset 19055
- Timestamp:
- 01/30/15 18:04:17 (10 years ago)
- Location:
- issm/trunk-jpl/src/m/contrib/netCDF
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/netCDF/export_netCDF.py
r18927 r19055 14 14 def GetDim(var,shape,i,istime): 15 15 output=[] 16 for dim in range(0,i): 17 if type(shape[0])==int: 16 for dim in range(0,i): #loop on the dimensions 17 if type(shape[0])==int: 18 18 try: 19 output=output+[str(DimDict[shape[dim]])] 20 except KeyError: 19 output=output+[str(DimDict[shape[dim]])] #test if the dimension allready exist 20 except KeyError: #if not create it 21 21 if (shape[dim])>1: 22 NewDim=NCData.createDimension(str(field) ,(shape[dim]))23 DimDict[len(NewDim)]=str(field) 22 NewDim=NCData.createDimension(str(field)+str(dim),(shape[dim])) 23 DimDict[len(NewDim)]=str(field)+str(dim) 24 24 output=output+[str(DimDict[shape[dim]])] 25 print 'Defining dimension ' +str(shape[dim]) +' for '+str(field) 25 print 'Defining dimension ' +str(shape[dim]) +' for '+str(field)+str(dim) 26 26 elif type(shape[0])==str:#dealling with a dictionnary 27 27 try: … … 129 129 VertNum=NCData.createDimension('VertNum',md.mesh.numberofvertices) 130 130 VertperElt=NCData.createDimension('VertperElt',numpy.shape(md.mesh.elements)[1]) 131 if type(md.mesh) is mesh2d:132 DimNum=NCData.createDimension('DimNum',2)133 elif type(md.mesh) is mesh3dprisms:134 DimNum=NCData.createDimension('DimNum',3)135 else:136 print 'I can not get the Dimension of the problem'137 EdgeNum=NCData.createDimension('EdgeNum',md.mesh.numberofedges)138 Time=NCData.createDimension('Time',StepNum)139 SegNum=NCData.createDimension('SegNum',numpy.shape(md.mesh.segmentmarkers)[0])140 InvSteps=NCData.createDimension('InvSteps',md.inversion.nsteps)141 DictDim=NCData.createDimension('DictDim',2)142 131 143 132 DimDict = {len(EltNum):'EltNum', 144 133 len(VertNum):'VertNum', 145 len(VertperElt):'VertperElt', 146 len(DimNum):'DimNum', 147 len(EdgeNum):'EdgeNum', 148 len(Time):'Time', 149 len(SegNum):'SegNum', 150 len(InvSteps):'InvSteps'} 134 len(VertperElt):'VertperElt'} 151 135 152 136 TypeDict = {float:'f8',
Note:
See TracChangeset
for help on using the changeset viewer.