error reading online netcdf data

Dear All,
I am trying to read this file with Matlab, using the following as advised by Columbia website :
loaddap('http://iridl.ldeo.columbia.edu/SOURCES/.UCSB/.CHIRPS/.v2p0/.daily-improved/.global/.0p05/.prcp/Y/%281N%29%2817N%29RANGEEDGES/X/%2830E%29%2850E%29RANGEEDGES/dods')
loaddap is not working so I used this and it works :
filename =
'http://iridl.ldeo.columbia.edu/SOURCES/.UCSB/.CHIRPS/.v2p0/.daily-improved/.global/.0p05/.prcp/Y/%281N%29%2817N%29RANGEEDGES/X/%2830E%29%2850E%29RANGEEDGES/dods'
and these are the variables in the netcdf file (latitude, longitude, time and precipitation) :
ncdisp(filename)
Source:
Format:
classic
Global Attributes:
Conventions = 'IRIDL'
Dimensions:
T = 14244
X = 400
Y = 320
Variables:
T
Size: 14244x1
Dimensions: T
Datatype: single
Attributes:
standard_name = 'time'
pointwidth = 1
calendar = 'standard'
expires = 1580515200
gridtype = 0
units = 'julian_day'
Y
Size: 320x1
Dimensions: Y
Datatype: single
Attributes:
standard_name = 'latitude'
pointwidth = 0.05
gridtype = 0
units = 'degree_north'
X
Size: 400x1
Dimensions: X
Datatype: single
Attributes:
standard_name = 'longitude'
pointwidth = 0.05
gridtype = 0
units = 'degree_east'
prcp
Size: 400x320x14244
Dimensions: X,Y,T
Datatype: single
Attributes:
pointwidth = 1
missing_value = -9999
standard_name = 'lwe_precipitation_rate'
units = 'mm/day'
long_name = 'precipitation'
expires = 1580515200
CE = 100
maxncolor = 254
scale_min = 0
CS = 0
colormap = '13882323
16777215
16777215
16777184
6
15453831
6
16748574
14
13434880
18
4026644
24
7451452
21
9419919
43
9234160
44
6333684
41
2237106
43
2237106'
colorscalename = 'prcp_dailyrate_max100_smooth'
scale_max = 100
ncolor = 254
Now if I read the variables latitude, longitude and time (X,Y and T), it works perfectly, but then when I arrive to read the precipitation variables I get the following error :
longitude=ncread (filename, 'X');
latitude=ncread (filename, 'Y');
time=ncread (filename, 'T');
prec=ncread (filename, 'prcp');
66 vardata = ncObj.read(varName, varargin{:});
Error using netcdflib
The NetCDF library encountered an error during execution of 'getVarFloat' function - 'Access failure (-77)'.
Error in netcdf.getVar (line 140)
data = netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 605)
data = netcdf.getVar(gid, varid);
Error in ncread (line 66)
vardata = ncObj.read(varName, varargin{:});
Can you please help me ?

 Accepted Answer

Hello,
I ran into a similar issue while trying to download another dataset from the same host webpage. The issue is that the command to read the data attempts to serve the entire dataset as one file which is too big, and I believe that explains the error you receive. Try instead to call the ncread function several times in a loop, and you may even have to save some of these data subsets to disk and remove from the workspace lest you run out of ram. Here is a short script to read in the data in smaller chunks and save:
filename = 'http://iridl.ldeo.columbia.edu/SOURCES/.UCSB/.CHIRPS/.v2p0/.daily-improved/.global/.0p05/.prcp/Y/%281N%29%2817N%29RANGEEDGES/X/%2830E%29%2850E%29RANGEEDGES/dods';
ncdisp(filename)
longitude=ncread(filename,'X');
latitude=ncread(filename,'Y');
time=ncread(filename,'T');
% Load data in 500 day increments:
incr=500; indVec=1:incr:length(time);
for i=1:length(indVec)
if i==length(indVec)
precip=ncread(filename,'prcp',[1 1 indVec(i)],[Inf Inf Inf]);
else
precip=ncread(filename,'prcp',[1 1 indVec(i)],[Inf Inf incr]);
end
save(['Prcp',num2str(i)],'precip'); clear precip;
end
Hope this helps!
-A

1 Comment

Hi Andrew,
I emailed Columbia university, and they told me exactly the same thing like one week ago, therefore I am accepting your answer, thanks for your help.

Sign in to comment.

More Answers (0)

Asked:

on 5 Feb 2020

Commented:

on 3 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!