Skip to content
Snippets Groups Projects
tsgqc_GUI.m 37.8 KiB
Newer Older
          mean_psal(i) = tsg.levitus.data.WOA01_MEAN_PSAL(ilat,ilon,1);
          std_temp(i)  = tsg.levitus.data.WOA01_STD_TEMP(ilat,ilon,1);
          std_psal(i)  = tsg.levitus.data.WOA01_STD_PSAL(ilat,ilon,1);

        % Plot mean salinity climatology
        hLine1.meanClim = line( ...
          time, mean_psal,'Linestyle', '-', 'Color','k');
        % Plot 2 standard deviation
        hLine1.stdClimPlus = line( ...
          time,  mean_psal + 3 * std_psal ,'Linestyle', '-', 'Color','r');
        hLine1.stdClimMinus = line( ...
          time,  mean_psal - 3 * std_psal ,'Linestyle', '-', 'Color','r');
        % Plot mean temperature climatology
        axes( hPlotAxes(2));
        hLine2.meanClim = line( ...
          time, mean_temp,'Linestyle', '-', 'Color','k');
        hLine2.stdClimPlus = line( ...
          time,  mean_temp + 3 * std_temp ,'Linestyle', '-', 'Color','r');
        hLine2.stdClimMinus = line( ...
          time,  mean_temp - 3 * std_temp ,'Linestyle', '-', 'Color','r');

        % Store the handle of the bucketline
        % ----------------------------------
        set( hPlotAxes(1), 'UserData', hLine1 );
        set( hPlotAxes(2), 'UserData', hLine2 );
      end

    else

      set( hClimPushtool, 'UserData', 'off' );

      % The bucket pushbutton has been pressed again :
      % Delete the bucket on figure
      % ----------------------------------------------
      hLine1 = get( hPlotAxes(1), 'UserData');
      hLine2 = get( hPlotAxes(2), 'UserData');
      % bug......
      try
        delete(hLine1.stdClimMinus);
        delete(hLine1.stdClimPlus);
        delete(hLine1.meanClim);
        delete(hLine2.stdClimMinus);
        delete(hLine2.stdClimPlus);
        delete(hLine2.meanClim);
      catch
      end
% -------------------------------------------------------------------
  function HeaderMenuCallback(hObject, eventdata)
    % Callback function run when the headerForm tool bar item is selected

    % call header form function
    % -------------------------
    headerForm(hMainFig);
  end

% -------------------------------------------------------------------
  function SaveMenuCallback(hObject, eventdata)
    % Callback function run when the Save menu item is selected
    
    % Retrieve named application data
    % -------------------------------
    tsg = getappdata( hMainFig, 'tsg_data');

    % get fileName without extension in cell
    % --------------------------------------
    file = textscan( tsg.file.name,'%s','delimiter','.');

    % fill or append header form
    % -------------------------
    error = headerForm(hMainFig);

    % if user press continue button, ask for netcdf file
    % ------------------------------------------------
    if error ~= -1
      [fileName, pathName, filterIndex] = uiputfile('*.nc', ...

      % if user press cancel button, all var set to zero
      % ------------------------------------------------
      if fileName == 0
        return;
      end

      % Pointer set to watch during reading and plotting
      % ------------------------------------------------
      set( hMainFig, 'Pointer', 'watch' );

      % flushes the event queue and updates the closed uiputfile window
      % ---------------------------------------------------------------
      drawnow;

      % write netcdf file
      % -----------------
      error = writeTSGDataNetCDF( hMainFig, [pathName fileName] );

      % Pointer reset to arrow
      % ----------------------
      set( hMainFig, 'Pointer', 'arrow' );

      % Check for a writing pb to NetCDF
      % must to be rewriting
      % --------------------------------
      if error == -1
        warning(['NetCDF writing error:'  [pathName fileName]]);
      
      % update the display
      % ------------------
      set( hInfoFileText, 'String', fileName);
      
      % enable Quality Control mode
      % ---------------------------
      hdl_pushtool = findobj('Tag', 'QC');
      set(hdl_pushtool, 'Enable', 'on');
% -----------------------------------------------------------------
  function QuitMenuCallback(hObject, eventdata)
    % Callback function run when the Quit menu item is selected

    % If the data have been modified and not save, the program
    % propose to save the data
    % --------------------------------------------------------
    if  strcmp( get( hSaveMenu, 'UserData' ), 'on')
      selection = ...
        questdlg('The file has been modified.  Do you want to save it ?',...
        'Save before Quit?',...
        'Yes', 'No', 'Yes');
      if strcmp(selection, 'Yes')
        return;
      else
        QuitProgram;
      end
    else
      selection = ...
        questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
        ['Quit ' get(hMainFig, 'Name') '?'],...
        'Yes', 'No', 'Yes');
      if strcmp(selection, 'No')
        return;
      else
        QuitProgram;
      end

  end

% ----------------------------------------------------------------
  function QuitProgram(hObject, eventdata)

    delete(hMainFig);
    % reset Matlab search path to default
    rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] );
    rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] );
    rmpath( [DEFAULT_PATH_FILE filesep 'tsg_io'] );