Skip to content
Snippets Groups Projects
plot_Sample.m 4.34 KiB
Newer Older
function plot_Sample( hTsgGUI, hAxes, PlotNum, Para, MyColor )
% Function to plot Para sample on axes hAxe
% The program can plot parameter of style SSPS or SSPS_DIF
% in that last case we need to extract the name of the parameter
%
% Input
% -----
% hTsgGUI ........ Handel to the user interface
% hPlotAxes ...... Handels to the graphic axes
% PlotNum ........ Plot Number (used for the TAG)
% Para ........... Parametre whose difference with TSG data is plot
% MyColor ........ []        - Draw Para taking into account color QC code
%                  'k''b'... - Draw Para using Color code 

% Retrieve named application data
% -------------------------------
sample    = getappdata( hTsgGUI, 'sample');
tsg       = getappdata( hTsgGUI, 'tsg_data');

axes( hAxes(PlotNum) );
set( hAxes(PlotNum), 'Box', 'on' );
% Extract the name of the parameter (if SSPS_DIF is the argument)
% ---------------------------------------------------------------
pos = regexp( Para, '_', 'ONCE');
if isempty( pos )
  parameter = Para;
else
  parameter = Para(1:pos-1);
end

if isempty(MyColor)
  % get list of keys from hashtable tsg.qc.hash, defined inside
  % tsg_initialisation.m
  % -----------------------------------------------------------
  qc_list = get(tsg.qc.hash);

  % Plot Sample/TSG differences on axe 2
  % iterate (loop) on each key store inside hastable
  % ------------------------------------------------
  for i=1:numel(qc_list)

    % get key and some values in hashtable
    % ------------------------------------
    key   = qc_list{i};
    state = get(tsg.qc.hash, key, 'state');
    code  = get(tsg.qc.hash, key, 'code');
    color = get(tsg.qc.hash, key, 'color');

    % plot only for valid context menu (set to 'on')
    % ----------------------------------------------
    if strcmp( state, 'on')

Yves Gouriou's avatar
Yves Gouriou committed
      % test if structure sample exist and member is valid
      % --------------------------------------------------
      if isfield(sample, [parameter '_QC'])
        
Yves Gouriou's avatar
Yves Gouriou committed
        % PLOT DATA OF TYPE 1 (Water Sample)
        % Find corresponding code <=> values
Yves Gouriou's avatar
Yves Gouriou committed
        ind = find( sample.([parameter '_QC']) == code & ...
                    sample.([parameter '_TYPE'])  <= 1);
        % plot tsg salinity sample with right code/color
        % ----------------------------------------------
        if ~isempty( ind )
          line( sample.DAYD(ind), sample.(Para)(ind), ...
Yves Gouriou's avatar
Yves Gouriou committed
            'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para '_' key '_1'],...
Yves Gouriou's avatar
Yves Gouriou committed
            'Marker', 'square', 'MarkerSize', 6,...
            'MarkerEdgeColor', color, 'MarkerFaceColor', 'w');
Yves Gouriou's avatar
Yves Gouriou committed

        % PLOT DATA OF TYPE 2 and Gretar (External Sample)
        % Find corresponding code <=> values
        % -----------------------------------------------
        ind = find( sample.([parameter '_QC']) == code & ...
                    sample.([parameter '_TYPE'])  >  1);
        
        % plot tsg salinity sample with right code/color
        % ----------------------------------------------
        if ~isempty( ind )
          line( sample.DAYD(ind), sample.(Para)(ind), ...
            'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para '_' key '_2'],...
            'LineStyle', 'none',...
            'Marker', 'o', 'MarkerSize', 6,...
            'MarkerEdgeColor', color, 'MarkerFaceColor', 'w');
  % Plot Parameter with MyColor specifies in the function arguments 
  % ---------------------------------------------------------------
Yves Gouriou's avatar
Yves Gouriou committed
  if ~isempty( sample.([(Para) '_TYPE'])  <= 1 )
    line( sample.DAYD, sample.(Para),...
      'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para '_1'],...
      'LineStyle', 'none', 'Marker', 'square', 'MarkerSize', 6,...
      'MarkerEdgeColor', MyColor, 'MarkerFaceColor', MyColor);
  end
  
  if ~isempty( sample.([(Para) '_TYPE']) > 1 )
    line( sample.DAYD, sample.(Para),...
      'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para '_1'],...
      'LineStyle', 'none', 'Marker', 'o', 'MarkerSize', 6,...
      'MarkerEdgeColor', MyColor, 'MarkerFaceColor', MyColor);
  end


% Write some 'Y' label
% ------------------
set(get(hAxes(PlotNum), 'Ylabel'), 'Interpreter', 'none', 'String', Para);