Need help reading netcdf files
17 views (last 30 days)
Show older comments
I am trying to read a subset of a netcdf file. I have a bunch of these files to read, but I can't even get one to work.
The subset is a time series of surface pressure ('sp') at one single latitude and longitude. My latitude is at 646 and the longitude is at 446. I only need this one point.
Here is what I have so far. When I try to read the entire file, it runs out of memory, but I also can't read a subset of the file either.
Can anyone point me in the right direction on how to read a subset of the file and also assign it to a variable? I eventually need to plot the time series.
Thank you much.
ncdisp('January_June_1992_Hourly_sp.nc')
Source:
F:\All_ERA_5\1990s\January_June_1992_Hourly_sp.nc
Format:
64bit
Global Attributes:
Conventions = 'CF-1.6'
history = '2019-03-12 03:17:31 GMT by grib_to_netcdf-2.10.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -o /cache/data3/adaptor.mars.internal-1552360053.8510885-11556-13-869f19cf-3b8a-4e0f-8265-af78ecffde0f.nc /cache/tmp/869f19cf-3b8a-4e0f-8265-af78ecffde0f-adaptor.mars.internal-1552360053.8514261-11556-3-tmp.grib'
Dimensions:
longitude = 1440
latitude = 721
time = 4368
Variables:
longitude
Size: 1440x1
Dimensions: longitude
Datatype: single
Attributes:
units = 'degrees_east'
long_name = 'longitude'
latitude
Size: 721x1
Dimensions: latitude
Datatype: single
Attributes:
units = 'degrees_north'
long_name = 'latitude'
time
Size: 4368x1
Dimensions: time
Datatype: int32
Attributes:
units = 'hours since 1900-01-01 00:00:00.0'
long_name = 'time'
calendar = 'gregorian'
sp
Size: 1440x721x4368
Dimensions: longitude,latitude,time
Datatype: int16
Attributes:
scale_factor = 0.88881
add_offset = 76906.7529
_FillValue = -32767
missing_value = -32767
units = 'Pa'
long_name = 'Surface pressure'
standard_name = 'surface_air_pressure'
startLoc = [446 646 1]; % Start location along each coordinate
count = [0 0 Inf]; %I only need it to read at this one point, but at all times.
ABN_sp_Data = ncread('January_June_1992_Hourly_sp.nc','sp');
Out of memory. Type HELP MEMORY for your options.
Error in internal.matlab.imagesci.nc/read (line 651)
data = double(data);
Error in ncread (line 58)
vardata = ncObj.read(varName, varargin{:});
ABN_ERA5_1992_sp = ncread('January_June_1992_Hourly_sp','sp', startLoc,count);
Error using internal.matlab.imagesci.nc/openToRead (line 1272)
Could not open January_June_1992_Hourly_sp for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 53)
ncObj = internal.matlab.imagesci.nc(ncFile);
4 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!