Sunday, 15 May 2011

matlab - Issues with extracting variables from NetCDF file in python -



matlab - Issues with extracting variables from NetCDF file in python -

i'm new python, , have experience matlab. not getting right values outgoing longwave radiation netcdf file , have tried scipy.io.netcdf module , scientific.io.netcdf module.

import scientific.io.netcdf s fileobj = s.netcdffile('filename.nc', mode='r') info = fileobj.variables['var'].getvalue() # tried both , w/o .getvalue() print data[0:10,43,80] #first 10 points in time @ specific lat/lon [ -5124 -5335 -5121 -5499 -5508 -8930 -10111 -9435 -8534 -8487]

my code using scipy.io.netcdf same except didn't utilize .getvalue(). tried exercise in matlab

data = ncread('filename.nc','var'); data[80,43,1:10] %note matlab orders info lon, lat, time ans(:,:,1) = 275.0400 ans(:,:,2) = 279.0800 ans(:,:,3) = 279.6800 ans(:,:,4) = 277.8700 ans(:,:,5) = 275.5900 ans(:,:,6) = 241.4700 ans(:,:,7) = 223.1900 ans(:,:,8) = 235.5700 ans(:,:,9) = 239.8200 ans(:,:,10) = 249.5400

i know values produced matlab correct. variable should in range of 80-330 (watts per square meter). ideas on what's going on python? thanks

try syntax:

from scipy.io.netcdf import netcdf_file dataset ncfile = dataset('filename.nc','r') info = ncfile.variables['var'][:,:,:]

python matlab netcdf

No comments:

Post a Comment