MATLAB Examples

argodata documentation

The argodata function downloads Argo profile data and imports it into your Matlab workspace for easy workin' with.

Contents

Syntax

[lat,lon,t,P,T,S,pn] = argodata(ncfiles)
[lat,lon,t,P,T,S,pn] = argodata(ncfiles,'keep')

Description

[lat,lon,t,P,T,S,pn] = argodata(ncfiles) downloads data from urls listed in the cell array ncfiles (generated by the argofiles function). If the data exist locally on your machine, ncfiles may be a cell array list of local filenames. Function outputs lat, lon, t, and pn are geo coordinates, times in datenum format, and platform numbers pn. P, T, and S are cell arrays of pressure, temperature, and salinity.

[lat,lon,t,P,T,S,pn] = argodata(ncfiles,'keep') prevents automatic deletion of .nc files. Select the 'keep' option if you want to access the raw NetCDF data or keep the files for later.

Example: All profiles in the Nino 3.4 box in December 2009

To plot all Argo data within the Nino 3.4 box collected in May 2009 start by using the argofiles function to get urls of the data files:

latlim = [-5 5];
lonlim = [-170 -120];
t = [datenum('may 1, 2009') datenum('may 31, 2009')];
f = argofiles(latlim,lonlim,t,'pacific');

With a list of NetCDF file urls obtained above, use argodata to download the data and import get measurements into the Matlab workspace. Give it a minute to download all the data:

[lat,lon,t,P,T,S,pn] = argodata(f);

Where are the profiles located? Here's where:

plot(lon,lat,'ko','markerfacecolor','y')
xlabel 'longitude'
ylabel 'latitude'

What do the profiles look like? Here are the profiles of all the data. There are two ways we can plot all the profiles and I'm showing both ways below. First, I plot a temperature profile by looping through all 172 Argo profiles in the dataset. For salinity, instead of looping I concatenate all the data using cell2mat and plot all data simultaneously:

figure
subplot(121)
hold on
for k = 1:length(lat)
    plot(T{k},P{k},'.')
end
axis ij; box off
ylabel 'pressure (dbar) '
xlabel 'temperature (\circC)'
axis([0 30 0 2000])

subplot(122)
plot(cell2mat(S(:)),cell2mat(P(:)),'.')
axis ij; box off
axis([34.2 36.5 0 2000])
xlabel 'salinity (psu)'

Or we can look at this data as a T-S diagram with pressure as the color variable:

figure
scatter(cell2mat(S(:)),cell2mat(T(:)),30,cell2mat(P(:)),'filled')

xlabel 'salinity'
ylabel 'temperature'
cb = colorbar;
ylabel(cb,' pressure ')
set(cb,'ydir','reverse')

Author Info:

The argodata function was written by Chad A. Greene of the University of Texas at Austin's Institute for Geophysics (UTIG), December 2015.