[英]Reading 1-D Variables in WRF NetCDF files with GDAL python
我的問題很簡單。
例如,帶有wrfout文件“ out.nc”。
該文件包含Geo2D,Geo3D和1D變量。
使用Python 2.7中的GDAL包,我可以像這樣輕松提取Geo2D變量:
## T2 is 2-d variable means temperature 2 m above the ground
temp = gdal.Open('NETCDF:"'+"out.nc"+'":T2')
但是,當我想使用此代碼提取1d數組時,它失敗了。
## Time is 1-d array represent the timeseries throught the simulation period
time = gdal.Open('NETCDF:"'+"out.nc"+'":Time')
沒啥事兒! 希望有人提供一些建議,以輕松閱讀WRF輸出變量的任意維!
您也可以在scipy.io中使用NetCDF閱讀器:
import scipy.io.netcdf as nc
# Open a netcdf file object and assign the data values to a variable
time = nc.netcdf_file('out.nc', 'r').variables['Time'][:]
它的優點是scipy是一個非常受歡迎且安裝廣泛的軟件包,同時在某些方面類似於打開文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.