[SciPy-User] netCDF output error

Neil Berg nberg@atmos.ucla....
Wed Oct 27 21:00:26 CDT 2010


Ryan,

Your gut was right, as my line to create the 'time' dimension mismatched with ntim.  I greatly appreciate your help!  

Cheers,
Neil
On Oct 27, 2010, at 6:47 PM, Ryan May wrote:

> On Wed, Oct 27, 2010 at 7:58 PM, Neil Berg <nberg@atmos.ucla.edu> wrote:
>> from scipy.io.netcdf import netcdf_file as Dataset
>> from scipy.interpolate import interp1d
>> .....
>> ws80 = zeros([ntim,nlat,nlon],'float32')
>> for tim_idx in range(0,ntim): # loops from hour 0 to hour 744, which covers entire month of January
>>            z_arr = (za1[tim_idx],za2[tim_idx])     # nearest heights below 80 meters (za1) and above 80 meter (za2)
>>            ws_arr = (wspd1[tim_idx],wspd2[tim_idx]) # wind speeds at za1 and za2
>>            f = interp1d(z_arr,ws_arr, kind='linear')
>>            ws80[tim_idx,lat_idx,lon_idx] = f(80) # interpolated wind speed at 80 meters
>>            print "time =",tim_idx,"lat =",lat_idx,"lon =",lon_idx,"ws80 =",ws80[tim_idx,lat_idx,lon_idx]
>> ....
>> ncfile_out = Dataset('output_file','w')
>> data = ncfile_out.createVariable('ws80',dtype('float32').char,('time','latitude','longitude',))
>> data.units = "m s-1"
>> data[:,:,:] = ws80[:,:,:]
>> ncfile_out.close()
>> _______________________________________________________
> 
> Where's the code where you create the dimensions
> ('time','latitude','longitude',)? My first gut guess is that the shape
> of the variable as written doesn't match the array.
> 
> Ryan
> 
> -- 
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list