Operating environment
CentOS 6.5
We plan to compare the numbers in multiple NetCDF files. Floating-point values can change slightly due to different environments. I want to display it as a graph.
I found an example of reading netCDF4 with python. Reference 1 http://qiita.com/okadate/items/954574a95545b06ca257 Reference 2 http://qiita.com/AnchorBlues/items/2dd18c1e9587c8f495bc
I implemented the following. It seems that you can see the size of the data read by .shape.
read_nc.py
import netCDF4
nc = netCDF4.Dataset('sample.nc', 'r')
dim_we = len(nc.dimensions['west_east'])
dim_sn = len(nc.dimensions['south_north'])
data = nc.variables['CONC'][:]
nc.close()
print data.shape
print 'dim_we=',dim_we
print 'dim_sn=',dim_sn
result
$ python read_nc.py
(24, 1, 1, 3, 65, 82)
dim_we= 82
dim_sn= 65
24: Dimension of time 3: top, bottom 65: south north 82: west east
The remaining 1,1 are undigested.
Recommended Posts