LoginSignup
2
4

More than 5 years have passed since last update.

python / netCDF > nc.variables[]でのデータ読込 / データサイズ確認

Last updated at Posted at 2016-10-21
動作環境
CentOS 6.5

複数のNetCDFファイルの数値を比較する予定。
環境の違いにより、浮動小数点の値が微妙に変わる可能性がある。
グラフで表示したいかと思う。

pythonでnetCDF4を読み取る例が見つかった。
参考1 http://qiita.com/okadate/items/954574a95545b06ca257
参考2 http://qiita.com/AnchorBlues/items/2dd18c1e9587c8f495bc

以下を実装してみた。
.shapeで読込んだdataのサイズが分かるようだ。

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
結果
$ python read_nc.py 
(24, 1, 1, 3, 65, 82)
dim_we= 82
dim_sn= 65

24: 時間の次元
3: top, bottom
65: south north
82: west east

残りの1,1は未消化。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4