test.py 1.44 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 ====================================#')
10
11
12
for k, tax in cdi.taxes.items():
  print(k,": ", tax.unitname)
  print(k,": ", tax.ntsteps)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
13

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

18
print("#========== ZAXES ====================================#")
19
20
for k, zax in cdi.zaxes.items():
  print(k,": ", zax.size,' ', zax.name,' ', zax.units)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
21

22
print("#========== VARIABLES ================================#")
23
24
25
for var in cdi.variables:
  print(k,var.name," ",var.size, " ", var.missval)
  print(var.longname,' ',var.units)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
26

27
print("#========== VAR by index ======================================#")
28
var = cdi.variables[1]
29
30
var.getValues()
val = var.values
31
32
33
34
35
36
37
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
38
39
name ="tsurf"
newvar = cdi.var[name]
40
41
print("name ",name," var.name: ", newvar.name, " var.grids.xsize: " , newvar.grid.xsize)
print("#========= Var by code ===============================#")
42
43
44
code = 169
newvar = cdi.varByCode[code]
newvar.sinfo()