diff --git a/decArgo_soft/soft/util/nc_create_synthetic_profile.m b/decArgo_soft/soft/util/nc_create_synthetic_profile.m index 84021e78..8e77cc05 100644 --- a/decArgo_soft/soft/util/nc_create_synthetic_profile.m +++ b/decArgo_soft/soft/util/nc_create_synthetic_profile.m @@ -48,6 +48,9 @@ % this new version generates S-PROF file (possibly % empty) even when 'c' PROF or 'b' PROF file is % missing +% 07/10/2020 - RNU - V 1.10: correction in processing of PROFILE__QC +% (the input Qcs used depend on PARAMATER_DATA_MODE +% information) % ------------------------------------------------------------------------------ function nc_create_synthetic_profile(varargin) @@ -102,11 +105,15 @@ function nc_create_synthetic_profile(varargin) % program version global g_cocs_ncCreateSyntheticProfileVersion; -g_cocs_ncCreateSyntheticProfileVersion = '1.9 (version 30.06.2020 for ARGO_simplified_profile)'; +g_cocs_ncCreateSyntheticProfileVersion = '1.10 (version 30.06.2020 for ARGO_simplified_profile)'; % current float and cycle identification global g_cocs_floatNum; +% output CSV file Id +global g_cocs_fidCsvFile; +g_cocs_fidCsvFile = -1; + % default values initialization init_default_values; @@ -190,6 +197,22 @@ function nc_create_synthetic_profile(varargin) end if (errorFlag == 0) + + % output CSV file name + [~, logFileName, ~] = fileparts(logFile); + csvFileName = [DIR_CSV_FILE '/' logFileName '.csv']; + + % create CSV file + g_cocs_fidCsvFile = fopen(csvFileName, 'wt'); + if (g_cocs_fidCsvFile == -1) + fprintf('ERROR: Unable to create output CSV file: %s\n', csvFileName); + return + end + + % put header + header = 'dac, type, float code, cycle number, message, file'; + fprintf(g_cocs_fidCsvFile, '%s\n', header); + if (~isempty(floatList)) % process floats of the FLOAT_LIST_FILE_NAME file (or provided in input @@ -238,12 +261,14 @@ function nc_create_synthetic_profile(varargin) end end +fclose(g_cocs_fidCsvFile); + diary off; -if (~isempty(DIR_CSV_FILE)) - % generate CSV file (from log file contents) - generate_csv_file(logFile, DIR_CSV_FILE); -end +% if (~isempty(DIR_CSV_FILE)) +% % generate CSV file (from log file contents) +% generate_csv_file(logFile, DIR_CSV_FILE); +% end return @@ -279,17 +304,46 @@ function process_one_float(a_floatDir, a_outputDir, ... global g_cocs_floatNum; global g_cocs_cycleNum; global g_cocs_cycleDir; - +g_cocs_cycleDir = ''; + +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +g_cocs_dacName = '-'; +global g_cocs_floatWmoStr; +g_cocs_floatWmoStr = num2str(g_cocs_floatNum); +global g_cocs_cycleNumStr; +g_cocs_cycleNumStr = '-'; +global g_cocs_inputFile; +g_cocs_inputFile = '-'; floatWmoStr = num2str(g_cocs_floatNum); + % META data file metaFileName = [a_floatDir '/' floatWmoStr '_meta.nc']; if ~(exist(metaFileName, 'file') == 2) fprintf('ERROR: Float %d: META file not found: %s\n', g_cocs_floatNum, metaFileName); + + % CSV output + msgType = 'error'; + message = 'File not found.'; + [~, fileName, fileExt] = fileparts(metaFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end +% retrieve DATA_CENTRE from META file +wantedVars = [ ... + {'DATA_CENTRE'} ... + ]; +[metaData] = get_data_from_nc_file(metaFileName, wantedVars); +dataCentre = get_data_from_name('DATA_CENTRE', metaData); +g_cocs_dacName = dataCentre(:, 1)'; + % create the list of available cycle numbers (from PROF files) profileDir = [a_floatDir '/profiles']; files = dir([profileDir '/' '*' floatWmoStr '_' '*.nc']); @@ -315,6 +369,7 @@ function process_one_float(a_floatDir, a_outputDir, ... for idCy = 1:length(cyNumList) g_cocs_cycleNum = cyNumList(idCy); + g_cocs_cycleNumStr = num2str(g_cocs_cycleNum); createMultiProfFlag = 0; if (idCy == length(cyNumList)) @@ -450,17 +505,17 @@ function process_one_float(a_floatDir, a_outputDir, ... return % ------------------------------------------------------------------------------ -% Generate the output CSV file (from INFO/WARNING/ERROR messages of the log -% file). +% Get data from name in a {var_name}/{var_data} list. % % SYNTAX : -% generate_csv_file(a_logFileName, a_csvDirName) +% [o_dataValues] = get_data_from_name(a_dataName, a_dataList) % % INPUT PARAMETERS : -% a_logFileName : log file path name of the run -% a_csvDirName : directory of CSV files +% a_dataName : name of the data to retrieve +% a_dataList : {var_name}/{var_data} list % % OUTPUT PARAMETERS : +% o_dataValues : concerned data % % EXAMPLES : % @@ -468,83 +523,89 @@ function process_one_float(a_floatDir, a_outputDir, ... % AUTHORS : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com) % ------------------------------------------------------------------------------ % RELEASES : -% 04/22/2020 - RNU - creation +% 06/15/2018 - RNU - creation % ------------------------------------------------------------------------------ -function generate_csv_file(a_logFileName, a_csvDirName) - -% output CSV file name -[~, logFileName, ~] = fileparts(a_logFileName); -csvFileName = [a_csvDirName '/' logFileName '.csv']; +function [o_dataValues] = get_data_from_name(a_dataName, a_dataList) +% output parameters initialization +o_dataValues = []; -% create CSV file -fidOut = fopen(csvFileName, 'wt'); -if (fidOut == -1) - fprintf('ERROR: Unable to create output file: %s\n', csvFileName); - return +idVal = find(strcmp(a_dataName, a_dataList(1:2:end)) == 1, 1); +if (~isempty(idVal)) + o_dataValues = a_dataList{2*idVal}; end -% put header -header = 'MESSAGE TYPE;MESSAGE SOURCE;MESSAGE CONTENT'; -fprintf(fidOut, '%s\n', header); +return -if (~isempty(a_logFileName)) - % read log file - fId = fopen(a_logFileName, 'r'); - if (fId == -1) - sprintf('ERROR: Unable to open file: %s\n', a_logFileName); +% ------------------------------------------------------------------------------ +% Retrieve data from NetCDF file. +% +% SYNTAX : +% [o_ncData] = get_data_from_nc_file(a_ncPathFileName, a_wantedVars) +% +% INPUT PARAMETERS : +% a_ncPathFileName : NetCDF file name +% a_wantedVars : NetCDF variables to retrieve from the file +% +% OUTPUT PARAMETERS : +% o_ncData : retrieved data +% +% EXAMPLES : +% +% SEE ALSO : +% AUTHORS : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com) +% ------------------------------------------------------------------------------ +% RELEASES : +% 06/15/2018 - RNU - creation +% ------------------------------------------------------------------------------ +function [o_ncData] = get_data_from_nc_file(a_ncPathFileName, a_wantedVars) + +% output parameters initialization +o_ncData = []; + +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_cycleDir; +global g_cocs_inputFile; + + +if (exist(a_ncPathFileName, 'file') == 2) + + % open NetCDF file + fCdf = netcdf.open(a_ncPathFileName, 'NC_NOWRITE'); + if (isempty(fCdf)) + fprintf('ERROR: Unable to open NetCDF input file: %s\n', a_ncPathFileName); + + % CSV output + msgType = 'error'; + message = 'Unable to open file.'; + [~, fileName, fileExt] = fileparts(a_ncPathFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end - fileContents = textscan(fId, '%s', 'delimiter', '\n'); - fclose(fId); - if (~isempty(fileContents) && ~isempty(fileContents{:})) - % retrieve wanted messages - fileContents = fileContents{:}; - idLine = 1; - while (1) - line = fileContents{idLine}; - msgType = ''; - msgSource = ''; - msg = ''; - if (strncmp(line, 'INFO: ', length('INFO: '))) - msgType = 'INFO'; - msgSource = 'nc_create_synthetic_profile'; - msg = line(length('INFO: ')+1:end); - elseif (strncmp(line, 'WARNING: ', length('WARNING: '))) - msgType = 'WARNING'; - msgSource = 'nc_create_synthetic_profile'; - msg = line(length('WARNING: ')+1:end); - elseif (strncmp(line, 'ERROR: ', length('ERROR: '))) - msgType = 'ERROR'; - msgSource = 'nc_create_synthetic_profile'; - msg = line(length('ERROR: ')+1:end); - elseif (strncmp(line, 'S-PROF_INFO: ', length('S-PROF_INFO: '))) - msgType = 'INFO'; - msgSource = 'ARGO_simplified_profile'; - msg = line(length('S-PROF_INFO: ')+1:end); - elseif (strncmp(line, 'S-PROF_WARNING: ', length('S-PROF_WARNING: '))) - msgType = 'WARNING'; - msgSource = 'ARGO_simplified_profile'; - msg = line(length('S-PROF_WARNING: ')+1:end); - elseif (strncmp(line, 'S-PROF_ERROR: ', length('S-PROF_ERROR: '))) - msgType = 'ERROR'; - msgSource = 'ARGO_simplified_profile'; - msg = line(length('S-PROF_ERROR: ')+1:end); - end - - if (~isempty(msgType)) - fprintf(fidOut, '%s;%s;%s\n', msgType, msgSource, msg); - end - - idLine = idLine + 1; - if (idLine > length(fileContents)) - break - end + % retrieve variables from NetCDF file + for idVar = 1:length(a_wantedVars) + varName = a_wantedVars{idVar}; + + if (var_is_present_dec_argo(fCdf, varName)) + varValue = netcdf.getVar(fCdf, netcdf.inqVarID(fCdf, varName)); + o_ncData = [o_ncData {varName} {varValue}]; + else + % fprintf('WARNING: Variable %s not present in file : %s\n', ... + % varName, a_ncPathFileName); + o_ncData = [o_ncData {varName} {' '}]; end + end + + netcdf.close(fCdf); end -fclose(fidOut); - return diff --git a/decArgo_soft/soft/util/nc_create_synthetic_profile_rt.m b/decArgo_soft/soft/util/nc_create_synthetic_profile_rt.m index adcd0a53..0825e5db 100644 --- a/decArgo_soft/soft/util/nc_create_synthetic_profile_rt.m +++ b/decArgo_soft/soft/util/nc_create_synthetic_profile_rt.m @@ -67,6 +67,9 @@ % this new version generates S-PROF file (possibly % empty) even when 'c' PROF or 'b' PROF file is % missing +% 07/10/2020 - RNU - V 1.10: correction in processing of PROFILE__QC +% (the input Qcs used depend on PARAMATER_DATA_MODE +% information) % ------------------------------------------------------------------------------ function nc_create_synthetic_profile_rt(varargin) @@ -135,13 +138,17 @@ function nc_create_synthetic_profile_rt(varargin) % program version global g_cocs_ncCreateSyntheticProfileVersion; -g_cocs_ncCreateSyntheticProfileVersion = '1.9 (version 30.06.2020 for ARGO_simplified_profile)'; +g_cocs_ncCreateSyntheticProfileVersion = '1.10 (version 30.06.2020 for ARGO_simplified_profile)'; % current float and cycle identification global g_cocs_floatNum; global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file Id +global g_cocs_fidCsvFile; +g_cocs_fidCsvFile = -1; + % startTime ticStartTime = tic; @@ -232,6 +239,21 @@ function nc_create_synthetic_profile_rt(varargin) g_cocs_floatNum = str2double(g_cocs_floatWmo); end + % output CSV file name + [~, logFile, ~] = fileparts(logFileName); + csvFileName = [g_cocs_outputCsvDirName '/' logFile '.csv']; + + % create CSV file + g_cocs_fidCsvFile = fopen(csvFileName, 'wt'); + if (g_cocs_fidCsvFile == -1) + fprintf('ERROR: Unable to create output CSV file: %s\n', csvFileName); + return + end + + % put header + header = 'dac, type, float code, cycle number, message, file'; + fprintf(g_cocs_fidCsvFile, '%s\n', header); + % generate S-PROF file nc_create_synthetic_profile_(... str2num(g_cocs_createOnlyMultiProfFlag), ... @@ -246,6 +268,8 @@ function nc_create_synthetic_profile_rt(varargin) end + fclose(g_cocs_fidCsvFile); + diary off; % finalize XML report @@ -253,6 +277,10 @@ function nc_create_synthetic_profile_rt(varargin) catch + if (g_cocs_fidCsvFile ~= -1) + fclose(g_cocs_fidCsvFile); + end + diary off; % finalize XML report @@ -260,11 +288,6 @@ function nc_create_synthetic_profile_rt(varargin) end -if (~isempty(g_cocs_outputCsvDirName)) - % generate CSV file (from log file contents) - generate_csv_file(logFileName, g_cocs_outputCsvDirName); -end - % create the XML report path file name if (~isempty(g_cocs_outputXmlReportDirName)) xmlFileName = [g_cocs_outputXmlReportDirName '/' g_cocs_outputXmlReportFileName]; @@ -888,103 +911,3 @@ function init_xml_report(a_time) end return - -% ------------------------------------------------------------------------------ -% Generate the output CSV file (from INFO/WARNING/ERROR messages of the log -% file). -% -% SYNTAX : -% generate_csv_file(a_logFileName, a_csvDirName) -% -% INPUT PARAMETERS : -% a_logFileName : log file path name of the run -% a_csvDirName : directory of CSV files -% -% OUTPUT PARAMETERS : -% -% EXAMPLES : -% -% SEE ALSO : -% AUTHORS : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com) -% ------------------------------------------------------------------------------ -% RELEASES : -% 04/22/2020 - RNU - creation -% ------------------------------------------------------------------------------ -function generate_csv_file(a_logFileName, a_csvDirName) - -% output CSV file name -[~, logFileName, ~] = fileparts(a_logFileName); -csvFileName = [a_csvDirName '/' logFileName '.csv']; - - -% create CSV file -fidOut = fopen(csvFileName, 'wt'); -if (fidOut == -1) - fprintf('ERROR: Unable to create output file: %s\n', csvFileName); - return -end - -% put header -header = 'MESSAGE TYPE;MESSAGE SOURCE;MESSAGE CONTENT'; -fprintf(fidOut, '%s\n', header); - -if (~isempty(a_logFileName)) - % read log file - fId = fopen(a_logFileName, 'r'); - if (fId == -1) - sprintf('ERROR: Unable to open file: %s\n', a_logFileName); - return - end - fileContents = textscan(fId, '%s', 'delimiter', '\n'); - fclose(fId); - - if (~isempty(fileContents) && ~isempty(fileContents{:})) - % retrieve wanted messages - fileContents = fileContents{:}; - idLine = 1; - while (1) - line = fileContents{idLine}; - msgType = ''; - msgSource = ''; - msg = ''; - if (strncmp(line, 'INFO: ', length('INFO: '))) - msgType = 'INFO'; - msgSource = 'nc_create_synthetic_profile'; - msg = line(length('INFO: ')+1:end); - elseif (strncmp(line, 'WARNING: ', length('WARNING: '))) - msgType = 'WARNING'; - msgSource = 'nc_create_synthetic_profile'; - msg = line(length('WARNING: ')+1:end); - elseif (strncmp(line, 'ERROR: ', length('ERROR: '))) - msgType = 'ERROR'; - msgSource = 'nc_create_synthetic_profile'; - msg = line(length('ERROR: ')+1:end); - elseif (strncmp(line, 'S-PROF_INFO: ', length('S-PROF_INFO: '))) - msgType = 'INFO'; - msgSource = 'ARGO_simplified_profile'; - msg = line(length('S-PROF_INFO: ')+1:end); - elseif (strncmp(line, 'S-PROF_WARNING: ', length('S-PROF_WARNING: '))) - msgType = 'WARNING'; - msgSource = 'ARGO_simplified_profile'; - msg = line(length('S-PROF_WARNING: ')+1:end); - elseif (strncmp(line, 'S-PROF_ERROR: ', length('S-PROF_ERROR: '))) - msgType = 'ERROR'; - msgSource = 'ARGO_simplified_profile'; - msg = line(length('S-PROF_ERROR: ')+1:end); - end - - if (~isempty(msgType)) - fprintf(fidOut, '%s;%s;%s\n', msgType, msgSource, msg); - end - - idLine = idLine + 1; - if (idLine > length(fileContents)) - break - end - end - end -end - -fclose(fidOut); - -return diff --git a/decArgo_soft/soft/util/sub/nc_create_synthetic_profile_.m b/decArgo_soft/soft/util/sub/nc_create_synthetic_profile_.m index 885d8a54..1f640e45 100644 --- a/decArgo_soft/soft/util/sub/nc_create_synthetic_profile_.m +++ b/decArgo_soft/soft/util/sub/nc_create_synthetic_profile_.m @@ -134,6 +134,13 @@ function nc_create_synthetic_profile_( ... global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_inputFile; + onlyCFileFlag = 0; onlyBFileFlag = 0; @@ -162,15 +169,27 @@ function nc_create_synthetic_profile_( ... wantedVars = [ ... {'FORMAT_VERSION'} ... {'STATION_PARAMETERS'} ... + {'DATA_CENTRE'} ... ]; [profData1] = get_data_from_nc_file(profFilePathName, wantedVars); formatVersion = deblank(get_data_from_name('FORMAT_VERSION', profData1)'); + dataCentre = get_data_from_name('DATA_CENTRE', profData1); + g_cocs_dacName = dataCentre(:, 1)'; % check the PROF file format version if (~strcmp(formatVersion, '3.1')) fprintf('ERROR: Float #%d Cycle #%d%c: Input PROF file (%s) format version is %s => not used\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, profFilePathName, formatVersion); + + % CSV output + msgType = 'error'; + message = sprintf('Input file format version is %s - not used.', formatVersion); + [~, fileName, fileExt] = fileparts(profFilePathName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end @@ -349,6 +368,15 @@ function nc_create_synthetic_profile_( ... else fprintf('ERROR: Float #%d Cycle #%d%c: PARAMETER_DATA_MODE information is missing in input PROF file (%s) => exit (as DATA_MODE = ''%c'')\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, profFilePathName, dataMode(idProf)); + + % CSV output + msgType = 'error'; + message = sprintf('PARAMETER_DATA_MODE information is missing in file - file ignored (as DATA_MODE = ''%c'').', dataMode(idProf)); + [~, fileName, fileExt] = fileparts(profFilePathName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end end @@ -416,6 +444,17 @@ function nc_create_synthetic_profile_( ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, ... length(profData.presData), ... length(profDataTabB(idProfB).presData)); + + % CSV output + msgType = 'error'; + message = sprintf('C and B files don''t have the same number of levels (%d vs %d) - files ignored.', ... + length(profData.presData), ... + length(profDataTabB(idProfB).presData)); + [~, fileName, fileExt] = fileparts(a_bProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end if (~any((profData.presData - profDataTabB(idProfB).presData) ~= 0)) @@ -469,6 +508,16 @@ function nc_create_synthetic_profile_( ... if (~isempty(profDataTabB)) fprintf('WARNING: Float #%d Cycle #%d%c: %d B profiles are not used\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, length(profDataTabB)); + + % CSV output + msgType = 'warning'; + message = sprintf('%d B profiles are not used.', ... + length(profDataTabB)); + [~, fileName, fileExt] = fileparts(a_bProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end elseif (~isempty(profDataTabC)) @@ -508,6 +557,14 @@ function nc_create_synthetic_profile_( ... % output parameters initialization o_ncData = []; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_cycleDir; +global g_cocs_inputFile; + if (exist(a_ncPathFileName, 'file') == 2) @@ -515,6 +572,15 @@ function nc_create_synthetic_profile_( ... fCdf = netcdf.open(a_ncPathFileName, 'NC_NOWRITE'); if (isempty(fCdf)) fprintf('ERROR: Unable to open NetCDF input file: %s\n', a_ncPathFileName); + + % CSV output + msgType = 'error'; + message = 'Unable to open file.'; + [~, fileName, fileExt] = fileparts(a_ncPathFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end @@ -598,6 +664,14 @@ function nc_create_synthetic_profile_( ... % output parameters initialization o_ncDataAtt = []; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_cycleDir; +global g_cocs_inputFile; + if (exist(a_ncPathFileName, 'file') == 2) @@ -605,6 +679,15 @@ function nc_create_synthetic_profile_( ... fCdf = netcdf.open(a_ncPathFileName, 'NC_NOWRITE'); if (isempty(fCdf)) fprintf('ERROR: Unable to open NetCDF input file: %s\n', a_ncPathFileName); + + % CSV output + msgType = 'error'; + message = 'Unable to open file.'; + [~, fileName, fileExt] = fileparts(a_ncPathFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end @@ -768,117 +851,260 @@ function nc_create_synthetic_profile_( ... global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_inputFile; + + +msgType = 'error'; +[~, fileName, fileExt] = fileparts(a_bProfFileName); +g_cocs_inputFile = [fileName fileExt]; % check input profile consistency errorFlag = 0; if (length(unique({a_profData.handbookVersion})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple HANDBOOK_VERSION => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple HANDBOOK_VERSION - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.referenceDateTime})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple REFERENCE_DATE_TIME => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple REFERENCE_DATE_TIME - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.platformNumber})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple PLATFORM_NUMBER => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple PLATFORM_NUMBER - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.projectName})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple PROJECT_NAME => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple PROJECT_NAME - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.piName})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple PI_NAME => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple PI_NAME - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.cycleNumber])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple CYCLE_NUMBER => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple CYCLE_NUMBER - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.direction})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple DIRECTION => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple DIRECTION - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.dataCentre})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple DATA_CENTRE => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple DATA_CENTRE - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.platformType})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple PLATFORM_TYPE => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple PLATFORM_TYPE - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.floatSerialNo})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple FLOAT_SERIAL_NO => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple FLOAT_SERIAL_NO - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.firmwareVersion})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple FIRMWARE_VERSION => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple FIRMWARE_VERSION - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.wmoInstType})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple WMO_INST_TYPE => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple WMO_INST_TYPE - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.juld])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple JULD => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple JULD - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.juldResolution])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple JULD:resolution => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple JULD:resolution - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.juldQc})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple JULD_QC => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple JULD_QC - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.juldLocation])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple JULD_LOCATION => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple JULD_LOCATION - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.juldLocationResolution])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple JULD_LOCATION:resolution => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple JULD_LOCATION:resolution - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.latitude])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple LATITUDE => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple LATITUDE - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.longitude])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple LONGITUDE => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple LONGITUDE - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.positionQc})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple POSITION_QC => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple POSITION_QC - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique({a_profData.positioningSystem})) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple POSITIONING_SYSTEM => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple POSITIONING_SYSTEM - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (length(unique([a_profData.configMissionNumber])) > 1) fprintf('ERROR: Float #%d Cycle #%d%c: multiple CONFIG_MISSION_NUMBER => file ignored\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + message = 'Multiple CONFIG_MISSION_NUMBER - file ignored.'; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + errorFlag = 1; end if (errorFlag == 1) @@ -939,6 +1165,15 @@ function nc_create_synthetic_profile_( ... [~, bProfFileName, bProfFileExt] = fileparts(a_bProfFileName); fprintf('ERROR: Float #%d Cycle #%d%c: the synthetic profile data processing failed (ARGO_simplified_profile fonction on file %s)\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, [bProfFileName bProfFileExt]); + + % CSV output + msgType = 'error'; + message = 'The synthetic profile data processing failed (ARGO_simplified_profile fonction).'; + [~, fileName, fileExt] = fileparts(a_bProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + o_syntProfData = []; % write error information in log file @@ -953,8 +1188,17 @@ function nc_create_synthetic_profile_( ... end if (isempty(syntProfData)) - fprintf('INFO: Float #%d Cycle #%d%c: no synthetic profile data reported by ARGO_simplified_profile fonction\n', ... + fprintf('ERROR: Float #%d Cycle #%d%c: no synthetic profile data reported by ARGO_simplified_profile fonction\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + msgType = 'error'; + message = 'No synthetic profile data reported by ARGO_simplified_profile fonction.'; + [~, fileName, fileExt] = fileparts(a_bProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + o_syntProfData = []; return end @@ -977,6 +1221,15 @@ function nc_create_synthetic_profile_( ... fprintf('ERROR: Float #%d Cycle #%d%c: ''%s'' parameter is not present in the output file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, ... paramName); + + % CSV output + msgType = 'error'; + message = sprintf('''%s'' parameter is not present in output file.', paramName); + [~, fileName, fileExt] = fileparts(a_bProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + continue end data = syntProfData.(paramName).value; @@ -1111,8 +1364,17 @@ function nc_create_synthetic_profile_( ... if (isempty(o_syntProfData.paramData)) - fprintf('INFO: Float #%d Cycle #%d%c: no data remain after processing => no synthetic profile\n', ... + fprintf('ERROR: Float #%d Cycle #%d%c: no data remain after processing => no synthetic profile\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir); + + % CSV output + msgType = 'error'; + message = 'No data remain after processing - no synthetic profile.'; + [~, fileName, fileExt] = fileparts(a_bProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + o_syntProfData = []; end @@ -1356,6 +1618,13 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_inputFile; + % common long_name for nc files global g_decArgo_longNameOfParamAdjErr; @@ -1377,6 +1646,15 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) if (isempty(fCdf)) fprintf('ERROR: Float #%d Cycle #%d%c: Unable to open NetCDF output file: %s\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, a_fileName); + + % CSV output + msgType = 'error'; + message = 'Unable to open file.'; + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end @@ -1391,6 +1669,14 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) if (isempty(deblank(institution))) fprintf('WARNING: Float #%d Cycle #%d%c: No institution assigned to data centre %s\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, a_profData.dataCentre); + + % CSV output + msgType = 'warning'; + message = sprintf('No institution assigned to data centre %s.', a_profData.dataCentre); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end netcdf.putAtt(fCdf, globalVarId, 'institution', institution); netcdf.putAtt(fCdf, globalVarId, 'source', 'Argo float'); @@ -1481,8 +1767,16 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) netcdf.putAtt(fCdf, paramVarId, 'axis', paramInfo.axis); end else - fprintf('ERROR: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... + fprintf('WARNING: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, paramName); + + % CSV output + msgType = 'warning'; + message = sprintf('Parameter ''%s'' already exists in file.', paramName); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end % parameter QC variable and attributes @@ -1502,8 +1796,16 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) netcdf.putAtt(fCdf, paramQcVarId, '_FillValue', ' '); end else - fprintf('ERROR: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... + fprintf('WARNING: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, paramQcName); + + % CSV output + msgType = 'warning'; + message = sprintf('Parameter ''%s'' already exists in file.', paramQcName); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end % parameter displacement variable and attributes @@ -1526,8 +1828,16 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) netcdf.putAtt(fCdf, paramDPresVarId, 'units', paramPresInfo.units); end else - fprintf('ERROR: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... + fprintf('WARNING: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, paramDPresName); + + % CSV output + msgType = 'warning'; + message = sprintf('Parameter ''%s'' already exists in file.', paramDPresName); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end end @@ -1575,8 +1885,16 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) netcdf.putAtt(fCdf, paramAdjVarId, 'axis', paramInfo.axis); end else - fprintf('ERROR: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... + fprintf('WARNING: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, paramAdjName); + + % CSV output + msgType = 'warning'; + message = sprintf('Parameter ''%s'' already exists in file.', paramAdjName); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end % parameter adjusted QC variable and attributes @@ -1596,8 +1914,16 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) netcdf.putAtt(fCdf, paramAdjQcVarId, '_FillValue', ' '); end else - fprintf('ERROR: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... + fprintf('WARNING: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, paramAdjQcName); + + % CSV output + msgType = 'warning'; + message = sprintf('Parameter ''%s'' already exists in file.', paramAdjQcName); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end % parameter adjusted error variable and attributes @@ -1630,8 +1956,16 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) netcdf.putAtt(fCdf, paramAdjErrVarId, 'resolution', paramInfo.resolution); end else - fprintf('ERROR: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... + fprintf('WARNING: Float #%d Cycle #%d%c: Parameter ''%s'' already exists in the nc file\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, paramAdjErrName); + + % CSV output + msgType = 'warning'; + message = sprintf('Parameter ''%s'' already exists in file.', paramAdjErrName); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end end @@ -1744,6 +2078,7 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) % fill PARAM variable data for idParam = 1:length(paramList) + paramDataMode = a_profData.paramDataMode(idParam); paramData = a_profData.paramData(:, idParam); paramDataQc = a_profData.paramDataQc(:, idParam); paramDataDPres = a_profData.paramDataDPres(:, idParam); @@ -1761,7 +2096,11 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) paramAdjErrName = [paramName '_ADJUSTED_ERROR']; % global quality of PARAM profile - profParamQcData = compute_profile_quality_flag(paramDataQc); + if (paramDataMode == 'R') + profParamQcData = compute_profile_quality_flag(paramDataQc); + else + profParamQcData = compute_profile_quality_flag(paramDataAdjQc); + end profParamQcName = ['PROFILE_' paramName '_QC']; netcdf.putVar(fCdf, netcdf.inqVarID(fCdf, profParamQcName), 0, 1, profParamQcData); @@ -1856,6 +2195,13 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_inputFile; + floatWmoStr = num2str(g_cocs_floatNum); @@ -1877,7 +2223,8 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) for idCy = 1:length(cyNumList) g_cocs_cycleNum = cyNumList(idCy); - + g_cocs_cycleNumStr = num2str(g_cocs_cycleNum); + % process descending and ascending profiles for idDir = 1:2 @@ -1943,10 +2290,26 @@ function fill_synthetic_mono_profile_file(a_fileName, a_profData) global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_inputFile; + if ~(exist(a_sProfFileName, 'file') == 2) fprintf('ERROR: Float #%d Cycle #%d%c: File not found: %s\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, a_sProfFileName); + + % CSV output + msgType = 'error'; + message = 'File not found.'; + [~, fileName, fileExt] = fileparts(a_sProfFileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end @@ -2294,6 +2657,13 @@ function fill_synthetic_multi_profiles_file(a_fileName, a_profData) global g_cocs_cycleNum; global g_cocs_cycleDir; +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_inputFile; + % common long_name for nc files global g_decArgo_longNameOfParamAdjErr; @@ -2315,6 +2685,15 @@ function fill_synthetic_multi_profiles_file(a_fileName, a_profData) if (isempty(fCdf)) fprintf('ERROR: Float #%d Cycle #%d%c: Unable to open NetCDF output file: %s\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, a_fileName); + + % CSV output + msgType = 'error'; + message = 'Unable to open file.'; + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + return end @@ -2329,6 +2708,14 @@ function fill_synthetic_multi_profiles_file(a_fileName, a_profData) if (isempty(deblank(institution))) fprintf('WARNING: Float #%d Cycle #%d%c: No institution assigned to data centre %s\n', ... g_cocs_floatNum, g_cocs_cycleNum, g_cocs_cycleDir, a_profData(1).dataCentre); + + % CSV output + msgType = 'warning'; + message = sprintf('No institution assigned to data centre %s.', a_profData(1).dataCentre); + [~, fileName, fileExt] = fileparts(a_fileName); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end netcdf.putAtt(fCdf, globalVarId, 'institution', institution); netcdf.putAtt(fCdf, globalVarId, 'source', 'Argo float'); @@ -2631,6 +3018,7 @@ function fill_synthetic_multi_profiles_file(a_fileName, a_profData) % fill PARAM variable data for idParam = 1:length(paramList) + paramDataMode = profData.paramDataMode(idParam); paramData = profData.paramData(:, idParam); paramDataQc = profData.paramDataQc(:, idParam); paramDataDPres = profData.paramDataDPres(:, idParam); @@ -2648,7 +3036,11 @@ function fill_synthetic_multi_profiles_file(a_fileName, a_profData) paramAdjErrName = [paramName '_ADJUSTED_ERROR']; % global quality of PARAM profile - profParamQcData = compute_profile_quality_flag(paramDataQc); + if (paramDataMode == 'R') + profParamQcData = compute_profile_quality_flag(paramDataQc); + else + profParamQcData = compute_profile_quality_flag(paramDataAdjQc); + end profParamQcName = ['PROFILE_' paramName '_QC']; netcdf.putVar(fCdf, netcdf.inqVarID(fCdf, profParamQcName), profPos, 1, profParamQcData); @@ -2711,3 +3103,87 @@ function fill_synthetic_multi_profiles_file(a_fileName, a_profData) netcdf.close(fCdf); return + +% ------------------------------------------------------------------------------ +% Remove a given diretory and all its contents. +% +% SYNTAX : +% [o_ok] = remove_directory(a_dirPathName) +% +% INPUT PARAMETERS : +% a_dirPathName : path name of the directory to remove +% +% OUTPUT PARAMETERS : +% +% EXAMPLES : +% +% SEE ALSO : +% AUTHORS : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com) +% ------------------------------------------------------------------------------ +% RELEASES : +% 01/25/2015 - RNU - creation +% ------------------------------------------------------------------------------ +function [o_ok] = remove_directory(a_dirPathName) + +% output parameters initialization +o_ok = 0; + +NB_ATTEMPTS = 10; + +if (exist(a_dirPathName, 'dir') == 7) + [status, ~, ~] = rmdir(a_dirPathName, 's'); + if (status ~= 1) + nbAttemps = 0; + while ((nbAttemps < NB_ATTEMPTS) && (status ~= 1)) + pause(1); + [status, ~, ~] = rmdir(a_dirPathName, 's'); + nbAttemps = nbAttemps + 1; + end + if (status ~= 1) + fprintf('ERROR: Unable to remove directory: %s\n', a_dirPathName); + return + end + end +end + +o_ok = 1; + +return + +% ------------------------------------------------------------------------------ +% Move file. +% +% SYNTAX : +% [o_ok] = move_file(a_sourceFileName, a_destFileName) +% +% INPUT PARAMETERS : +% a_sourceFileName : source file path name +% a_destFileName : destination file path name +% +% OUTPUT PARAMETERS : +% o_ok : copy operation report flag (1 if ok, 0 otherwise) +% +% EXAMPLES : +% +% SEE ALSO : +% AUTHORS : Jean-Philippe Rannou (Altran)(jean-philippe.rannou@altran.com) +% ------------------------------------------------------------------------------ +% RELEASES : +% 01/10/2014 - RNU - creation +% ------------------------------------------------------------------------------ +function [o_ok] = move_file(a_sourceFileName, a_destFileName) + +% output parameters initialization +o_ok = 1; + + +[status, message, messageid] = movefile(a_sourceFileName, a_destFileName); +if (status == 0) + fprintf('ERROR: Error while moving file %s to file %s (%s)\n', ... + a_sourceFileName, ... + a_destFileName, ... + message); + o_ok = 0; +end + +return diff --git a/decArgo_soft/soft/util/sub_foreign/ARGO_simplified_profile.m b/decArgo_soft/soft/util/sub_foreign/ARGO_simplified_profile.m index 1aca7dae..2f65a3f5 100644 --- a/decArgo_soft/soft/util/sub_foreign/ARGO_simplified_profile.m +++ b/decArgo_soft/soft/util/sub_foreign/ARGO_simplified_profile.m @@ -43,6 +43,13 @@ % all info messages, correct treatment of levels with QC '4' in % adjusted fields, add bgcFloatFlag as optional input +% output CSV file information +global g_cocs_fidCsvFile; +global g_cocs_dacName; +global g_cocs_floatWmoStr; +global g_cocs_cycleNumStr; +global g_cocs_cycleDir; +global g_cocs_inputFile; if nargin<1 || isempty(varargin) varargin{1}='bfilepath';varargin{2}='\argo\dac\coriolis\6901485\profiles\BR6901485_049.nc'; @@ -121,11 +128,31 @@ fnamec=setdiff(fieldnames(C),fieldnames(S)); % find core parameter names for i=1:length(fnamec), S.(fnamec{i})=C.(fnamec{i}); end % copy core data to bio data else - if verbose>-2, disp(['S-PROF_ERROR: File ' bfilestr '.nc: No corresponding core file found. Create empty s-profile.']), end + if (verbose>-2) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: No corresponding core file found. Create empty s-profile.']) + + % CSV output + msgType = 'warning_s-prof'; + message = 'No corresponding core file found. Create empty s-profile.'; + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end S.PRES_QC.value=ones(size(S.PRES.value))*4; % mimic core PRES_QC: all bad, because no info end if isfield(S,'empty') && bgcfloatflag - if verbose>-2, disp(['S-PROF_ERROR: File ' cfilestr '.nc: No corresponding bio file found. Use only the core file.']), end + if (verbose>-2) + disp(['S-PROF_WARNING: File ' cfilestr '.nc: No corresponding bio file found. Use only the core file.']) + + % CSV output + msgType = 'warning_s-prof'; + message = 'No corresponding bio file found. Use only the core file.'; + [~, fileName, fileExt] = fileparts(cfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end S=rmfield(S,'empty'); end @@ -141,7 +168,18 @@ try for i=1:length(indperm), indperm(i)=find(strcmpi(C.PARAMETER.dimname,indstr{i})); end catch me - if verbose>-1, disp(['S-PROF_WARNING: File ' cfilestr '.nc: Could not figure out N_DIMs order of core file PARAMETER field with dimensions: ' strjoin(C.PARAMETER.dimname,', ')]), end + if (verbose>-1) + disp(['S-PROF_WARNING: File ' cfilestr '.nc: Could not figure out N_DIMs order of core file PARAMETER field with dimensions: ' strjoin(C.PARAMETER.dimname,', ')]) + + % CSV output + msgType = 'warning_s-prof'; + message = sprintf('Could not figure out N_DIMs order of core file PARAMETER field with dimensions: %s.', ... + strjoin(C.PARAMETER.dimname,' ')); + [~, fileName, fileExt] = fileparts(cfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end indperm=1:ndims(C.PARAMETER.value); end C.PARAMETER.value=permute(C.PARAMETER.value,indperm); @@ -153,7 +191,18 @@ try for i=1:length(indperm), indperm(i)=find(strcmpi(C.STATION_PARAMETERS.dimname,indstr{i})); end catch me - if verbose>-1, disp(['S-PROF_WARNING: File ' cfilestr '.nc: Could not figure out N_DIMs order of core file STATION_PARAMETERS field with dimensions: ' strjoin(C.PARAMETER.dimname,', ')]), end + if (verbose>-1) + disp(['S-PROF_WARNING: File ' cfilestr '.nc: Could not figure out N_DIMs order of core file STATION_PARAMETERS field with dimensions: ' strjoin(C.PARAMETER.dimname,', ')]) + + % CSV output + msgType = 'warning_s-prof'; + message = sprintf('Could not figure out N_DIMs order of core file STATION_PARAMETERS field with dimensions: %s.', ... + strjoin(C.PARAMETER.dimname,' ')); + [~, fileName, fileExt] = fileparts(cfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end indperm=1:ndims(C.STATION_PARAMETERS.value); end C.STATION_PARAMETERS.value=permute(C.STATION_PARAMETERS.value,indperm); @@ -171,7 +220,18 @@ try for i=1:length(indperm), indperm(i)=find(strcmpi(S.PARAMETER.dimname,indstr{i})); end catch me - if verbose>-1, disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not figure out N_DIMs order of bio file PARAMETER field with dimensions: ' strjoin(S.PARAMETER.dimname,', ')]), end + if (verbose>-1) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not figure out N_DIMs order of bio file PARAMETER field with dimensions: ' strjoin(S.PARAMETER.dimname,', ')]) + + % CSV output + msgType = 'warning_s-prof'; + message = sprintf('Could not figure out N_DIMs order of bio file PARAMETER field with dimensions: %s.', ... + strjoin(S.PARAMETER.dimname,' ')); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end indperm=1:ndims(S.PARAMETER.value); end S.PARAMETER.value=permute(S.PARAMETER.value,indperm); @@ -183,7 +243,17 @@ try for i=1:length(indperm), indperm(i)=find(strcmpi(S.STATION_PARAMETERS.dimname,indstr{i})); end catch me - if verbose>-1, disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not figure out N_DIMs order of bio file STATION_PARAMETERS field with dimensions: ' strjoin(S.PARAMETER.dimname,', ')]), end + if (verbose>-1) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not figure out N_DIMs order of bio file STATION_PARAMETERS field with dimensions: ' strjoin(S.PARAMETER.dimname,', ')]) + + % CSV output + msgType = 'warning_s-prof'; + message = sprintf('Could not figure out N_DIMs order of bio file STATION_PARAMETERS field with dimensions: %s.', strjoin(S.PARAMETER.dimname,' ')); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end indperm=1:ndims(S.STATION_PARAMETERS.value); end S.STATION_PARAMETERS.value=permute(S.STATION_PARAMETERS.value,indperm); @@ -258,7 +328,17 @@ if isfield(S,'TEMP'), S=rmfield(S,'TEMP'); end if isfield(S,'PSAL'), S=rmfield(S,'PSAL'); end %} - if verbose>-2, disp(['S-PROF_ERROR: File ' bfilestr '.nc: PRES (bio) and PRES_QC (core) dimensions don''t match. Create synthetic profile only with available core data.']), end + if (verbose>-2) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: PRES (bio) and PRES_QC (core) dimensions don''t match. Create synthetic profile only with available core data.']) + + % CSV output + msgType = 'warning_s-prof'; + message = 'PRES (bio) and PRES_QC (core) dimensions don''t match. Create synthetic profile only with available core data.'; + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end S.PRES.value=int32(C.PRES.value); [noNLEVELs,noNPROFs]=size(S.PRES.value); for i=1:length(ubgcparams) @@ -278,7 +358,18 @@ end %pinversion=pinversion & ismember(S.PRES_QC.value,[0 1 2 3]); if any(pinversion(:)) - if verbose>1, disp(['S-PROF_INFO: File ' cfilestr '.nc: Found ' num2str(sum(pinversion(:))) ' levels with unflagged pressure inversions. Flag with PRES_QC=4.']), end + if (verbose>1) + disp(['S-PROF_INFO: File ' cfilestr '.nc: Found ' num2str(sum(pinversion(:))) ' levels with unflagged pressure inversions. Flag with PRES_QC=4.']) + + % CSV output + msgType = 'info_s-prof'; + message = sprintf('Found %s levels with unflagged pressure inversions. Flag with PRES_QC=4.', ... + num2str(sum(pinversion(:)))); + [~, fileName, fileExt] = fileparts(cfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end S.PRES_QC.value(pinversion)=4; % check if there are more pnum=0; @@ -294,7 +385,18 @@ pnum=pnum+sum(pinversion(:)); end end % while - if verbose>1 && pnum, disp(['S-PROF_INFO: File ' cfilestr '.nc: Found ' num2str(pnum) ' more levels with unflagged pressure inversions. Flag with PRES_QC=4.']), end + if (verbose>1 && pnum) + disp(['S-PROF_INFO: File ' cfilestr '.nc: Found ' num2str(pnum) ' more levels with unflagged pressure inversions. Flag with PRES_QC=4.']) + + % CSV output + msgType = 'info_s-prof'; + message = sprintf('Found %s more levels with unflagged pressure inversions. Flag with PRES_QC=4.', ... + num2str(pnum)); + [~, fileName, fileExt] = fileparts(cfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end end % first iteration clear pinversion ind pnum @@ -340,12 +442,31 @@ C=lov_netcdf_pickprod(metafilepath,infields); catch me % failed to locate meta file - if verbose>-2, disp(['S-PROF_ERROR: Float ' strtrim(S.PLATFORM_NUMBER.value(1,:)) ': Could not find meta file ' metafilepath '. Abort..']), end + if (verbose>-2) + disp(['S-PROF_ERROR: Float ' strtrim(S.PLATFORM_NUMBER.value(1,:)) ': Could not find meta file ' metafilepath '. Abort..']); + + % CSV output + msgType = 'error'; + message = 'File not found.'; + [~, fileName, fileExt] = fileparts(metafilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end synthfull=[]; return end if isempty(C) - if verbose>-2, disp(['S-PROF_ERROR: Float ' strtrim(S.PLATFORM_NUMBER.value(1,:)) ': Could not find meta file ' strtrim(S.PLATFORM_NUMBER.value(1,:)) '_meta.nc in current or parent folder. Abort..']), end + if (verbose>-2) + disp(['S-PROF_ERROR: Float ' strtrim(S.PLATFORM_NUMBER.value(1,:)) ': Could not find meta file ' strtrim(S.PLATFORM_NUMBER.value(1,:)) '_meta.nc in current or parent folder. Abort..']); + + % CSV output + msgType = 'error'; + message = 'File not found.'; + g_cocs_inputFile = [strtrim(S.PLATFORM_NUMBER.value(1,:)) '_meta.nc']; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end synthfull=[]; return end % meta file exists @@ -387,14 +508,35 @@ ind=find(~cellfun(@isempty,strfind(cellstr(lower(names)),lower(cnames{1})))); % ignore upper/lower case if any(ind) - if verbose>1, disp(['S-PROF_INFO: File ' metafilestr '.nc: Found ' num2str(length(ind)) ' VerticalOffsets']); end + if (verbose>1) + disp(['S-PROF_INFO: File ' metafilestr '.nc: Found ' num2str(length(ind)) ' VerticalOffsets']) + + % CSV output + msgType = 'info_s-prof'; + message = sprintf('Found %s VerticalOffsets.', ... + num2str(length(ind))); + [~, fileName, fileExt] = fileparts(metafilestr); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end % get short sensor names and vertical offsets cpnames=strrep(strrep(cellstr(lower(names(ind,:))),lower(cnames{1}),''),lower('CONFIG_'),''); voffset=values(ind); try % get corresponding full-length sensor name: index to param_sensors / sensors - sensorind=cellfun(@(x)find(~cellfun(@isempty,strfind(lower(sensors),lower(x)))),cpnames); + sensorind=cellfun(@(x)find(~cellfun(@isempty,strfind(lower(sensors),lower(x)))),cpnames); catch me - if verbose>0, disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not identify some short sensor name in meta file ' strjoin(cpnames,'; ')]), end + if (verbose>0) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not identify some short sensor name in meta file ' strjoin(cpnames,'; ')]) + + % CSV output + msgType = 'warning_s-prof'; + message = sprintf('Could not identify some short sensor name in meta file %s.', strjoin(cpnames,' ')); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end end % and assign vertical offset via full-length sensor name to % bgc parameters @@ -420,7 +562,18 @@ %keyboard %synthfull=[]; %return - if verbose>0, disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not identify parameter with sensor name(s) ' strjoin(cellstr(snames),', ') '; Skipping vertical offset of ' num2str(voffset(i)) ' dbar from LAUNCH_CONFIG']), end + if (verbose>0) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not identify parameter with sensor name(s) ' strjoin(cellstr(snames),', ') '; Skipping vertical offset of ' num2str(voffset(i)) ' dbar from LAUNCH_CONFIG']) + + % CSV output + msgType = 'warning_s-prof'; + message = sprintf('Could not identify parameter with sensor name(s) %s. Skipping vertical offset of %s dbar from LAUNCH_CONFIG.', ... + strjoin(cellstr(snames),' '), num2str(voffset(i))); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end else % found pnames=C.PARAMETER.value(pind); % get i- and b- parameter names @@ -441,12 +594,33 @@ voff.linbgcparams=reshape(linbgcparams,1,[]); voff.linvoffset=reshape(linvoffset,1,[]); clear inpflag cpnames sensorind voffset sensors param_sensors else - if verbose>1, disp(['S-PROF_INFO: File ' bfilestr '.nc: Found no verticalOffsets in meta file']), end + if (verbose>1) + disp(['S-PROF_INFO: File ' bfilestr '.nc: Found no verticalOffsets in meta file']) + + % CSV output + msgType = 'info_s-prof'; + message = 'Found no VerticalOffsets in meta file.'; + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end voff.linbgcparams={};voff.linvoffset=[]; end % config name found clear ind cnames names values else - if verbose>-1, disp(['S-PROF_INFO: File ' bfilestr '.nc: Could not find LAUNCH_CONFIG_PARAMETER_NAME in meta file (FORMAT_VERSION ' C.FORMAT_VERSION.value '). No vertical sensor offsets corrected.']), end + if (verbose>-1) + disp(['S-PROF_INFO: File ' bfilestr '.nc: Could not find LAUNCH_CONFIG_PARAMETER_NAME in meta file (FORMAT_VERSION ' C.FORMAT_VERSION.value '). No vertical sensor offsets corrected.']) + + % CSV output + msgType = 'info_s-prof'; + message = sprintf('Could not find LAUNCH_CONFIG_PARAMETER_NAME in meta file (FORMAT_VERSION %s). No vertical sensor offsets corrected.', ... + C.FORMAT_VERSION.value); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end voff.linbgcparams={};voff.linvoffset=[]; end % LAUNCH_CONFIG_PARAMETER_NAME end % addoffsetflag @@ -465,8 +639,25 @@ if verbose>0 if isempty(ubgcparams) disp(['S-PROF_WARNING: File ' bfilestr '.nc: Found no b-parameters. Create synthetic profile only with available core data.']) + + % CSV output + msgType = 'warning'; + message = 'Found no b-parameters. Create synthetic profile only with available core data.'; + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); else disp(['S-PROF_WARNING: File ' bfilestr '.nc: Found b-parameter(s) ' strjoin(ubgcparams,' ') ', but without any PRES_QC=0..3 and non-FillValue BGC data. Create synthetic profile only with available core data.']) + + % CSV output + msgType = 'warning'; + message = sprintf('Found b-parameter(s) %s but without any PRES_QC=0..3 and non-FillValue BGC data. Create synthetic profile only with available core data.', ... + strjoin(ubgcparams,' ')); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); end end %synthfull=[]; return @@ -479,7 +670,18 @@ % verify that there are BGC observations, not just BGC N_PROFs if ~any(prespresent(:)) % may not be needed; redundant - if verbose>0, disp(['S-PROF_WARNING: File ' bfilestr '.nc: Found b-parameter(s) ' strjoin(ubgcparams,' ') ', but without any non-FillValue data. Create synthetic profile only with available core data.']), end + if (verbose>0) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Found b-parameter(s) ' strjoin(ubgcparams,' ') ', but without any non-FillValue data. Create synthetic profile only with available core data.']) + + % CSV output + msgType = 'warning'; + message = sprintf('Found b-parameter(s) %s but without any non-FillValue data. Create synthetic profile only with available core data.', ... + strjoin(ubgcparams,' ')); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end %synthfull=[]; return presaxis=[]; % default to empty presaxis break % extra loop around presaxis construction @@ -525,7 +727,17 @@ i=ind(find(max(flipud(cumsum(flipud(obspresence),1)),[],2)>1,1,'last')); if isempty(i) %keyboard % should not happen?? Check code.. - if verbose>-3, disp(['S-PROF_ERROR: File ' bfilestr '.nc: Trouble during creation of synthetic pressure axis. Create synthetic profile only with available core data.']), end + if (verbose>-3) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Trouble during creation of synthetic pressure axis. Create synthetic profile only with available core data.']) + + % CSV output + msgType = 'warning'; + message = 'Trouble during creation of synthetic pressure axis. Create synthetic profile only with available core data.'; + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end %synthfull=[]; return useind=[]; % default to empty presaxis if failed break % loop of pressure levels from bottom @@ -540,9 +752,19 @@ end clear obspresence if niter>nitermax - if verbose>-3, disp(['S-PROF_ERROR: File ' bfilestr '.nc: Exceeded maximum number of iterations in selection of synthetic pressure levels. Should not happen... Create synthetic profile only with available core data.']), end - %synthfull=[]; return - useind=[]; % default to empty presaxis if failed + if (verbose>-3) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Exceeded maximum number of iterations in selection of synthetic pressure levels. Should not happen... Create synthetic profile only with available core data.']) + + % CSV output + msgType = 'warning'; + message = 'Exceeded maximum number of iterations in selection of synthetic pressure levels. Should not happen... Create synthetic profile only with available core data.'; + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end + %synthfull=[]; return + useind=[]; % default to empty presaxis if failed break % loop of pressure levels from bottom end end @@ -570,7 +792,18 @@ % and bring into order but keeping nprof 1 at first position [~,asort]=sort(nprofstr(2:end));asort=[1 asort+1]; else % pre-v3.1 meta file - if verbose>0, disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not find PARAMETER_SENSOR in meta file (FORMAT_VERSION ' C.FORMAT_VERSION.value '). Kept N_PROF order as in profile file.']), end + if (verbose>0) + disp(['S-PROF_WARNING: File ' bfilestr '.nc: Could not find PARAMETER_SENSOR in meta file (FORMAT_VERSION ' C.FORMAT_VERSION.value '). Kept N_PROF order as in profile file.']) + + % CSV output + msgType = 'warning'; + message = sprintf('Could not find PARAMETER_SENSOR in meta file (FORMAT_VERSION %s). Kept N_PROF order as in profile file.', ... + C.FORMAT_VERSION.value); + [~, fileName, fileExt] = fileparts(bfilepath); + g_cocs_inputFile = [fileName fileExt]; + fprintf(g_cocs_fidCsvFile, '%s,%s,%s,%s%s,%s,%s\n', ... + g_cocs_dacName, msgType, g_cocs_floatWmoStr, g_cocs_cycleNumStr, g_cocs_cycleDir, message, g_cocs_inputFile); + end asort=1:noNPROFs; end % define N_PROF priority