%% Matlab GMAO GDS example
%%
%% Author: Denis Nadeau
%%
%%
%%

url = 'http://opendap.gsfc.nasa.gov:9090/dods/GEOS-5/yotc/0.25_deg/fcast/inst3_3d_asm_Np.latest'
%
% Retrieve all the metadata using loaddap with the -A switch.
m = loaddap ( '-A', url )

%
% Now look at the metadata for the v dataset.
m.omega


% Now look at the metadata for the Longitude dimension.
m.omega.lon


% Now look at the metadata for the Latitude dimension.
m.omega.lat

% Now Retrieve Missing Values.
% Hit return to continue...
missing_value=m.omega.missing_value;

%
% And finally, retrieve the data by making a constraint.
% Image is 721x1080 we grab the first level first time.
%
constraint = [url '?omega[1:1][1:1]']

%
%% And load the actual data by dropping the '-A' switch to loaddap.
d = loaddap ( constraint );
d.omega;


pcolor ( d.omega.lon, d.omega.lat, d.omega.omega );
shading flat;
colorbar;
drawnow;
%%
%% Let''s try again and scale the data this time.
pause;
delete(gcf);
%
% Round data to match missing_value.
%
omega = round(d.omega.omega/(missing_value/10))*(missing_value/10);
ind = find(omega==missing_value);
%
% Get back original data and mask select values between -0.1 and 0.1
%
omega = d.omega.omega;
omega(ind) = NaN;
ind = find((omega > .1) | (omega < -.1));
omega(ind) = NaN;

pcolor ( d.omega.lon, d.omega.lat, omega) 
shading flat;
colorbar;
