testObj.py 1.64 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

cdi = CdiObj.Cdi(ifile)

7
print('Stream: ',cdi.streamID,' vlistID:',cdi.vlistID,' nvars:{d}', cdi.nvars)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
8

9
print('#========== TAXES ====================================#')
Uwe Schulzweida's avatar
Uwe Schulzweida committed
10
for k in range(cdi.taxes.size()):
11
  print(k,": ", cdi.taxes[k].unitname)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
12

13
print('#========== GRIDS ====================================#')
Uwe Schulzweida's avatar
Uwe Schulzweida committed
14
for k in range(cdi.grids.size()):
15
  print(k,": ", cdi.grids[k].size,' ', cdi.grids[k].xname,' ', cdi.grids[k].yname,' ', cdi.grids[k].ylongname) 
Uwe Schulzweida's avatar
Uwe Schulzweida committed
16

17
print("#========== ZAXES ====================================#")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
18
for k in range(cdi.zaxes.size()):
19
  print(k,": ", cdi.zaxes[k].size,' ', cdi.zaxes[k].name,' ', cdi.zaxes[k].units)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
20

21
print("#========== VARIABLES ================================#")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
22
23
for k in range(cdi.variables.size()):
  v = cdi.variables[k]
24
  print(v.name," ",v.size, " ", v.missval)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
25

26
print("#========== VARIABLEcdi.NAMES =================================#")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
27
for k in range(cdi.variables.size()):
28
  print(cdi.variables[k].longname,' ',cdi.variables[k].units)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
29

30
print("#========== VAR by index ======================================#")
31
var = cdi.variables[1]
32
33
var.getValues()
val = var.values
34
35
36
37
38
39
40
i=0; print('val[',i,'] = ',val[i])
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])
print("#========= Var by name ===============================#")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
41
42
name ="tsurf"
newvar = cdi.var[name]
43
44
print("name ",name," var.name: ", newvar.name, " var.grids.xsize: " , newvar.grid.xsize)
print("#========= Var by code ===============================#")
45
46
47
code = 169
newvar = cdi.varByCode[code]
newvar.sinfo()