From d6aca9fd28de68b45ebb2dd3c2a72d6fb34a5458 Mon Sep 17 00:00:00 2001 From: Jacques Grelet <jacques.grelet@ird.fr> Date: Tue, 8 Jan 2008 15:34:21 +0000 Subject: [PATCH] supprime les fichiers --- tsg_util/readBucketData.m | 70 --------- tsg_util/readTsgDataNetCDF.m | 187 ------------------------ tsg_util/readTsgDataTxt.m | 105 -------------- tsg_util/readTsgDataXML.m | 58 -------- tsg_util/read_file_woa01.m | 60 -------- tsg_util/tsg_header.m | 227 ------------------------------ tsg_util/tsg_plot_SalTempVel.m | 73 ---------- tsg_util/tsg_plot_SalTsgSample.m | 106 -------------- tsg_util/tsg_plotmap.m | 49 ------- tsg_util/tsg_readBucketData.m | 55 -------- tsg_util/tsg_readTsgDataNetCDF.m | 187 ------------------------ tsg_util/tsg_readTsgDataTxt.m | 105 -------------- tsg_util/tsg_readTsgDataXML.m | 58 -------- tsg_util/tsg_writeTSGDataNetCDF.m | 147 ------------------- tsg_util/tsg_writeTsgData.m | 55 -------- tsg_util/writeTSGDataNetCDF.m | 147 ------------------- tsg_util/writeTsgData.m | 55 -------- 17 files changed, 1744 deletions(-) delete mode 100644 tsg_util/readBucketData.m delete mode 100644 tsg_util/readTsgDataNetCDF.m delete mode 100644 tsg_util/readTsgDataTxt.m delete mode 100644 tsg_util/readTsgDataXML.m delete mode 100644 tsg_util/read_file_woa01.m delete mode 100644 tsg_util/tsg_header.m delete mode 100644 tsg_util/tsg_plot_SalTempVel.m delete mode 100644 tsg_util/tsg_plot_SalTsgSample.m delete mode 100644 tsg_util/tsg_plotmap.m delete mode 100644 tsg_util/tsg_readBucketData.m delete mode 100644 tsg_util/tsg_readTsgDataNetCDF.m delete mode 100644 tsg_util/tsg_readTsgDataTxt.m delete mode 100644 tsg_util/tsg_readTsgDataXML.m delete mode 100644 tsg_util/tsg_writeTSGDataNetCDF.m delete mode 100644 tsg_util/tsg_writeTsgData.m delete mode 100644 tsg_util/writeTSGDataNetCDF.m delete mode 100644 tsg_util/writeTsgData.m diff --git a/tsg_util/readBucketData.m b/tsg_util/readBucketData.m deleted file mode 100644 index d509107..0000000 --- a/tsg_util/readBucketData.m +++ /dev/null @@ -1,70 +0,0 @@ -function [error] = readBucketData( hTsgGUI, filename) -% Function to read Bucket data in ASCII format. -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% @The data are store using setappdata - Variable name : 'bucketASCII' -% -% Caution : replace the fill-value with NaN -% $Id$ - -% Open the file -% ------------- -fid = fopen( filename, 'r' ); - -error = -1; -if fid ~= -1 - - % Get the tsg structure from application GUI - % ------------------------------------------ - tsg = getappdata( hTsgGUI, 'tsg_data'); - - % Read the file - skip 2 lines - % ---------------------------- - fgetl( fid ); fgetl( fid ); - bucketData = fscanf(fid,'%d %d %d %d %d %d %f %f %f', [9 Inf])'; - - % Every variable are put in a structure - % ------------------------------------- - tsg.DAYD_WS = datenum(bucketData(:,1), bucketData(:,2), ... - bucketData(:,3), bucketData(:,4), ... - bucketData(:,5), bucketData(:,6)); - - % save original date - % ------------------ - tsg.DATE_WS = datestr( tsg.DAYD_WS, 'yyyymmddHHMMSS' ); - - tsg.LATX_WS = bucketData(:,7); - tsg.LONX_WS = bucketData(:,8); - tsg.SSPS_WS = bucketData(:,9); - tsg.SSPS_WS_QC = zeros(size(tsg.SSPS_WS)); - - %@ completer ces 2 champs !!!!!!!! - %tsg.PSAL_WS_ANALDATE = ; - %tsg.PSAL_WS_BOTTLE = ; - % remplace pour l'instant sample.TYPE !!!!!! - %tsg.SSPS_WS_TYPE = ones(size(tsg.SSPS_WS)); - - % Save the data in the application GUI - % ------------------------------------ - setappdata( hTsgGUI, 'tsg_data', tsg ); - - % Clear the Workspace - % ------------------- - clear bucketData - - % Close the file - % -------------- - fclose( fid ); - - % Everything OK - % ------------- - error = 1; -end diff --git a/tsg_util/readTsgDataNetCDF.m b/tsg_util/readTsgDataNetCDF.m deleted file mode 100644 index 475fbdc..0000000 --- a/tsg_util/readTsgDataNetCDF.m +++ /dev/null @@ -1,187 +0,0 @@ -function [error] = readTsgDataNetCDF( hTsgGUI, filename) -% Function to read the TSG data. Should be a NetCDF file -% GOSUD data format TSG V1.4 -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% $Id$ - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Display read file info on console -% --------------------------------- -fprintf('\nREAD_NETCDF_FILE\n'); tic; - -% Open netCDF file -% ---------------- -nc = netcdf(filename,'read'); -if isempty(nc) - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; - warndlg( msg_error, 'NetCDF error dialog'); - sprintf('...cannot locate %s\n', filename); - error = -1; - return; -end - -% Display more info about read file on console -% -------------------------------------------- -fprintf('...reading %s : ', filename); - -% Read global attributes: meta data -% ---------------------------------- - -tsg.PLATFORM_NAME = nc.PLATFORM_NAME(:); -tsg.SHIP_CALL_SIGN = nc.SHIP_CALL_SIGN(:); -tsg.SHIP_MMSI = nc.SHIP_MMSI(:); -tsg.TSG_TYPE = nc.TSG_TYPE(:); -tsg.TSG_NUMBER = nc.TSG_NUMBER(:); -tsg.TINT_TYPE = nc.TINT_TYPE(:); -tsg.TINT_NUMBER = nc.TINT_NUMBER(:); -tsg.DATA_TYPE = nc.DATA_TYPE(:); -tsg.DATA_MODE = nc.DATA_MODE(:); -tsg.SAMPLING_PERIOD = nc.SAMPLING_PERIOD(:); -tsg.PROCESSING_STATUS = nc.PROCESSING_STATUS(:); -tsg.DATE_START = nc.DATE_START(:); -tsg.DATE_END = nc.DATE_END(:); -tsg.SOUTH_LATX = nc.SOUTH_LATX(:); -tsg.NORTH_LATX = nc.NORTH_LATX(:); -tsg.WEST_LONX = nc.WEST_LONX(:); -tsg.EAST_LONX = nc.EAST_LONX(:); -tsg.FORMAT_VERSION = nc.FORMAT_VERSION(:); -tsg.DATE_CREATION = nc.DATE_CREATION(:); -tsg.DATE_UPDATE = nc.DATE_UPDATE(:); -tsg.DATA_RESTRICTIONS = nc.DATA_RESTRICTIONS(:); -tsg.CITATION = nc.CITATION(:); -tsg.COMMENT = nc.COMMENT(:); -tsg.PROJECT_NAME = nc.PROJECT_NAME(:); -tsg.PI_NAME = nc.PI_NAME(:); -tsg.DATA_CENTRE = nc.DATA_CENTRE(:); -tsg.DATA_ACQUISITION = nc.DATA_ACQUISITION(:); -tsg.PROCESSING_CENTRE = nc.PROCESSING_CENTRE(:); -tsg.PROCESSING_STATE = nc.PROCESSING_STATE(:); - -% read variables describing TSG installation -% ------------------------------------------ - -tsg.SSJT_DEPH = nc{'SSJT_DEPH'}(:); -tsg.SSJT_DEPH_MIN = nc{'SSJT_DEPH_MIN'}(:); -tsg.SSJT_DEPH_MAX = nc{'SSJT_DEPH_MAX'}(:); -tsg.CNDC_CALCOEF = nc{'CNDC_CALCOEF'}(:); -tsg.CNDC_LINCOEF = nc{'CNDC_LINCOEF'}(:); -tsg.SSJT_CALCOEF = nc{'SSJT_CALCOEF'}(:); -tsg.SSJT_LINCOEF = nc{'SSJT_LINCOEF'}(:); - -% read variables describing Temperature sensor at intake (TINT) installation -% -------------------------------------------------------------------------- - -tsg.SSTP_DEPH = nc{'SSTP_DEPH'}(:); -tsg.SSTP_DEPH_MIN = nc{'SSTP_DEPH_MIN'}(:); -tsg.SSTP_DEPH_MAX = nc{'SSTP_DEPH_MAX'}(:); -tsg.SSTP_CALCOEF = nc{'SSTP_CALCOEF'}(:); -tsg.SSTP_LINCOEF = nc{'SSTP_LINCOEF'}(:); - -% Coordinates -%------------ - -tsg.DATE = nc{'DATE'}(:,:); -tsg.DAYD = nc{'DAYD'}(:); -tsg.LATX = nc{'LATX'}(:); -tsg.LONX = nc{'LONX'}(:); -tsg.POSITION_QC = nc{'POSITION_QC'}(:); -tsg.SPDC = nc{'SPDC'}(:); -tsg.REFERENCE_DATE_TIME = nc{'REFERENCE_DATE_TIME'}(:); - -% Convert julian day with origin 1950 to Matlab datenum in memory -% --------------------------------------------------------------- -tsg.DAYD = julianToDatenum( tsg.DAYD ); - -% Variables holding data from the main TSG -% data series 1 -%----------------------------------------- - -% measured variables -%----------------------------------------- -%if isempty(tsg.PRES) - tsg.PRES = nc{'PRES'}(:); -%end - -%if isempty(tsg.SSJT) - tsg.SSJT = nc{'SSJT'}(:); - tsg.SSJT_STD = nc{'SSJT_STD'}(:); - tsg.SSJT_STD_CAL = nc{'TEMP_STD_CAL'}(:); -%end - -%if isempty(tsg.CNDC) - tsg.CNDC = nc{'CNDC'}(:); - tsg.CNDC_STD = nc{'CNDC_STD'}(:); - tsg.CNDC_CAL = nc{'CNDC_CAL'}(:); -%end - -% intake temperature variable -%----------------------------------------- -tsg.SSTP = nc{'SSTP'}(:); -tsg.SSTP_QC = nc{'SSTP_QC'}(:); -tsg.SSTP_CAL = nc{'SSTP_CAL'}(:); -tsg.SSTP_ADJUSTED = nc{'SSTP_ADJUSTED'}(:); -tsg.SSTP_ADJUSTED_ERROR = nc{'SSTP_ADJUSTED_ERROR'}(:); -tsg.SSTP_ADJUSTED_QC = nc{'SSTP_ADJUSTED_QC'}(:); -tsg.SSTP_ADJUSTED_HIST = nc{'HIST_SSTP_ADJUSTED'}(:); - -% derived variables -%----------------------------------------- -tsg.SSPS = nc{'SSPS'}(:); -tsg.SSPS_QC = nc{'SSPS_QC'}(:); -tsg.SSPS_CAL = nc{'SSPS_CAL'}(:); -tsg.SSPS_ADJUSTED = nc{'SSPS_ADJUSTED'}(:); -tsg.SSPS_ADJUSTED_ERROR = nc{'SSPS_ADJUSTED_ERROR'}(:); -tsg.SSPS_ADJUSTED_QC = nc{'SSPS_ADJUSTED_QC'}(:); -tsg.SSPS_ADJUSTED_HIST = nc{'HIST_SSPS_ADJUSTED'}(:); - -% data series 2 -%----------------------------------------- - -% water samples -%----------------------------------------- -tsg.DATE_WS = nc{'DATE_WS'}(:,:); -tsg.DAYD_WS = julianToDatenum(nc{'DAYD_WS'}(:)); -tsg.LATX_WS = nc{'LATX_WS'}(:); -tsg.LONX_WS = nc{'LONX_WS'}(:); -tsg.SSPS_WS = nc{'SSPS_WS'}(:); -tsg.SSPS_WS_QC = nc{'SSPS_WS_QC'}(:); -tsg.SSPS_WS_ANALDATE = nc{'SSPS_WS_ANALDATE'}(:,:); -tsg.SSPS_WS_BOTTLE = nc{'SSPS_WS_BOTTLE'}(:,:); - - -% Save the data in the application GUI -% ------------------------------------ -setappdata( hTsgGUI, 'tsg_data', tsg ); - -% Clear the Workspace -% ------------------- -clear tsgdata - -% Close the file -% -------------- -%endef(nc) -close(nc); - -% Display time to read file on console -% ------------------------------------ -t = toc; fprintf('...done (%6.2f sec).\n\n',t); - -% Everything OK -% ------------- -error = 1; - -end diff --git a/tsg_util/readTsgDataTxt.m b/tsg_util/readTsgDataTxt.m deleted file mode 100644 index f57c38c..0000000 --- a/tsg_util/readTsgDataTxt.m +++ /dev/null @@ -1,105 +0,0 @@ -function [error] = readTsgDataTxt( hTsgGUI, filename) -% Function to read the TSG data. Should be a NetCDF file -% -% Input -% ----- -% hTsgGUI ............ Handle to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% -% Caution : replace the fill-value with NaN -% $Id$ - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Display read file info on console -% --------------------------------- -fprintf('\nREAD_ASCII_FILE\n'); tic; - -% Open the file -% ------------- -fid = fopen( filename, 'r' ); - -% Check file -% ----------- -if fid == -1 - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; - warndlg( msg_error, 'ASCII error dialog'); - sprintf('...cannot locate %s\n', filename); - error = -1; - return; -end - -% Display more info about read file on console -% -------------------------------------------- -fprintf('...reading %s : ', filename); - -% Read the file -% ------------- -tsgData = fscanf(fid, '%d/%d/%d %d:%d:%d %f %f %f %f %d %f %f', ... - [13 Inf])'; - -% Every variable are put in a structure -% ------------------------------------- -tsg.DAYD = datenum(tsgData(:,3), tsgData(:,2),tsgData(:,1), ... - tsgData(:,4),tsgData(:,5),tsgData(:,6)); - -% save original date -% ------------------ -tsg.DATE = datestr( tsg.DAYD, 'yyyymmddHHMMSS' ); - -% convert with julian day with origin 1950 -% ----------------------------------------- -%% a supprimer !!!!!!! -% tsg.TIME_TSG = datenumToJulian(tsg.TIME_TSG); - -tsg.LATX = tsgData(:,7); -tsg.LONX = tsgData(:,8); -tsg.SSJT = tsgData(:,9); -tsg.SSPS = tsgData(:,10); -tsg.SSPS_QC = tsgData(:,11); -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -tsg.SSPS_ADJ = tsgData(:,12); -tsg.SSPS_ERR = tsgData(:,13); - -% Compute ship velocity from positions if sog not available -% --------------------------------------------------------- -if isempty(tsg.SPDC) - range = m_lldist(tsg.LONX,tsg.LATX); - ind = size(tsg.DAYD); - tsg.SPDC = zeros(size(ind)); - for i=1:length(tsg.DAYD)-1 - tsg.SPDC(i) = range(i) / ((tsg.DAYD(i+1)-tsg.DAYD(i)) * 24 * 1.854); - end - tsg.SPDC = [tsg.SPDC';0]; -end - - -% Save the data in the application GUI -% ------------------------------------ -setappdata( hTsgGUI, 'tsg_data', tsg ); - -% Clear the Workspace -% ------------------- -clear tsgdata - -% Close the file -% -------------- -fclose( fid ); - -% Display time to read file on console -% ------------------------------------ -t = toc; fprintf('...done (%6.2f sec).\n\n',t); - -% Everything OK -% ------------- -error = 1; diff --git a/tsg_util/readTsgDataXML.m b/tsg_util/readTsgDataXML.m deleted file mode 100644 index 8f2b79d..0000000 --- a/tsg_util/readTsgDataXML.m +++ /dev/null @@ -1,58 +0,0 @@ -function [error] = readTsgDataXML( hTsgGUI, filename) -% Function to read the TSG data XML file -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% Function not yet implemented -% Caution : replace the fill-value with NaN -% $Id$ - -% Open the file -% ------------- -fid = fopen( filename, 'r' ); - -error = -1; -if fid ~= -1 - disp('Read XML file, not yet implemeted ...'); -% % Read the file -% % ------------- -% tsgData = fscanf(fid, '%d/%d/%d %d:%d:%d %f %f %f %f %d %f %f', ... -% [13 Inf])'; -% -% % Every variable are put in a structure -% % ------------------------------------- -% tsg.TIME = datenum(tsgData(:,3), tsgData(:,2),tsgData(:,1), ... -% tsgData(:,4),tsgData(:,5),tsgData(:,6)); -% tsg.LATITUDE = tsgData(:,7); -% tsg.LONGITUDE = tsgData(:,8); -% tsg.TEMP_TSG = tsgData(:,9); -% tsg.PSAL = tsgData(:,10); -% tsg.PSAL_QC = tsgData(:,11); -% tsg.PSAL_ADJ = tsgData(:,12); -% tsg.PSAL_ERR = tsgData(:,13); -% -% % Save the data in the application GUI -% % ------------------------------------ -% setappdata( hTsgGUI, 'tsg_data', tsg ); - - % Clear the Workspace - % ------------------- - clear tsgdata - - % Close the file - % -------------- - fclose( fid ); - - % Everything is not OK - % ------------- - error = -1; -end diff --git a/tsg_util/read_file_woa01.m b/tsg_util/read_file_woa01.m deleted file mode 100644 index aeaa694..0000000 --- a/tsg_util/read_file_woa01.m +++ /dev/null @@ -1,60 +0,0 @@ -function levitus = read_file_woa01(file) -% a mettre dans la classe de base oceano puisque commun a tous -% -% read WOA01 Levitus T-S-O2, Stddev & nb_obs Netcdf file in memory - -% $Id$ - -filesfound = checkforfiles( file ); -if filesfound == 0; - warning(['Couldn''t find ', file]); - levitus = -1; - return; -end - -% a commenter en production -% t = cputime; - -% il existe un "bug" dans netcdf ligne 409, ncitem retourne une -% erreur dans la variable result -nc = netcdf(which(file),'nowrite'); - -%recupere les variables et les mets de le workspace -variables = var(nc); - -% list les variables du fichier et sort -% if strcmp( variable, 'list' ) -% disp(char(ncnames(var(nc)))); -% return -% end - -% Initialise la waitbar de chargement du fichier netCDF -wb = waitbar(0,['Loading file: ' file ' Please wait...']); - -for i = 1:length(variables) - value = variables{i}(:); - % je n'ai pas reussi a utiliser autonan avec l'attribue FillValue_ - value(value == fillval(variables{i})) = NaN; - % Assign dynamiquely variable in struct levitus. - levitus.(name(variables{i})) = value; - % set(wb, 'Title', name(variables{i})); - waitbar( i/length(variables), wb); -end - -close(wb); -close(nc); - -% a commenter en production -% e = cputime-t -% -% builtin( 'set', findobj( 'Tag', 'main' ), 'UserData', self ); - -%---------------------------------------------------------------------- -%---------------------------------------------------------------------- -function filesfound = checkforfiles( file ) - -if exist(file,'file'); - filesfound = 1; -else - filesfound = 0; -end diff --git a/tsg_util/tsg_header.m b/tsg_util/tsg_header.m deleted file mode 100644 index 26c3037..0000000 --- a/tsg_util/tsg_header.m +++ /dev/null @@ -1,227 +0,0 @@ -function error = tsg_header(hTsgGUI) -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% -% Output -% ------ -% error .............. 1: OK ; -1 : an error occured - -% $Id$ - -error = -1; - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Define uicontrol start position -% ------------------------------- -left = .01; -bottom = .95; -inc_x = 0.5; -inc_y = 0.03; - -% set default uicontrol size -% -------------------------- -default_height = 0.018; -default_length = .1; - - -% Get global attributes list from class tsg_nc with file 'tsg_ncattr.csv' -% ----------------------------------------------------------------------- -nca = tsg_nc('tsg_ncattr.csv'); -nca_keys = keys(nca); - - -% header Uicontrols in a new figure -% --------------------------------- -hHeaderFig = figure(... - 'BackingStore','off',... - 'Name', 'TSG GLOBAL ATTRIBUTES', ... - 'NumberTitle', 'off', ... - 'Resize', 'on', ... - 'Menubar','none', ... - 'Toolbar', 'none', ... - 'Tag', 'GLOBAL_ATTRIBUTES', ... - 'Visible','on',... - 'Units', 'normalized',... - 'Position',get(hTsgGUI,'Position'), ... - 'Color', get( 0, 'DefaultUIControlBackgroundColor' )); - -% bg = [0.92549 0.913725 0.847059] = get( 0, 'DefaultUIControlBackgroundColor' ); - -% Display fields from class -% ------------------------- -for i=1:numel(nca_keys) - % get key, use {} for cell - key = nca_keys{i}; - % get all structure for the key - s = get(nca, key); - - % check for empty field and replace them by default value - % ------------------------------------------------------- - if isempty(s.length), s.length = default_length; end; - if isempty(s.height), s.height = default_height; end; - - % display dynamic uicontrol text - % use of char function prevent error when field is empty [] => '' - % --------------------------------------------------------------- - uicontrol(... - 'Parent', hHeaderFig, ... - 'Units', 'normalized', ... - 'Style', 'Text', ... - 'HorizontalAlignment', 'left', ... - 'Position',[left, bottom, .8, .0135], ... - 'TooltipString', char(s.comment), ... - 'String', char(s.name) ); - - % display dynamic uicontrol - % ------------------------- - ui = uicontrol(... - 'Parent', hHeaderFig, ... - 'Units', 'normalized', ... - 'BackgroundColor', 'w', ... - 'Style', char(s.uicontrolType), ... - 'HorizontalAlignment', char(s.horizontalAlignment), ... - 'Position',[left+.09, bottom, s.length, s.height], ... - 'String', char(s.string), ... - 'Value', s.value, ... - 'Tag', key); - - % set dynamically uicontrol - % ------------------------- - switch s.uicontrolType - case 'popupmenu' - str = cellstr(get(ui,'String')); - ind = strfind(str,tsg.(key)); - for k=1:numel(ind) - if ~isempty(ind{k}) - set(ui, 'value', k); - end - end - case 'edit' - set(ui, 'string', tsg.(key)); - end - - % Check vertical position of last uicontrol and creation new colomn - % ----------------------------------------------------------------- - bottom = bottom - inc_y; - if bottom < .15 - bottom = 0.95; - left = left + inc_x; - end -end - - -% CONTINUE PUSH BUTTON -% -------------------- -% The Continue (valid) button -uicontrol( ... - 'Parent', hHeaderFig, ... - 'Style','pushbutton',... - 'Units', 'normalized', ... - 'Position',[.05, .1, .05, .02],... - 'String','Continue',... - 'Interruptible','off',... - 'BusyAction','cancel',... - 'Tag','PUSH_BUTTON',... - 'Callback', @continueCallback); - -% CANCEL PUSH BUTTON -% ------------------ -% The cancel button -uicontrol( ... - 'Parent', hHeaderFig, ... - 'Style','pushbutton',... - 'Units', 'normalized', ... - 'Position',[.15, .1, .05, .02],... - 'String','Cancel',... - 'Interruptible','off',... - 'BusyAction','cancel',... - 'Tag','PUSH_BUTTON',... - 'Callback', @cancelCallback); - -% Build structure container for graphic handles with tag property defined. -% ------------------------------------------------------------------------ -data = guihandles(hHeaderFig); - -% record data struct in application data object -% --------------------------------------------- -%guidata(hHeaderFig, data); - -% stop execution until push-button Continue was press -% --------------------------------------------------- -uiwait(hHeaderFig); - -%% Nested callback - function continueCallback(obj, event) - - % get uicontrol filelds and populate tsg structure - % ------------------------------------------------ - tsg.PLATFORM_NAME = get(data.PLATFORM_NAME, 'string'); - tsg.SHIP_CALL_SIGN = get(data.SHIP_CALL_SIGN, 'string'); - tsg.SHIP_MMSI = get(data.SHIP_MMSI, 'string'); - tsg.TSG_TYPE = get(data.TSG_TYPE, 'string'); - tsg.TSG_TYPE = tsg.TSG_TYPE(get(data.TSG_TYPE, 'value'),:); - tsg.TSG_NUMBER = get(data.TSG_NUMBER, 'string'); - tsg.TINT_TYPE = get(data.TINT_TYPE, 'string'); - tsg.TINT_TYPE = tsg.TINT_TYPE(get(data.TINT_TYPE, 'value'),:); - tsg.TINT_NUMBER = get(data.TINT_NUMBER, 'string'); - tsg.DATA_TYPE = get(data.DATA_TYPE, 'string'); - tsg.DATA_MODE = get(data.DATA_MODE, 'string'); - tsg.DATA_MODE = tsg.DATA_MODE(get(data.DATA_MODE, 'value'),:); - tsg.SAMPLING_PERIOD = get(data.SAMPLING_PERIOD, 'string'); - tsg.PROCESSING_STATUS = get(data.PROCESSING_STATUS, 'string'); - tsg.DATE_START = get(data.DATE_START, 'string'); - tsg.DATE_END = get(data.DATE_END, 'string'); - tsg.SOUTH_LATX = get(data.SOUTH_LATX, 'string'); - tsg.NORTH_LATX = get(data.NORTH_LATX, 'string'); - tsg.WEST_LONX = get(data.WEST_LONX, 'string'); - tsg.EAST_LONX = get(data.EAST_LONX, 'string'); - tsg.FORMAT_VERSION = get(data.FORMAT_VERSION, 'string'); - tsg.DATE_CREATION = get(data.DATE_CREATION, 'string'); - tsg.DATE_UPDATE = get(data.DATE_UPDATE, 'string'); - tsg.DATA_RESTRICTIONS = get(data.DATA_RESTRICTIONS, 'string'); - tsg.COMMENT = get(data.COMMENT, 'string'); - tsg.PROJECT_NAME = get(data.PROJECT_NAME, 'string'); - tsg.PI_NAME = get(data.PI_NAME, 'string'); - tsg.DATA_CENTRE = get(data.DATA_CENTRE, 'string'); - tsg.DATA_ACQUISITION = get(data.DATA_ACQUISITION, 'string'); - tsg.PROCESSING_CENTRE = get(data.PROCESSING_CENTRE, 'string'); - tsg.PROCESSING_STATES = get(data.PROCESSING_STATES, 'string'); - - % Save tsg structure - % ------------------ - setappdata( hTsgGUI, 'tsg_data', tsg); - - % close windows (replace call to uiresume(hHeaderFig)) - % ---------------------------------------------------- - close(hHeaderFig); - - % flushes the event queue and updates the figure window - % ----------------------------------------------------- - drawnow; - - % return no error code (true) - % --------------------------- - error = 1; - end - - function cancelCallback(obj, event) - - % close windows - % ------------- - close(hHeaderFig); - - % flushes the event queue and updates the figure window - % ----------------------------------------------------- - drawnow; - - % return error code (no change) - % ----------------------------- - error = -1; - end - -end diff --git a/tsg_util/tsg_plot_SalTempVel.m b/tsg_util/tsg_plot_SalTempVel.m deleted file mode 100644 index 12bbafc..0000000 --- a/tsg_util/tsg_plot_SalTempVel.m +++ /dev/null @@ -1,73 +0,0 @@ -function tsg_plot_SalTempVel( hTsgGUI, hAxes ) -% Function to plot the Salinity, Temperature TSG data as well as the -% ship velocity -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% hPlotAxes .......... Handels to the 3 graphic axes -% -% Output -% ------ -% $Id$ - -% Retrieve named application data -% ------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); -qc = getappdata( hTsgGUI, 'qcColor'); - -% Plot the Salinity with the right color code -% ------------------------------------------- -axes( hAxes(1)); - -ind = find(tsg.SSPS_QC <= qc.Code.NO_CONTROL ); -plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ... - strcat('.',qc.Color.NO_CONTROL)); - -hold on; - -ind = find(tsg.SSPS_QC == qc.Code.GOOD ); -plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ... - strcat('.',qc.Color.GOOD)); - -ind = find(tsg.SSPS_QC == qc.Code.PROBABLY_GOOD ); -plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ... - strcat('.',qc.Color.PROBABLY_GOOD)); - -ind = find(tsg.SSPS_QC == qc.Code.PROBABLY_BAD ); -plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ... - strcat('.',qc.Color.PROBABLY_BAD)); - -ind = find(tsg.SSPS_QC == qc.Code.BAD ); -plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ... - strcat('.',qc.Color.BAD)); -hold off; - -% Plot Temperature and ship velocity with no qc color code -% --------------------------------------------------------- -plot(hAxes(2), tsg.DAYD, tsg.SSJT, '.'); -plot(hAxes(3), tsg.DAYD, tsg.SPDC, '.k'); - -% Formatted x-TIME axes -% --------------------- -datetick(hAxes(1), 'x'); -datetick(hAxes(2), 'x'); -datetick(hAxes(3), 'x'); - -% Write some 'Y' label -% ------------------ -set(get(hAxes(1), 'Ylabel'), 'String', 'Salinity'); -set(get(hAxes(2), 'Ylabel'), 'String', 'Temperature (°C)'); -set(get(hAxes(3), 'Ylabel'), 'String', 'Ship Velocity (knots)'); - -% Make the axes visible -% --------------------- -set(hAxes(1), 'Visible', 'on' ); -set(hAxes(2), 'Visible', 'on' ); -set(hAxes(3), 'Visible', 'on' ); - -% The 3 axes will behave identically when zoomed and panned -% --------------------------------------------------------- -linkaxes([hAxes(1),hAxes(2),hAxes(3)], 'x'); - -end diff --git a/tsg_util/tsg_plot_SalTsgSample.m b/tsg_util/tsg_plot_SalTsgSample.m deleted file mode 100644 index 29e1c54..0000000 --- a/tsg_util/tsg_plot_SalTsgSample.m +++ /dev/null @@ -1,106 +0,0 @@ -function tsg_plot_SalTsgSample( hGUI, hAxes ) -% -% Function to plot the Salinity from TSG and smaple meausrements -% -% Input -% ----- -% hGUI ............... Handel to the user interface -% hPlotAxes .......... Handels to the graphic axes -% -% Output -% ------ -% - -% Retrieve named application data -% ------------------------------- -tsg = getappdata( hGUI, 'tsg_data'); -sample = getappdata( hGUI, 'sample' ); -qc = getappdata( hGUI, 'qcColor'); - - -% Plot the Salinity with the right color code -% ------------------------------------------- -axes( hAxes(1)); - -ind = find(tsg.PSAL_QC <= qc.Code.NO_CONTROL ); -plot(hAxes(1), tsg.TIME(ind), tsg.PSAL(ind), ... - strcat('.',qc.Color.NO_CONTROL)); - -hold on; - -ind = find(tsg.PSAL_QC == qc.Code.GOOD ); -plot(hAxes(1), tsg.TIME(ind), tsg.PSAL(ind), ... - strcat('.',qc.Color.GOOD)); - -ind = find(tsg.PSAL_QC == qc.Code.PROBABLY_GOOD ); -plot(hAxes(1), tsg.TIME(ind), tsg.PSAL(ind), ... - strcat('.',qc.Color.PROBABLY_GOOD)); - -ind = find(tsg.PSAL_QC == qc.Code.PROBABLY_BAD ); -plot(hAxes(1), tsg.TIME(ind), tsg.PSAL(ind), ... - strcat('.',qc.Color.PROBABLY_BAD)); - -ind = find(tsg.PSAL_QC == qc.Code.BAD ); -plot(hAxes(1), tsg.TIME(ind), tsg.PSAL(ind), ... - strcat('.',qc.Color.BAD)); - -% Plot salinity sample on TSG plot -% -------------------------------- -if ~isempty(sample) - plot(hAxes(1), sample.TIME, sample.PSAL, 'r*'); -end - - -% Plot sample measurements -% ------------------------ -axes( hAxes(2)); - -ind = find(sample.PSAL_QC <= qc.Code.NO_CONTROL ); -plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... - strcat('o',qc.Color.NO_CONTROL)); - -hold on; - -ind = find(sample.PSAL_QC == qc.Code.GOOD ); -plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... - strcat('o',qc.Color.GOOD)); - -ind = find(sample.PSAL_QC == qc.Code.PROBABLY_GOOD ); -plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... - strcat('o',qc.Color.PROBABLY_GOOD)); - -ind = find(sample.PSAL_QC == qc.Code.PROBABLY_BAD ); -plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... - strcat('o',qc.Color.PROBABLY_BAD)); - -ind = find(sample.PSAL_QC == qc.Code.BAD ); -plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... - strcat('o',qc.Color.BAD)); - -%plot(hAxes(3), tsg.TIME, tsg.TEMP_TSG, '.'); - -% Formatted x-TIME axes -% --------------------- -datetick(hAxes(1), 'x'); -get(hAxes(1), 'Xlim'); -datetick(hAxes(2), 'x'); -set(hAxes(2), 'Xlim', get(hAxes(1), 'Xlim')); -%datetick(hAxes(3), 'x'); - -% Write some 'Y' label -% ------------------ -set(get(hAxes(1), 'Ylabel'), 'String', 'Salinity'); -set(get(hAxes(2), 'Ylabel'), 'String', 'Salinity Difference'); -%set(get(hAxes(3), 'Ylabel'), 'String', 'Ship Velocity'); - -% Make the axes visible -% --------------------- -set(hAxes(1), 'Visible', 'on' ); -set(hAxes(2), 'Visible', 'on' ); -%set(hAxes(3), 'Visible', 'on' ); - -% The 3 axes will behave identically when zoomed and panned -% --------------------------------------------------------- -linkaxes([hAxes(1),hAxes(2)], 'x'); - -end diff --git a/tsg_util/tsg_plotmap.m b/tsg_util/tsg_plotmap.m deleted file mode 100644 index 0a95c5f..0000000 --- a/tsg_util/tsg_plotmap.m +++ /dev/null @@ -1,49 +0,0 @@ -function tsg_plotmap(hTsgGUI, hAxes) -% Function to plot the earth map and ship trackline -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% hPlotAxes .......... Handels to the graphic axes -% -% Output -% ------ -% -% Library : 'M_MAP' -% -% PROBLEM NOT YET RESOLVED -% Does M_MAP use 0-360° or -180°-180° covention ? -% $Id$ - -% Retrieve named application data -% ------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Positionning the right axes -% ---------------------------- -axes(hAxes(4)); - -% Use of Mercator projection -% -------------------------- -m_proj('Mercator','lat',[-70 70],'long',[-180 180]); - -% detailed coast lines -% m_gshhs_i('patch',[.7 .7 .7]); - -% Less detailed coast lines -% m_gshhs_l('patch',[.7 .7 .7]); - -% Lesser detailed coast lines -% ---------------------------- -m_coast('patch',[.7 .7 .7]); - -m_grid('box','fancy','tickdir','in', ... - 'ytick', [-70:20:70],... - 'xtick', [-180:40:180],... - 'Fontsize', [10]); - -% Plot the ship track - Check if LAT-LON in deg-decimal -% ----------------------------------------------------- -m_line(tsg.LONGITUDE,tsg.LATITUDE,'marker','.','markersize',3,'color','b'); - -end diff --git a/tsg_util/tsg_readBucketData.m b/tsg_util/tsg_readBucketData.m deleted file mode 100644 index 691301e..0000000 --- a/tsg_util/tsg_readBucketData.m +++ /dev/null @@ -1,55 +0,0 @@ -function [error] = tsg_readBucketData( hTsgGUI, filename) -% Function to read Bucket data in ASCII format. -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'bucketASCII' -% -% Caution : replace the fill-value with NaN -% $Id$ - -% Open the file -% ------------- -fid = fopen( filename, 'r' ); - -error = -1; -if fid ~= -1 - - % Read the file - skip 2 lines - % ---------------------------- - fgetl( fid ); fgetl( fid ); - bucketData = fscanf(fid,'%d %d %d %d %d %d %f %f %f', [9 Inf])'; - - % Every variable are put in a structure - % ------------------------------------- - bucketASCII.TIME = datenum(bucketData(:,1), bucketData(:,2), ... - bucketData(:,3), bucketData(:,4), ... - bucketData(:,5), bucketData(:,6)); - bucketASCII.LATITUDE = bucketData(:,7); - bucketASCII.LONGITUDE = bucketData(:,8); - bucketASCII.PSAL = bucketData(:,9); - bucketASCII.PSAL_QC = zeros(size(bucketASCII.PSAL)); - - % Save the data in the application GUI - % ------------------------------------ - setappdata( hTsgGUI, 'bucketASCII', bucketASCII ); - - % Clear the Workspace - % ------------------- - clear bucketData - - % Close the file - % -------------- - fclose( fid ); - - % Everything OK - % ------------- - error = 1; -end diff --git a/tsg_util/tsg_readTsgDataNetCDF.m b/tsg_util/tsg_readTsgDataNetCDF.m deleted file mode 100644 index 95a7811..0000000 --- a/tsg_util/tsg_readTsgDataNetCDF.m +++ /dev/null @@ -1,187 +0,0 @@ -function [error] = tsg_readTsgDataNetCDF( hTsgGUI, filename) -% Function to read the TSG data. Should be a NetCDF file -% GOSUD data format TSG V1.4 -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% $Id$ - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Display read file info on console -% --------------------------------- -fprintf('\nREAD_NETCDF_FILE\n'); tic; - -% Open netCDF file -% ---------------- -nc = netcdf(filename,'read'); -if isempty(nc) - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; - warndlg( msg_error, 'NetCDF error dialog'); - sprintf('...cannot locate %s\n', filename); - error = -1; - return; -end - -% Display more info about read file on console -% -------------------------------------------- -fprintf('...reading %s : ', filename); - -% Read global attributes: meta data -% ---------------------------------- - -tsg.PLATFORM_NAME = nc.PLATFORM_NAME(:); -tsg.SHIP_CALL_SIGN = nc.SHIP_CALL_SIGN(:); -tsg.SHIP_MMSI = nc.SHIP_MMSI(:); -tsg.TSG_TYPE = nc.TSG_TYPE(:); -tsg.TSG_NUMBER = nc.TSG_NUMBER(:); -tsg.TINT_TYPE = nc.TINT_TYPE(:); -tsg.TINT_NUMBER = nc.TINT_NUMBER(:); -tsg.DATA_TYPE = nc.DATA_TYPE(:); -tsg.DATA_MODE = nc.DATA_MODE(:); -tsg.SAMPLING_PERIOD = nc.SAMPLING_PERIOD(:); -tsg.PROCESSING_STATUS = nc.PROCESSING_STATUS(:); -tsg.DATE_START = nc.DATE_START(:); -tsg.DATE_END = nc.DATE_END(:); -tsg.SOUTH_LATX = nc.SOUTH_LATX(:); -tsg.NORTH_LATX = nc.NORTH_LATX(:); -tsg.WEST_LONX = nc.WEST_LONX(:); -tsg.EAST_LONX = nc.EAST_LONX(:); -tsg.FORMAT_VERSION = nc.FORMAT_VERSION(:); -tsg.DATE_CREATION = nc.DATE_CREATION(:); -tsg.DATE_UPDATE = nc.DATE_UPDATE(:); -tsg.DATA_RESTRICTIONS = nc.DATA_RESTRICTIONS(:); -tsg.CITATION = nc.CITATION(:); -tsg.COMMENT = nc.COMMENT(:); -tsg.PROJECT_NAME = nc.PROJECT_NAME(:); -tsg.PI_NAME = nc.PI_NAME(:); -tsg.DATA_CENTRE = nc.DATA_CENTRE(:); -tsg.DATA_ACQUISITION = nc.DATA_ACQUISITION(:); -tsg.PROCESSING_CENTRE = nc.PROCESSING_CENTRE(:); -tsg.PROCESSING_STATE = nc.PROCESSING_STATE(:); - -% read variables describing TSG installation -% ------------------------------------------ - -tsg.SSJT_DEPH = nc{'SSJT_DEPH'}(:); -tsg.SSJT_DEPH_MIN = nc{'SSJT_DEPH_MIN'}(:); -tsg.SSJT_DEPH_MAX = nc{'SSJT_DEPH_MAX'}(:); -tsg.CNDC_CALCOEF = nc{'CNDC_CALCOEF'}(:); -tsg.CNDC_LINCOEF = nc{'CNDC_LINCOEF'}(:); -tsg.SSJT_CALCOEF = nc{'SSJT_CALCOEF'}(:); -tsg.SSJT_LINCOEF = nc{'SSJT_LINCOEF'}(:); - -% read variables describing Temperature sensor at intake (TINT) installation -% -------------------------------------------------------------------------- - -tsg.SSTP_DEPH = nc{'SSTP_DEPH'}(:); -tsg.SSTP_DEPH_MIN = nc{'SSTP_DEPH_MIN'}(:); -tsg.SSTP_DEPH_MAX = nc{'SSTP_DEPH_MAX'}(:); -tsg.SSTP_CALCOEF = nc{'SSTP_CALCOEF'}(:); -tsg.SSTP_LINCOEF = nc{'SSTP_LINCOEF'}(:); - -% Coordinates -%------------ - -tsg.DATE = nc{'DATE'}(:,:); -tsg.DAYD = nc{'DAYD'}(:); -tsg.LATX = nc{'LATX'}(:); -tsg.LONX = nc{'LONX'}(:); -tsg.POSITION_QC = nc{'POSITION_QC'}(:); -tsg.SPDC = nc{'SPDC'}(:); -tsg.REFERENCE_DATE_TIME = nc{'REFERENCE_DATE_TIME'}(:); - -% Convert julian day with origin 1950 to Matlab datenum in memory -% --------------------------------------------------------------- -tsg.DAYD = julianToDatenum( tsg.DAYD ); - -% Variables holding data from the main TSG -% data series 1 -%----------------------------------------- - -% measured variables -%----------------------------------------- -%if isempty(tsg.PRES) - tsg.PRES = nc{'PRES'}(:); -%end - -%if isempty(tsg.SSJT) - tsg.SSJT = nc{'SSJT'}(:); - tsg.SSJT_STD = nc{'SSJT_STD'}(:); - tsg.SSJT_STD_CAL = nc{'TEMP_STD_CAL'}(:); -%end - -%if isempty(tsg.CNDC) - tsg.CNDC = nc{'CNDC'}(:); - tsg.CNDC_STD = nc{'CNDC_STD'}(:); - tsg.CNDC_CAL = nc{'CNDC_CAL'}(:); -%end - -% intake temperature variable -%----------------------------------------- -tsg.SSTP = nc{'SSTP'}(:); -tsg.SSTP_QC = nc{'SSTP_QC'}(:); -tsg.SSTP_CAL = nc{'SSTP_CAL'}(:); -tsg.SSTP_ADJUSTED = nc{'SSTP_ADJUSTED'}(:); -tsg.SSTP_ADJUSTED_ERROR = nc{'SSTP_ADJUSTED_ERROR'}(:); -tsg.SSTP_ADJUSTED_QC = nc{'SSTP_ADJUSTED_QC'}(:); -tsg.SSTP_ADJUSTED_HIST = nc{'HIST_SSTP_ADJUSTED'}(:); - -% derived variables -%----------------------------------------- -tsg.SSPS = nc{'SSPS'}(:); -tsg.SSPS_QC = nc{'SSPS_QC'}(:); -tsg.SSPS_CAL = nc{'SSPS_CAL'}(:); -tsg.SSPS_ADJUSTED = nc{'SSPS_ADJUSTED'}(:); -tsg.SSPS_ADJUSTED_ERROR = nc{'SSPS_ADJUSTED_ERROR'}(:); -tsg.SSPS_ADJUSTED_QC = nc{'SSPS_ADJUSTED_QC'}(:); -tsg.SSPS_ADJUSTED_HIST = nc{'HIST_SSPS_ADJUSTED'}(:); - -% data series 2 -%----------------------------------------- - -% water samples -%----------------------------------------- -tsg.DATE_WS = nc{'DATE_WS'}(:,:); -tsg.DAYD_WS = julianToDatenum(nc{'DAYD_WS'}(:)); -tsg.LATX_WS = nc{'LATX_WS'}(:); -tsg.LONX_WS = nc{'LONX_WS'}(:); -tsg.SSPS_WS = nc{'SSPS_WS'}(:); -tsg.SSPS_WS_QC = nc{'SSPS_WS_QC'}(:); -tsg.SSPS_WS_ANALDATE = nc{'SSPS_WS_ANALDATE'}(:,:); -tsg.SSPS_WS_BOTTLE = nc{'SSPS_WS_BOTTLE'}(:,:); - - -% Save the data in the application GUI -% ------------------------------------ -setappdata( hTsgGUI, 'tsg_data', tsg ); - -% Clear the Workspace -% ------------------- -clear tsgdata - -% Close the file -% -------------- -%endef(nc) -close(nc); - -% Display time to read file on console -% ------------------------------------ -t = toc; fprintf('...done (%6.2f sec).\n\n',t); - -% Everything OK -% ------------- -error = 1; - -end diff --git a/tsg_util/tsg_readTsgDataTxt.m b/tsg_util/tsg_readTsgDataTxt.m deleted file mode 100644 index d73df09..0000000 --- a/tsg_util/tsg_readTsgDataTxt.m +++ /dev/null @@ -1,105 +0,0 @@ -function [error] = tsg_readTsgDataTxt( hTsgGUI, filename) -% Function to read the TSG data. Should be a NetCDF file -% -% Input -% ----- -% hTsgGUI ............ Handle to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% -% Caution : replace the fill-value with NaN -% $Id$ - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Display read file info on console -% --------------------------------- -fprintf('\nREAD_ASCII_FILE\n'); tic; - -% Open the file -% ------------- -fid = fopen( filename, 'r' ); - -% Check file -% ----------- -if fid == -1 - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; - warndlg( msg_error, 'ASCII error dialog'); - sprintf('...cannot locate %s\n', filename); - error = -1; - return; -end - -% Display more info about read file on console -% -------------------------------------------- -fprintf('...reading %s : ', filename); - -% Read the file -% ------------- -tsgData = fscanf(fid, '%d/%d/%d %d:%d:%d %f %f %f %f %d %f %f', ... - [13 Inf])'; - -% Every variable are put in a structure -% ------------------------------------- -tsg.DAYD = datenum(tsgData(:,3), tsgData(:,2),tsgData(:,1), ... - tsgData(:,4),tsgData(:,5),tsgData(:,6)); - -% save original date -% ------------------ -tsg.DATE = datestr( tsg.DAYD, 'yyyymmddHHMMSS' ); - -% convert with julian day with origin 1950 -% ----------------------------------------- -%% a supprimer !!!!!!! -% tsg.TIME_TSG = datenumToJulian(tsg.TIME_TSG); - -tsg.LATX = tsgData(:,7); -tsg.LONX = tsgData(:,8); -tsg.SSJT = tsgData(:,9); -tsg.SSPS = tsgData(:,10); -tsg.SSPS_QC = tsgData(:,11); -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -tsg.SSPS_ADJ = tsgData(:,12); -tsg.SSPS_ERR = tsgData(:,13); - -% Compute ship velocity from positions if sog not available -% --------------------------------------------------------- -if isempty(tsg.SPDC) - range = m_lldist(tsg.LONX,tsg.LATX); - ind = size(tsg.DAYD); - tsg.SPDC = zeros(size(ind)); - for i=1:length(tsg.DAYD)-1 - tsg.SPDC(i) = range(i) / ((tsg.DAYD(i+1)-tsg.DAYD(i)) * 24 * 1.854); - end - tsg.SPDC = [tsg.SPDC';0]; -end - - -% Save the data in the application GUI -% ------------------------------------ -setappdata( hTsgGUI, 'tsg_data', tsg ); - -% Clear the Workspace -% ------------------- -clear tsgdata - -% Close the file -% -------------- -fclose( fid ); - -% Display time to read file on console -% ------------------------------------ -t = toc; fprintf('...done (%6.2f sec).\n\n',t); - -% Everything OK -% ------------- -error = 1; diff --git a/tsg_util/tsg_readTsgDataXML.m b/tsg_util/tsg_readTsgDataXML.m deleted file mode 100644 index d937645..0000000 --- a/tsg_util/tsg_readTsgDataXML.m +++ /dev/null @@ -1,58 +0,0 @@ -function [error] = tsg_readTsgDataXML( hTsgGUI, filename) -% Function to read the TSG data XML file -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% Function not yet implemented -% Caution : replace the fill-value with NaN -% $Id$ - -% Open the file -% ------------- -fid = fopen( filename, 'r' ); - -error = -1; -if fid ~= -1 - disp('Read XML file, not yet implemeted ...'); -% % Read the file -% % ------------- -% tsgData = fscanf(fid, '%d/%d/%d %d:%d:%d %f %f %f %f %d %f %f', ... -% [13 Inf])'; -% -% % Every variable are put in a structure -% % ------------------------------------- -% tsg.TIME = datenum(tsgData(:,3), tsgData(:,2),tsgData(:,1), ... -% tsgData(:,4),tsgData(:,5),tsgData(:,6)); -% tsg.LATITUDE = tsgData(:,7); -% tsg.LONGITUDE = tsgData(:,8); -% tsg.TEMP_TSG = tsgData(:,9); -% tsg.PSAL = tsgData(:,10); -% tsg.PSAL_QC = tsgData(:,11); -% tsg.PSAL_ADJ = tsgData(:,12); -% tsg.PSAL_ERR = tsgData(:,13); -% -% % Save the data in the application GUI -% % ------------------------------------ -% setappdata( hTsgGUI, 'tsg_data', tsg ); - - % Clear the Workspace - % ------------------- - clear tsgdata - - % Close the file - % -------------- - fclose( fid ); - - % Everything is not OK - % ------------- - error = -1; -end diff --git a/tsg_util/tsg_writeTSGDataNetCDF.m b/tsg_util/tsg_writeTSGDataNetCDF.m deleted file mode 100644 index 4c49a29..0000000 --- a/tsg_util/tsg_writeTSGDataNetCDF.m +++ /dev/null @@ -1,147 +0,0 @@ -function [error] = tsg_writeTSGDataNetCDF( hTsgGUI, filename) -% Function to write TSG data in NetCDF file. -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error ............. 1 : OK -% ............. -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% Caution : replace the fill-value with NaN -% $Id$ - -% Open the file -% ------------- -nc = netcdf(filename, 'clobber'); -if isempty(nc) - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; - warndlg( msg_error, 'NetCDF write dialog'); - error = -1; - return; -end - -% Initialize loading NetCDF file waitbar -% -------------------------------------- -wb = waitbar(0, 'Initializing NetCDF file. Please wait...'); - -% We cannot change title property to 'none' (default set as 'tex') inside -% waitbar function (line 81), see -% http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/115725 -% ----------------------------------------------------------------------- -hchild = get(wb,'children'); -htitle = get(hchild,'title'); -set(htitle,'Interpreter','None'); - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Get global attributes list from class tsg_nc with file 'tsg_ncattr.csv' -% ----------------------------------------------------------------------- -nca = tsg_nc('tsg_ncattr.csv'); -nca_keys = keys(nca); - -% Get GF3 variables list codes from class tsg_nc with file 'tsg_ncvar.csv' -% ----------------------------------------------------------------------- -ncv = tsg_nc('tsg_ncvar.csv'); -ncv_keys = keys(ncv); -ncv_fieldNames = get_fieldnames(ncv); - -% Create NetCDF file: -% ------------------- - -% Variable dimensions -% ------------------- -nc('DAYD') = numel(tsg.DAYD); % number of TSG measurements -nc('DAYD_WS') = numel(tsg.DAYD_WS); % number of water samples -nc('DAYD_EXT') = numel(tsg.DAYD_EXT); % number of external SSPS or SSTP comparison -nc('NCOEF_CAL') = 5; % number of calibration coefficients -nc('NCOEF_LIN') = 2; % number of linearisation coefficients - -% Fixed dimensions -% ---------------- -nc('STRING256') = 256; -nc('STRING14') = 14; -nc('STRING4') = 4; -nc('N1') = 1; - -% display filename after 'Interpreter','None' initialization to prevent -% display console warning -% --------------------------------------------------------------------- -waitbar(1/50,wb,['Writing file: ' filename ' Please wait...']); - -% Create NetCDF global attributes -% ------------------------------- -for i=1:numel(nca_keys) - nc.(nca_keys{i}) = tsg.(nca_keys{i}); -end - -% Create NetCDF variables and attributes -% --------------------------------------------------- -for i=1:numel(ncv_keys) - for j=1:numel(ncv_fieldNames) - fn = ncv_fieldNames{j}; - % define dimension - if strcmp(fn,'dimension') - nc{ncv_keys{i}} = ncfloat(get(ncv, ncv_keys{i}, fn)); - % define variable atributes - elseif ~isempty(get(ncv, ncv_keys{i}, fn)) - if ischar(get(ncv, ncv_keys{i}, fn)) - nc{ncv_keys{i}}.(fn) = ncchar(get(ncv, ncv_keys{i}, fn)); - else - nc{ncv_keys{i}}.(fn) = ncfloat(get(ncv, ncv_keys{i}, fn)); - end - end - end -end - -% Create data to NetCDF file: -% --------------------------- - -% Write global attributes -% ----------------------- -for i=1:numel(nca_keys) - nc.(nca_keys{i}) = tsg.(nca_keys{i}); -end - -% Convert Matlab julian days (datenum) to 1950 reference -% ------------------------------------------------------ -d = strmatch('DAYD',ncv_keys); -for i=1:numel(d) - tsg.(ncv_keys{d(i)}) = datenumToJulian(tsg.(ncv_keys{d(i)})); -end - -% Write measurements (variables) -% ------------------------------- -for i=1:numel(ncv_keys) - % display waitbar - waitbar( i/numel(ncv_keys), wb, ['writing ' ncv_keys{i} ' variable']); - % DATE as two dimension - if strmatch('DATE',ncv_keys(i)) - nc{ncv_keys{i}}(:,:) = tsg.(ncv_keys{i}); - else - % other one dimension - nc{ncv_keys{i}}(:) = tsg.(ncv_keys{i}); - end -end - -% Close waitbar -% ------------- -close(wb) - -% Close NetCDF file -% ----------------- -endef(nc) -close(nc) - -% Everything OK -% ------------- -error = 1; - -end diff --git a/tsg_util/tsg_writeTsgData.m b/tsg_util/tsg_writeTsgData.m deleted file mode 100644 index 9948b56..0000000 --- a/tsg_util/tsg_writeTsgData.m +++ /dev/null @@ -1,55 +0,0 @@ -function [error] = tsg_writeTsgData( hTsgGUI, filename) -% Function to write the TSG data. Should be a NetCDF file -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% Function to be rewritten when the NetCDF format will be in use -% Caution : replace the fill-value with NaN -%$Id$ - -% Open the file -% ------------- -fid = fopen( filename, 'w' ); - -error = -1; -if fid ~= -1 - - % Get the data from the application GUI - % ------------------------------------- - tsg = getappdata( hTsgGUI, 'tsg_data'); - - [year, month, day, hour, min, sec] = datevec( tsg.TIME ); - - tsg_data = [day month year hour min fix(sec) tsg.LATITUDE ... - tsg.LONGITUDE tsg.TEMP_TSG ... - tsg.PSAL tsg.PSAL_QC ... - tsg.PSAL_ADJ tsg.PSAL_ERR ... - ]; - - % Write the file - % ------------- - fprintf(fid,... - '%02d/%02d/%04d %02d:%02d:%02d %11.6f %11.6f %6.3f %6.3f %1d %6.3f %6.3f\n',... - tsg_data'); - - % Clear the Workspace - % ------------------- - clear tsgdata - - % Close the file - % -------------- - fclose( fid ); - - % Everything OK - % ------------- - error = 1; -end diff --git a/tsg_util/writeTSGDataNetCDF.m b/tsg_util/writeTSGDataNetCDF.m deleted file mode 100644 index 4c49a29..0000000 --- a/tsg_util/writeTSGDataNetCDF.m +++ /dev/null @@ -1,147 +0,0 @@ -function [error] = tsg_writeTSGDataNetCDF( hTsgGUI, filename) -% Function to write TSG data in NetCDF file. -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error ............. 1 : OK -% ............. -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% Caution : replace the fill-value with NaN -% $Id$ - -% Open the file -% ------------- -nc = netcdf(filename, 'clobber'); -if isempty(nc) - msg_error = ['TSG_GOSUD file_lecture : Open file error : ' filename]; - warndlg( msg_error, 'NetCDF write dialog'); - error = -1; - return; -end - -% Initialize loading NetCDF file waitbar -% -------------------------------------- -wb = waitbar(0, 'Initializing NetCDF file. Please wait...'); - -% We cannot change title property to 'none' (default set as 'tex') inside -% waitbar function (line 81), see -% http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/115725 -% ----------------------------------------------------------------------- -hchild = get(wb,'children'); -htitle = get(hchild,'title'); -set(htitle,'Interpreter','None'); - -% Get the data from the application GUI -% ------------------------------------- -tsg = getappdata( hTsgGUI, 'tsg_data'); - -% Get global attributes list from class tsg_nc with file 'tsg_ncattr.csv' -% ----------------------------------------------------------------------- -nca = tsg_nc('tsg_ncattr.csv'); -nca_keys = keys(nca); - -% Get GF3 variables list codes from class tsg_nc with file 'tsg_ncvar.csv' -% ----------------------------------------------------------------------- -ncv = tsg_nc('tsg_ncvar.csv'); -ncv_keys = keys(ncv); -ncv_fieldNames = get_fieldnames(ncv); - -% Create NetCDF file: -% ------------------- - -% Variable dimensions -% ------------------- -nc('DAYD') = numel(tsg.DAYD); % number of TSG measurements -nc('DAYD_WS') = numel(tsg.DAYD_WS); % number of water samples -nc('DAYD_EXT') = numel(tsg.DAYD_EXT); % number of external SSPS or SSTP comparison -nc('NCOEF_CAL') = 5; % number of calibration coefficients -nc('NCOEF_LIN') = 2; % number of linearisation coefficients - -% Fixed dimensions -% ---------------- -nc('STRING256') = 256; -nc('STRING14') = 14; -nc('STRING4') = 4; -nc('N1') = 1; - -% display filename after 'Interpreter','None' initialization to prevent -% display console warning -% --------------------------------------------------------------------- -waitbar(1/50,wb,['Writing file: ' filename ' Please wait...']); - -% Create NetCDF global attributes -% ------------------------------- -for i=1:numel(nca_keys) - nc.(nca_keys{i}) = tsg.(nca_keys{i}); -end - -% Create NetCDF variables and attributes -% --------------------------------------------------- -for i=1:numel(ncv_keys) - for j=1:numel(ncv_fieldNames) - fn = ncv_fieldNames{j}; - % define dimension - if strcmp(fn,'dimension') - nc{ncv_keys{i}} = ncfloat(get(ncv, ncv_keys{i}, fn)); - % define variable atributes - elseif ~isempty(get(ncv, ncv_keys{i}, fn)) - if ischar(get(ncv, ncv_keys{i}, fn)) - nc{ncv_keys{i}}.(fn) = ncchar(get(ncv, ncv_keys{i}, fn)); - else - nc{ncv_keys{i}}.(fn) = ncfloat(get(ncv, ncv_keys{i}, fn)); - end - end - end -end - -% Create data to NetCDF file: -% --------------------------- - -% Write global attributes -% ----------------------- -for i=1:numel(nca_keys) - nc.(nca_keys{i}) = tsg.(nca_keys{i}); -end - -% Convert Matlab julian days (datenum) to 1950 reference -% ------------------------------------------------------ -d = strmatch('DAYD',ncv_keys); -for i=1:numel(d) - tsg.(ncv_keys{d(i)}) = datenumToJulian(tsg.(ncv_keys{d(i)})); -end - -% Write measurements (variables) -% ------------------------------- -for i=1:numel(ncv_keys) - % display waitbar - waitbar( i/numel(ncv_keys), wb, ['writing ' ncv_keys{i} ' variable']); - % DATE as two dimension - if strmatch('DATE',ncv_keys(i)) - nc{ncv_keys{i}}(:,:) = tsg.(ncv_keys{i}); - else - % other one dimension - nc{ncv_keys{i}}(:) = tsg.(ncv_keys{i}); - end -end - -% Close waitbar -% ------------- -close(wb) - -% Close NetCDF file -% ----------------- -endef(nc) -close(nc) - -% Everything OK -% ------------- -error = 1; - -end diff --git a/tsg_util/writeTsgData.m b/tsg_util/writeTsgData.m deleted file mode 100644 index 9948b56..0000000 --- a/tsg_util/writeTsgData.m +++ /dev/null @@ -1,55 +0,0 @@ -function [error] = tsg_writeTsgData( hTsgGUI, filename) -% Function to write the TSG data. Should be a NetCDF file -% -% Input -% ----- -% hTsgGUI ............ Handel to the main user interface -% filename ........... Data filename -% -% Output -% ------ -% error .............. 1: OK - -1 : an error occured -% -% The data are store using setappdata - Variable name : 'tsg_data' -% -% Function to be rewritten when the NetCDF format will be in use -% Caution : replace the fill-value with NaN -%$Id$ - -% Open the file -% ------------- -fid = fopen( filename, 'w' ); - -error = -1; -if fid ~= -1 - - % Get the data from the application GUI - % ------------------------------------- - tsg = getappdata( hTsgGUI, 'tsg_data'); - - [year, month, day, hour, min, sec] = datevec( tsg.TIME ); - - tsg_data = [day month year hour min fix(sec) tsg.LATITUDE ... - tsg.LONGITUDE tsg.TEMP_TSG ... - tsg.PSAL tsg.PSAL_QC ... - tsg.PSAL_ADJ tsg.PSAL_ERR ... - ]; - - % Write the file - % ------------- - fprintf(fid,... - '%02d/%02d/%04d %02d:%02d:%02d %11.6f %11.6f %6.3f %6.3f %1d %6.3f %6.3f\n',... - tsg_data'); - - % Clear the Workspace - % ------------------- - clear tsgdata - - % Close the file - % -------------- - fclose( fid ); - - % Everything OK - % ------------- - error = 1; -end -- GitLab