Newer
Older
function plot_map(hTsgGUI, hPlotAxes)
% Function to plot the earth map and ship trackline
%
% Input
% -----
% hTsgGUI ............ Handel to the main user interface
% hPlotAxes .......... Handels to the graphic axes
%
% Output
% ------
%
% TODOS
%
% note that a decimal degree notation is used, so that a longitude of
gael.alory_legos.obs-mip.fr
committed
% 120?30'W is specified as -120.5
Yves Gouriou
committed
%
gael.alory_legos.obs-mip.fr
committed
% Does M_MAP use 0-360? or -180? +180? covention ?
%
% $Id$
% Retrieve named application data
% -------------------------------
tsg = getappdata( hTsgGUI, 'tsg_data');
% Get the Geographic limit of the TSG time series
% -----------------------------------------------
dateLim = get(hPlotAxes(1), 'Xlim');
ind = find( tsg.DAYD >= dateLim(1) & tsg.DAYD <= dateLim(2));

jacques.grelet_ird.fr
committed
% m_grid need the use of double instead single
% --------------------------------------------
latx = double(tsg.LATX);
lonx = double(tsg.LONX);

jacques.grelet_ird.fr
committed
latMin = min(latx(ind) );
if latMin < -90
latMin = -90;
end

jacques.grelet_ird.fr
committed
latMax = max( latx(ind) );
if latMax > 90
latMax = 90;
end

jacques.grelet_ird.fr
committed
lonMin = min( lonx(ind) );
lonMax = max( lonx(ind) );
% Oversize window due to the large frame
%--------------------------------------
latRange = (latMax-latMin);

jacques.grelet_ird.fr
committed
latMin = max(floor(latMin), -90);
latMax = min(ceil(latMax), 90);
lonRange = (lonMax-lonMin);

jacques.grelet_ird.fr
committed
lonMin = floor(lonMin);
lonMax = ceil(lonMax);
lonRange = (lonMax-lonMin);
if lonRange>=360
lonMin = -183.6; %to account for fancy frame
lonMax = 183.6;
tsg.lonplus = 180;
tsg.lonmod = 360;
tsg.lonplus = 0;
tsg.lonmod = 0;
% Positionning the right axes (set map current axe)
% -------------------------------------------------
% Use of Mercator projection
% --------------------------
m_proj('Mercator','lat',[latMin latMax],'long',[lonMin lonMax]);
switch tsg.preference.map_resolution
case 1
% Low-resolution coast lines
% --------------------------
m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');
Yves Gouriou
committed
case 2
% Medium-resolution coast lines
% -----------------------------
m_gshhs_l('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');
case 3

jacques.grelet_ird.fr
committed
% Intermediate-resolution coast lines
% ----------------------------
m_gshhs_i('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');

jacques.grelet_ird.fr
committed
case 4
% High-resolution coast lines
% ----------------------------
m_gshhs_h('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');
otherwise
tsg.preference.map_resolution = 1;
% Low-resolution coast lines
% --------------------------
m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');
Yves Gouriou
committed
% Make a grid on the map with fancy box
% -------------------------------------
m_grid('box', 'fancy', 'tickdir', 'in', 'TAG', 'TAG_PLOT4_LINE_GRID', ...
'Fontsize', tsg.fontSize);
% Plot the ship track - Check if LAT-LON in deg-decimal
% -----------------------------------------------------

jacques.grelet_ird.fr
committed
%m_line(lonx, latx, 'TAG', 'TAG_PLOT4_LINE_SHIPTRACK', 'marker','.','markersize',3,'color','b');
% m_line(lonx, latx, 'LineStyle', 'none', 'marker','*','markersize',2,'color','b');
% Plot using QC
% -------------
% Get list of keys from hashtable tsg.qc.hash, defined inside
% tsg_initialisation.m
% -----------------------------------------------------------

jacques.grelet_ird.fr
committed
qc_list = keys(tsg.qc.hash);
% Plot Sample/TSG differences on axe 2
% iterate (loop) on each key store inside hastable
% Iterate from the end of the cell array : fliplr
% ------------------------------------------------
for key = fliplr( qc_list )

jacques.grelet_ird.fr
committed
% get some values in hashtable
% -----------------------------
%qcState = tsg.qc.hash.(key).state;

jacques.grelet_ird.fr
committed
qcCode = tsg.qc.hash.(key).code;
qcColor = tsg.qc.hash.(key).color;
% plot tsg salinity sample with right code/color
% ----------------------------------------------
ind = find( tsg.SSPS_QC == qcCode & isnan(tsg.SSPS) == 0);
% Create line on the map
% ----------------------

jacques.grelet_ird.fr
committed
m_line( mod(lonx(ind) + tsg.lonplus, tsg.lonmod) - tsg.lonplus,...
latx(ind), 'LineStyle', 'none', 'marker','*',...
'markersize', 2, 'color', qcColor);
% Write title
% -----------
title( ['Cruise: ' tsg.file.name], 'fontsize',tsg.fontSize +2, ...
'fontweight', 'bold','interpreter','none');
% Set tag for each line
% ---------------------
hLines = get(hPlotAxes(4), 'Children');
for i=1:length(hLines)
set(hLines(i), 'Tag', ['TAG_PLOT4_LINE_MAP' int2str(i)]);
end
% Save tsg structure
% ------------------
setappdata( hTsgGUI, 'tsg_data', tsg);