How can I properly retrieve data from a remote file that ncread returns wrongly.

The following code demonstrates the error I'm having retrieving data properly from a remote NetCDF file. Ncread retrieves data but somehow has messed up in the indexing between the 3rd and 4th dimensions. Anyone now of a solution, workaround to this issue or seen this issue?
if true
% code
%
% ncread error demonstration
%
urlstr ='http://ourocean.jpl.nasa.gov:8080/thredds/dodsC/CA3kmForecast/ca_subCA_fcst_2013013003.nc';
ncinfo(urlstr,'temp') % shows temp has dimension of 351X391X12X73 longitudes,latitudes, depths, times
temp=ncread(urlstr,'temp',[1 1 1 1],[Inf Inf 1 Inf]); % returns an array of 351x391x1x73 however this array is WRONG.
% as you change the last element you should be advancing in time, but
% instead you are going to different depths!
% Using
temp2=ncread(urlstr,'temp',[1 1 1 9],[Inf Inf 1 9]); % this returns an array with apparently the correct time stamp
% the array is now 351x391x1x9
temp2=ncread(urlstr,'temp',[1 1 1 10],[Inf Inf 1 60]); % also returns an array 351x391x1x60 again apparently correctly.
% however if you try to access elements beyond
try
temp3=ncread(urlstr,'temp',[1 1 1 10],[Inf Inf 1 65]); % fails
catch
temp3=ncread(urlstr,'temp',[1 1 1 10],[Inf Inf 1 64]); % works
end
% In all cases I want the stride to be 1 so it has been omitted, but the
% code fails just the same if you add it.
% The data can be compared by contour plots.
ll=temp < 0;
temp(ll)=NaN;
ll=temp2 < 0;
temp2(ll)=NaN;
figure(1)
contourf(temp(:,:,1,9)); % wrong
figure(2)
contourf(temp2(:,:,1,9)); % correct
% So how do you access the data at indecies 65-73 in time?
end

Answers (0)

Products

Tags

Asked:

on 31 Jan 2013

Community Treasure Hunt

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

Start Hunting!