testObj.py 1.56 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
import CdiObj

3
ifile = "../testdata/mulval.grb"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

cdi = CdiObj.Cdi(ifile)

print 'Stream: ',cdi.streamID,' vlistID:',cdi.vlistID,' nvars:{d}', cdi.nvars

print '#========== TAXES ====================================#'
for k in range(cdi.taxes.size()):
  print  k,": ", cdi.taxes[k].ntsteps

print '#========== GRIDS ====================================#'
for k in range(cdi.grids.size()):
  print k,": ", cdi.grids[k].size,' ', cdi.grids[k].xname,' ', cdi.grids[k].yname,' ', cdi.grids[k].ylongname 

print "#========== ZAXES ====================================#"
for k in range(cdi.zaxes.size()):
  print k,": ", cdi.zaxes[k].size,' ', cdi.zaxes[k].name,' ', cdi.zaxes[k].units

print "#========== VARIABLES ================================#"
for k in range(cdi.variables.size()):
  v = cdi.variables[k]
  print v.name," ",v.size, " ", v.missval

print "#========== VARIABLEcdi.NAMES =================================#"
for k in range(cdi.variables.size()):
  print cdi.variables[k].longname,' ',cdi.variables[k].units

print "#========== VAR ======================================#"
31
var = cdi.variables[1]
32
33
var.getValues()
val = var.values
Uwe Schulzweida's avatar
Uwe Schulzweida committed
34
i=0; print 'val[',i,'] = ',val[i]
35
36
37
38
39
i=1; print 'val[',i,'] = ',val[i]
i=2; print 'val[',i,'] = ',val[i]
i=3; print 'val[',i,'] = ',val[i]
i=4; print 'val[',i,'] = ',val[i]
i=5; print 'val[',i,'] = ',val[i]
Uwe Schulzweida's avatar
Uwe Schulzweida committed
40
41
42
43
44
print "#=====================================================#"
name ="tsurf"
newvar = cdi.var[name]
print "name ",name," var.name: ", newvar.name, " var.grids.xsize: " , newvar.grid.xsize
print "#=====================================================#"