Doc/Tools/External: reading_nc.py
File reading_nc.py, 458 bytes (added by acosce, 8 years ago) |
---|
Line | |
---|---|
1 | import numpy as np |
2 | from netCDF4 import Dataset as NetCDFFile |
3 | |
4 | filename = '/media/ExtDiskC_ext4/bkup/foudre/feinetes/BootCamp/files/Relief.nc' |
5 | toponame = 'RELIEF' |
6 | |
7 | ncobj = NetCDFFile(filename, 'r') |
8 | |
9 | objtopo = ncobj.variables[toponame] |
10 | |
11 | print 'variables:',ncobj.variables.keys() |
12 | print 'dimension of the topography:', \ |
13 | objtopo.shape |
14 | topovals = objtopo[:] |
15 | utopo = objtopo.getncattr('units') |
16 | print 'maximum height:', np.max(topovals), \ |
17 | utopo |
18 | |
19 | ncobj.close() |