Doc/Tools/External: reading_nc.py

File reading_nc.py, 458 bytes (added by acosce, 8 years ago)

fichier TP python reading_nc Bootcamp 24 mars 2016

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