Changeset 379 for trunk/UTIL
- Timestamp:
- Nov 14, 2011, 12:25:49 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/make_netcdf.py
r376 r379 55 55 56 56 zdims={} 57 zdims[ nx]='longitude'58 zdims[ ny]='latitude'59 zdims[ nz]='altitude'60 zdims[ nt]='Time'57 zdims['longitude']=nx 58 zdims['latitude']=ny 59 zdims['altitude']=nz 60 zdims['Time']=nt 61 61 print zdims 62 62 # Find which variable uses which dimensions … … 70 70 j=0 71 71 for dim in zvardim: 72 if dim not in zdims. keys():72 if dim not in zdims.values(): 73 73 print "WARNING -----------------------------" 74 74 print "Dimensions given to subroutine do not match variables dimensions :" … … 78 78 exit() 79 79 else: 80 zzvardim[j]=zdims[dim] 80 a=get_key(zdims,dim) 81 if len(a) is not 1: 82 if j is 0: ##this should solve most conflicts with Time 83 zzvardim[j]=a[1] 84 else: 85 zzvardim[j]=a[0] 86 else: 87 zzvardim[j]=a[0] 81 88 j=j+1 82 89 zvarcarac[zznames[i]]=zzvardim 83 90 i=i+1 84 91 print zvarcarac 92 85 93 ######################### 86 94 ## Clean previous file ## … … 130 138 ## close file 131 139 file.close() 140 141 def find_key(dic, val): 142 """return the key of dictionary dic given the value""" 143 return [k for k, v in dic.iteritems() if v == val][0] 144 145 def get_key(self, value): 146 """find the key(s) as a list given a value""" 147 return [item[0] for item in self.items() if item[1] == value]
Note: See TracChangeset
for help on using the changeset viewer.