ncdisp displays the netcdf file but cannot open with netcdf.open
4 次查看(过去 30 天)
显示 更早的评论
Hello,
I am using Matlab R2016a and trying to work with netcdf files. I can view the variable information with ncdisp and everything appears as I think it should, but I cannot used netcdf.open.
The output of ncdisp:
Format: classic
Dimensions: lon = 720 lat = 360 ncl2 = 365 Variables:
lon
Size: 720x1
Dimensions: lon
Datatype: single
Attributes:
long_name = 'Longitude'
units = 'degrees_east'
comment = 'center of cell'
lat
Size: 360x1
Dimensions: lat
Datatype: single
Attributes:
long_name = 'Latitude'
units = 'degrees_north '
comment = 'center of cell'
O3_1hrDailyMax
Size: 720x360x365
Dimensions: lon,lat,ncl2
Datatype: single
Attributes:
missing_value = 1.000000020040877e+20
_FillValue = 1.000000020040877e+20
average_op_ncl = 'dim_avg_n over dimension(s): ncl_join'
lon = 357.5
associated_files = 'baseURL: http://htap.icg.fz-juelich.de/data/ACCMIP gridspecFile: gridspec_atmos_fx_CESM-CAM-superfast_accrcp60_r0i0p0.nc'
cell_methods = 'time: mean (interval: 30 minutes)'
original_name = 'O3'
units = '1'
long_name = 'O3 Volume Mixing Ratio in Lowest Model Layer'
standard_name = 'mole_fraction_of_ozone_in_air'
max_op_ncl = 'dim_max_n over dimension(s): time'
The netcdf.open error:
Error using netcdflib
'ncid' must be a non-empty finite numeric scalar value.
Error in netcdf.getVar (line 100) data = netcdflib(funcstr,ncid,varid,varargin{1:end-1});
Error in tryingnetcdffiles (line 9) varid = netcdf.getVar('regrid_1hrDailyMaximum_CESM-CAM-superfast_accrcp60_r1i1p1_05x05.nc','lon','single');
Are there any ideas of things I should look into trying?
Thank you!
0 个评论
回答(1 个)
Prashant Arora
2017-4-28
编辑:Prashant Arora
2017-4-28
Hi MelMo,
It looks like the error is generated by the command "netcdf.getVar" function at line 9 of "tryingnetcdffiles" script/function. I see that you are calling the netcdf.getVar function with the name of the file rather than the file ID. To use the function, you need to first get the fileID by using netcdf.open like this:
ncid = netcdf.open('Name');
varname = netcdf.inqVar(ncid,0) %Query First Variable Name
varid = netcdf.inqVarID(ncid,varname) %Query ID with Variable Name
data = netcdf.getVar(ncid,varid);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!