Changeset 19055


Ignore:
Timestamp:
01/30/15 18:04:17 (10 years ago)
Author:
bdef
Message:

NEW: adding netcdf export for matlab and minor change in python

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  
    1414        def GetDim(var,shape,i,istime):
    1515                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: 
    1818                                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
    2121                                        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)
    2424                                                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)
    2626                        elif type(shape[0])==str:#dealling with a dictionnary
    2727                                try:
     
    129129        VertNum=NCData.createDimension('VertNum',md.mesh.numberofvertices)
    130130        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)
    142131
    143132        DimDict = {len(EltNum):'EltNum',
    144133                                                 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'}
    151135
    152136        TypeDict = {float:'f8',
Note: See TracChangeset for help on using the changeset viewer.