diff --git a/@netcdf_native/tsgqc_netcdf.csv b/@netcdf_native/tsgqc_netcdf.csv index db3a2f4f8dc1f216a2720d5aeebd4a19fe067c64..4db662839fa939c6952eeb9e49e0d214ea60453e 100644 --- a/@netcdf_native/tsgqc_netcdf.csv +++ b/@netcdf_native/tsgqc_netcdf.csv @@ -18,9 +18,9 @@ $DIMENSIONS$ $VARIABLES$ #;key__;dimension__;type__;long_name;standard_name;units;conventions;valid_min;valid_max;format;FillValue_;epic_code;axis;resolution;comment;default_value;coordinate;# #;char;cell;char;char;char;char;char;double;double;char;double;double;char;double;char;double;char;# -#;REFERENCE_DATE_TIME;'STRING14';char;ORIGIN OF TIME;;;yyyymmddhhmmss;;;;;;;;Reference date for julian days origin;;;# -#;DATE;'DAYD','STRING14';char;DATE OF MAIN INSTRUMENT MEASUREMENT;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost;;DAYD;# -#;DATE_EXT;'DAYD_EXT','STRING14';char;DATE OF EACH EXTERNAL DATA MEASUREMENT;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost;;DAYD_EXT;# +#;REFERENCE_DATE_TIME;'STRING14';char;ORIGIN OF TIME;;;yyyymmddHHMMSS;;;;;;;;Reference date for julian days origin. The recommended reference date time is "19500101T000000Z": January 1st 1950 00:00:00;;;# +#;DATE;'DAYD','STRING14';char;DATE OF MAIN INSTRUMENT MEASUREMENT;;;yyyymmddHHMMSS;;;;;;;;This is the original data describing the date, it must not be lost;;DAYD;# +#;DATE_EXT;'DAYD_EXT','STRING14';char;DATE OF EACH EXTERNAL DATA MEASUREMENT;;;yyyymmddHHMMSS;;;;;;;;This is the original data describing the date, it must not be lost;;DAYD_EXT;# #;DAYD;'DAYD';double;DECIMAL JULIAN DAY (UTC) OF EACH MEASUREMENT;time;days since REFERENCE_DATE_TIME;Relative julian days with decimal part (as parts of the day);0;36600;%11.5f;;601;T;;Julian day of the measurement since REFERENCE_DATE_TIME;;DAYD;# #;DAYD_EXT;'DAYD_EXT';double;DECIMAL JULIAN DAY (UTC) OF EXTERNAL DATA MEASUREMENT;time;days since REFERENCE_DATE_TIME;Relative julian days with decimal part (as parts of the day);0;36600;%11.5f;;601;T;;Julian day of the measurement since REFERENCE_DATE_TIME;;DAYD_EXT;# #;LATX;'DAYD';float;LATITUDE OF EACH MEASUREMENT;latitude;degree_north;;-90;90;%+8.4f;99999;500;Y;;Latitude of the measurement (decimal);;DAYD;# @@ -84,7 +84,7 @@ $VARIABLES$ #;SSPS_EXT;'DAYD_EXT';float;SEA SURFACE SALINITY FROM EXTERNAL DATA;sea_surface_salinity;;;0;40;%6.3f;99999;;;0.001;Sea Surface Salinity (SSS) from external data instrument (WS,ARGO,CTD, XBT);;DAYD_EXT;# #;SSPS_EXT_QC;'DAYD_EXT';byte;SEA SURFACE SALINITY FROM EXTERNAL DATA QUALITY FLAG;;;;0;9;%1d;;;;;Quality flag applied on external sea surface salinity data values;0;DAYD_EXT;# #;SSPS_EXT_TYPE;'DAYD_EXT','STRING4';char;TYPE OF EXTERNAL SEA SURFACE SALINITY DATA ORIGIN;;;;;;;;;;;WS (Water Sample),ARGO,CTD,XBT,...;;DAYD_EXT;# -#;SSPS_EXT_ANALDATE;'DAYD_EXT','STRING14';char;DATE OF WATER SAMPLE SURFACE SALINITY ANALYSIS;;;yyyymmddhhmmss;;;;;;;;Date of sea surface salinity water sample analysis;;DAYD_EXT;# +#;SSPS_EXT_ANALDATE;'DAYD_EXT','STRING14';char;DATE OF WATER SAMPLE SURFACE SALINITY ANALYSIS;;;yyyymmddHHMMSS;;;;;;;;Date of sea surface salinity water sample analysis;;DAYD_EXT;# #;SSPS_EXT_BOTTLE;'DAYD_EXT','STRING4';char;SEA SURFACE SALINITY BOTTLE NUMBER;;;;;;;;;;;Number of sea surface salinity water sample;;DAYD_EXT;# % $ATTRIBUTES$ @@ -96,25 +96,25 @@ $ATTRIBUTES$ #;PROJECT_NAME;PROJECT NAME:;;popupmenu;ORE-SSS|CORIOLIS|IRD|SISMER|SURVOSRAL|TSG_Recherche;1;0.1;0.02;;right;Name of project which operates the TSG line, ex: ORE-SSS;# #;SHIP_CALL_SIGN;SHIP CALL SIGN:;;edit;;;;;;right;Ship call sign;# #;SHIP_MMSI;SHIP MMSI:;;edit;;;;;;right;Ship MMSI (ASN) number;# -#;DATE_TSG;TSG INSTALL DATE;;edit;;;;;;right;TSG installation date;# +#;DATE_TSG;TSG INSTALL DATE;;edit;;;;;;right;TSG installation date, format: yyyymmdd;# #;TYPE_TSG;TYPE TSG:;;popupmenu;SBE21|SBE45|UNKNO;1;0.1;0.02;;right;Thermosalinograph model number;# #;NUMBER_TSG;NUMBER TSG:;;edit;;;;;;right;TSG serial number;# -#;DATE_TINT;TINT INSTALL DATE;;edit;;;;;;right;TINT installation date;# +#;DATE_TINT;TINT INSTALL DATE;;edit;;;;;;right;TINT installation date, format: yyyymmdd;# #;TYPE_TINT;TYPE TINT:;;popupmenu;SBE38|SBE3S|UNKNO|NA;1;0.1;0.02;;right;External sea surface temperature sensor;# #;NUMBER_TINT;NUMBER TINT:;;edit;;;;;;right;External temperature sensor serial number;# #;DATA_TYPE;DATA TYPE:;;popupmenu;TRAJECTORY|PROFIL|TIME_SERIE;1;;;;right;Describe data type contained in file, eg: TRAJECTORY, PROFIL or TIME_SERIE;# #;DATA_MODE;DATA MODE:;;popupmenu;Delayed mode data|Real time data;1;0.1;0.02;;right;Indicate if the file contains real time or delayed mode data;# #;SAMPLING_PERIOD;SAMPLING PERIOD:;;edit;300;;0.050000001;;;right;Sampling period in seconds: 6 to 3600;# -#;DATE_START;DATE_START:;yyyymmddhhmnss;edit;;;;;;right;Date of first measurements;# -#;DATE_END;DATE END:;yyyymmddhhmnss;edit;;;;;;right;Date of last measurements;# +#;DATE_START;DATE_START:;yyyymmddHHMMSS;edit;;;;;;right;Date of first measurements, format: yyyymmddHHMMSS;# +#;DATE_END;DATE END:;yyyymmddHHMMSS;edit;;;;;;right;Date of last measurements, format: yyyymmddHHMMSS;# #;SOUTH_LATX;SOUTH LATX:;;edit;;;;;;right;South limit of measurements;# #;NORTH_LATX;NORTH LATX:;;edit;;;;;;right;North limit of measurements;# #;WEST_LONX;WEST LONX:;;edit;;;;;;right;West limit of measurements;# #;EAST_LONX;EAST LONX:;;edit;;;;;;right;East limit of measurements;# #;FORMAT_VERSION;FORMAT VERSION:;;popupmenu;1.6|2.0;2;0.1;0.02;;right;File format version;# #;CONVENTIONS;CONVENTIONS:;;popupmenu;GOSUD 1.6, CF1.4|GOSUD 2.0, CF1.4;2;0.1;0.02;;right;NetCDF file format conventions;# -#;DATE_CREATION;DATE CREATION:;yyyymmddhhmnss;edit;;;;;;right;Date and time of file creation, format: YYYYMMDDHHMISS;# -#;DATE_UPDATE;DATE UPDATE:;yyyymmddhhmnss;edit;;;;;;right;Date and time of file update, format: YYYYMMDDHHMISS;# +#;DATE_CREATION;DATE CREATION:;yyyymmddHHMMSS;edit;;;;;;right;Date and time of file creation, format: yyyymmddHHMMSS;# +#;DATE_UPDATE;DATE UPDATE:;yyyymmddHHMMSS;edit;;;;;;right;Date and time of file update, format: yyyymmddHHMMSS;# #;DATA_RESTRICTIONS;DATA RESTRICTIONS:;;edit;NONE;;;;;right;Restriction on use for these data;# #;CITATION;CITATION:;;edit;;;;;;left;This citation should be used for publications;# #;COMMENT;COMMENT:;;edit;;;;;;right;;# diff --git a/@netcdf_native/tsgqc_netcdf.xls b/@netcdf_native/tsgqc_netcdf.xls index 2186644bd03a6d4b2bd6fc8ca78d98b42b5c7cee..f1985238454f3b396d4d1ee95da4cfd8dd8621b1 100644 Binary files a/@netcdf_native/tsgqc_netcdf.xls and b/@netcdf_native/tsgqc_netcdf.xls differ diff --git a/TSGQC_amelioration.xls b/TSGQC_amelioration.xls index ac69762074abe3ba3064eb156382fa0365348fdc..8820a2a76098ebabfdd13c9a1077593594ea7a5a 100644 Binary files a/TSGQC_amelioration.xls and b/TSGQC_amelioration.xls differ diff --git a/tsg_io/readArgoLocean.m b/tsg_io/readArgoLocean.m index bf30259b95c2e523f496c78c99d43f4b7dc1f94e..e2ebd73385985b6e3e02ab588ee02462a3679d22 100644 --- a/tsg_io/readArgoLocean.m +++ b/tsg_io/readArgoLocean.m @@ -74,7 +74,8 @@ argo.DAYD_EXT = argo.DAYD_EXT + data(:,17); % Convert date in character. % ------------------------------------------------------ -argo.DATE_EXT = datestr( argo.DAYD_EXT, 'yyyymmddHHMMSS' ); +argo.DATE_EXT = datestr( argo.DAYD_EXT,... + tsg.preference.date_format_variable ); argo.LONX_EXT = data(:, 7); argo.LATX_EXT = data(:, 8); diff --git a/tsg_io/readAsciiSample.m b/tsg_io/readAsciiSample.m index 39a09d87825007ec2e0e5fed93ee903ee1afb4a7..6b870067580f255598b0cd1005d280b34ae656bf 100644 --- a/tsg_io/readAsciiSample.m +++ b/tsg_io/readAsciiSample.m @@ -175,19 +175,9 @@ ss = double( s.(char(header(6))) ); s.DAYD_EXT = datenum(yy, mm, dd, hh, mi, ss); -% Convert date in character. This cannot be done using -% the Matlab Serial Date format as there can be -% some loss of precision. -% The following instruction is not precise enough : -% s.DATE_EXT = datestr( s.DAYD_EXT, 'yyyymmddHHMMSS' ); -% ------------------------------------------------------ -yy = num2str( s.(char(header(1))), '%4d' ); -mm = num2str( s.(char(header(2))), '%02d' ); -dd = num2str( s.(char(header(3))), '%02d' ); -hh = num2str( s.(char(header(4))), '%02d' ); -mi = num2str( s.(char(header(5))), '%02d' ); -ss = num2str( s.(char(header(6))), '%02d' ); -s.DATE_EXT = [yy mm dd hh mi ss]; +% Convert date using pre-defined format +% ------------------------------------- +s.DATE_EXT = datestr(s.DAYD_EXT, tsg.preference.date_format_variable); % Check if bottle/ship colocation is OK % ------------------------------------- diff --git a/tsg_io/readAsciiTsg.m b/tsg_io/readAsciiTsg.m index 511a535f60e84181b3e4edcc1518db41def01baf..69ec00f9382dc9b0bae1d85c712e8012b5b1fc69 100644 --- a/tsg_io/readAsciiTsg.m +++ b/tsg_io/readAsciiTsg.m @@ -128,19 +128,9 @@ ss = double( s.(char(header(6))) ); tsg.report.tsgfile = filename; tsg.DAYD = datenum(yy, mm, dd, hh, mi, ss); -% Convert date in character. This cannot be done using -% the Matlab Serial Date format as there can be -% some loss of precision. -% The following instruction is not precise enough : -% tsg.DATE = datestr( tsg.DAYD, 'yyyymmddHHMMSS' ); -% ------------------------------------------------------ -yy = num2str( s.(char(header(1))), '%4d' ); -mm = num2str( s.(char(header(2))), '%02d' ); -dd = num2str( s.(char(header(3))), '%02d' ); -hh = num2str( s.(char(header(4))), '%02d' ); -mi = num2str( s.(char(header(5))), '%02d' ); -ss = num2str( s.(char(header(6))), '%02d' ); -tsg.DATE = [yy mm dd hh mi ss]; +% Convert date using pre-defined format +% ------------------------------------- +tsg.DATE = datestr( tsg.DAYD, tsg.preference.date_format_variable ); nHeader = length( header ); for i = 7 : nHeader diff --git a/tsg_io/readTsgDataAstrolabe.m b/tsg_io/readTsgDataAstrolabe.m index 52638a1df0679144809579ae362e1606faec6ef9..bc2bad50690caac5cfa3f326db1efa46802e102b 100644 --- a/tsg_io/readTsgDataAstrolabe.m +++ b/tsg_io/readTsgDataAstrolabe.m @@ -119,9 +119,6 @@ clear cellData % Date (y m d h m s) in the first 4 elements in data % -------------------------------------------------- -% ddmmyy = char(s.(char(header(1)))) ; -% dd = str2num(ddmmyy(:,1:2)); -% mm = str2num(ddmmyy(:,3:4)); ddmmyy = double(s.(char(header(1)))) ; nn = length(ddmmyy); dd = repmat(NaN, [nn 1]); @@ -144,7 +141,10 @@ ss = double( s.(char(header(4))) ); tsg.report.tsgfile = filename; tsg.DAYD = datenum(yy, mm, dd, hh, mi, ss); -tsg.DATE = datestr( tsg.DAYD, 'yyyymmddHHMMSS' ); + +% Convert date using pre-defined format +% ------------------------------------- +tsg.DATE = datestr( tsg.DAYD, tsg.preference.date_format_variable ); nHeader = length( header ); for i = 5 : nHeader diff --git a/tsg_io/readTsgDataLabview.m b/tsg_io/readTsgDataLabview.m index dcbf40eb516942317b07aec02aad87d51bb5b589..82840902cbd8387bf2a0145812a7c553e85fcede 100644 --- a/tsg_io/readTsgDataLabview.m +++ b/tsg_io/readTsgDataLabview.m @@ -165,7 +165,8 @@ if fid ~= -1 % Save original data. If date or time are incorrect data are deleted % ------------------------------------------------------------------ - tsg.DATE = deblank( datestr( tsg.DAYD, 'yyyymmddHHMMSS' ) ); + tsg.DATE = deblank( datestr(tsg.DAYD,... + tsg.preference.date_format_variable) ); tsg.LATX = lat(noNaN); tsg.LONX = lon(noNaN); tsg.SSJT = sst(noNaN); diff --git a/tsg_io/readTsgDataNetCDF.m b/tsg_io/readTsgDataNetCDF.m index e934bf05a07febd1ed3d5dcdbda4860971cf35db..98a578f170e5d8924e0469c488bd456887e3a2d2 100644 --- a/tsg_io/readTsgDataNetCDF.m +++ b/tsg_io/readTsgDataNetCDF.m @@ -120,6 +120,12 @@ automaticQC( hMainFig ) tsg.(variable) = julianToDatenum(tsg.(variable)); end + % save in tsg structure attribute conventions for DATE viariables + % --------------------------------------------------------------- + if strmatch('DATE', variable) + tsg.conventions.(variable) = nv.conventions(:); + end + % assign netcdf variables in base workspace % ----------------------------------------- assignin('base', variable, nv(:)); @@ -183,6 +189,16 @@ automaticQC( hMainFig ) tsg.(var) = julianToDatenum(tsg.(var)); end + % save in tsg structure attribute conventions for DATE viariables + % --------------------------------------------------------------- + if strfind(var, 'DATE') + if strcmp(nc.VARIABLES.(var).conventions, 'yyyymmddhhmmss') + tsg.conventions.(var) = 'yyyymmddHHMMSS'; + else + tsg.conventions.(var) = nc.VARIABLES.(var).conventions; + end + end + % assign variable in base workspace % ------------------------------------------- assignin('base', var , tsg.(var)); diff --git a/tsg_io/readTsgDataNuka.m b/tsg_io/readTsgDataNuka.m index 4ddc9b5da3cdd81efeb640722df7f9a7459436c4..7fbdffaaf4e95b39a2d8514f9fdd5414efb1c4cb 100644 --- a/tsg_io/readTsgDataNuka.m +++ b/tsg_io/readTsgDataNuka.m @@ -98,8 +98,9 @@ end % Fill other TSG variables % --------------------------------- -tsg.DATE = datestr([cellData{3} cellData{4} cellData{5} hh mm zeros(nrecords,1)],'yyyymmddHHMMSS'); -tsg.DAYD = datenum(tsg.DATE,'yyyymmddHHMMSS'); +tsg.DATE = datestr([cellData{3} cellData{4} cellData{5} hh mm zeros(nrecords,1)],... + tsg.preference.date_format_variable); +tsg.DAYD = datenum(tsg.DATE, tsg.preference.date_format_variable); tsg.LATX = cellData{7}; tsg.LONX = cellData{8}; tsg.SSPS = cellData{10}; diff --git a/tsg_io/readTsgDataOracle.m b/tsg_io/readTsgDataOracle.m index e543bfef53dfef054fae81352c0000bbec1f0669..0dedf1ac4b33edc4166c6f4ae6157ed79e432c55 100644 --- a/tsg_io/readTsgDataOracle.m +++ b/tsg_io/readTsgDataOracle.m @@ -128,8 +128,9 @@ if size(timechar,2)>5 else SS = zeros(nrecords,1); end -tsg.DATE = datestr([yyyy mm dd HH MM SS],'yyyymmddHHMMSS'); -tsg.DAYD = datenum(tsg.DATE,'yyyymmddHHMMSS'); +tsg.DATE = datestr([yyyy mm dd HH MM SS],... + tsg.preference.date_format_variable); +tsg.DAYD = datenum(tsg.DATE, tsg.preference.date_format_variable); tsg.LATX = cellData{3}; tsg.LONX = cellData{4}; tsg.SSJT = cellData{5}; diff --git a/tsg_io/writeAsciiSample.m b/tsg_io/writeAsciiSample.m index 61df45d278cfdc68832f350d9737f6d5cc7e93c0..59f10a635555fc4e724911fed55882e5e65c37ad 100644 --- a/tsg_io/writeAsciiSample.m +++ b/tsg_io/writeAsciiSample.m @@ -52,17 +52,8 @@ if choice if nbRecords ~= 0 % Use tsg.DATE_EXT to get the year, month, day, etc. - % This cannot be done using the Matlab Serial Date format as there can be - % some loss of precision. - % The following instruction is not precise enough : - % [year, month, day, hour, min, sec] = datevec( tsg.DAYD_EXT ); % ------------------------------------------------------ - year = str2num( tsg.DATE_EXT(:,1:4) ); - month = str2num( tsg.DATE_EXT(:,5:6) ); - day = str2num( tsg.DATE_EXT(:,7:8) ); - hour = str2num( tsg.DATE_EXT(:,9:10) ); - min = str2num( tsg.DATE_EXT(:,11:12) ); - sec = str2num( tsg.DATE_EXT(:,13:14) ); + [year, month, day, hour, min, sec] = datevec( tsg.DAYD_EXT ); tsg_data = [year month day hour min fix(sec) tsg.LATX_EXT tsg.LONX_EXT ]; header = 'YEAR MNTH DAYX hh mi ss LATX_EXT LONX_EXT'; diff --git a/tsg_io/writeAsciiTsg.m b/tsg_io/writeAsciiTsg.m index 5364faf4d8241c2197215ab557e119ecaa43bab7..0a7877c04468ded6d628c0840e600816e30fc3de 100644 --- a/tsg_io/writeAsciiTsg.m +++ b/tsg_io/writeAsciiTsg.m @@ -52,18 +52,15 @@ if choice nbRecords = length( tsg.DAYD ); if nbRecords ~= 0 - % Use tsg.DATE to get the year, month, day, etc. - % This cannot be done using the Matlab Serial Date format as there can be - % some loss of precision. - % The following instruction is not precise enough : - % [year, month, day, hour, min, sec] = datevec( tsg.DAYD ); - % ------------------------------------------------------ - year = str2num( tsg.DATE(:,1:4) ); - month = str2num( tsg.DATE(:,5:6) ); - day = str2num( tsg.DATE(:,7:8) ); - hour = str2num( tsg.DATE(:,9:10) ); - min = str2num( tsg.DATE(:,11:12) ); - sec = str2num( tsg.DATE(:,13:14) ); + % get the year, month, day, etc. + % ------------------------------- +% year = str2num( tsg.DATE(:,1:4) ); +% month = str2num( tsg.DATE(:,5:6) ); +% day = str2num( tsg.DATE(:,7:8) ); +% hour = str2num( tsg.DATE(:,10:11) ); +% min = str2num( tsg.DATE(:,12:13) ); +% sec = str2num( tsg.DATE(:,14:15) ); + [year, month, day, hour, min, sec] = datevec( tsg.DAYD ); tsg_data = [year month day hour min fix(sec) tsg.LATX mod(tsg.LONX+180,360)-180 ]; header = 'YEAR MNTH DAYX hh mi ss LATX LONX'; diff --git a/tsg_io/writeTSGDataNetCDF.m b/tsg_io/writeTSGDataNetCDF.m index dce5aeabb3b7ff66912afd7b6407846ee725fd50..807da14837c8fa1084eca4c37b7708ee06d7dc0f 100644 --- a/tsg_io/writeTSGDataNetCDF.m +++ b/tsg_io/writeTSGDataNetCDF.m @@ -122,6 +122,7 @@ end % Fixed dimensions % ---------------- nc('STRING256') = tsg.dim.STRING256; + nc('STRING16') = tsg.dim.STRING16; nc('STRING14') = tsg.dim.STRING14; nc('STRING8') = tsg.dim.STRING8; nc('STRING4') = tsg.dim.STRING4; diff --git a/tsg_util/headerForm.m b/tsg_util/headerForm.m index ad576109cb5d4aeb1df9eee4ec9773d9325b7f0d..807eadf60e7954ebd76dfe47112f526d639e7a7e 100644 --- a/tsg_util/headerForm.m +++ b/tsg_util/headerForm.m @@ -36,9 +36,9 @@ bottom = .95; inc_x = 3 * default_length; inc_y = 0.01; -% get actual date -% --------------- -date = datestr(now,30); +% get actual date to format +% ------------------------- +date = datestr(now, tsg.preference.date_format_attribute); % Get an instance of dynaload objetc from file 'tsgqc_netcdf.csv' % ----------------------------------------------------------------- @@ -61,7 +61,7 @@ add_coeff_var = { 'SSJT_CALCOEF', 'SSJT_LINCOEF', 'CNDC_CALCOEF', ... % if tsg_platform_info.csv not exist, create it % --------------------------------------------- -%existPlatform(hTsgGUI); +existPlatform(hTsgGUI); % % check if .ini file exist in data % % -------------------------------- @@ -79,7 +79,8 @@ platform_info = tsg_nc('tsg_platform.csv'); % end % header Uicontrols in a new figure -% --------------------------------- +% comment 'WindowStyle', 'modal', ... in debug mode +% --------------------------------------------------- hHeaderFig = figure(... 'BackingStore','off',... 'Name', 'TSG GLOBAL ATTRIBUTES AND VARIABLES', ... @@ -89,11 +90,10 @@ hHeaderFig = figure(... 'Toolbar', 'none', ... 'Tag', 'GLOBAL_ATTRIBUTES', ... 'Visible','on',... - 'WindowStyle', 'modal', ... 'Units', 'normalized',... 'Position',get(hTsgGUI,'Position'), ... 'Color', get(0, 'DefaultUIControlBackgroundColor')); - +%'WindowStyle', 'modal', ... % bg = [0.92549 0.913725 0.847059] = get(0, 'DefaultUIControlBackgroundColor'); % Iterate from each element from object nca and additional variables @@ -144,14 +144,30 @@ for i = nca_keys % display conventions field if exist % ---------------------------------- - uicontrol(... - 'Parent', hHeaderFig, ... - 'Units', 'normalized', ... - 'Style', 'text', ... - 'Fontsize', tsg.fontSize-2, ... - 'HorizontalAlignment', 'left', ... - 'Position', [left + 2*s.length, bottom, s.length, s.height], ... - 'String', char(s.conventions)); + convention = char(s.conventions); + name = char(s.name); + + % if attribute as a column conventions in csv file + % ------------------------------------------------ + if ~isempty(convention) + + % get it + % ------ + if ~isempty(strfind(name, 'DATE')) + convention = tsg.preference.date_format_attribute; + end + + % and display in text field + % ------------------------- + uicontrol(... + 'Parent', hHeaderFig, ... + 'Units', 'normalized', ... + 'Style', 'text', ... + 'Fontsize', tsg.fontSize-2, ... + 'HorizontalAlignment', 'left', ... + 'Position', [left + 2*s.length, bottom, s.length, s.height], ... + 'String', convention); + end % set dynamically uicontrol from tsg struct % ----------------------------------------- @@ -312,7 +328,7 @@ uiwait(hHeaderFig); % set tsg.DATE_UPDATE % ------------------- if strcmp(key, 'DATE_UPDATE') - tsg.(key) = [date(1:8) date(10:15)]; + tsg.(key) = date; end % if uicontrol is a popupmenu, string is cell array with all choices @@ -608,8 +624,7 @@ uiwait(hHeaderFig); % additionnal coefficients variable here % -------------------------------------- function add_coefficients - - + % display dynamically uicontrol text over add_var list % ---------------------------------------------------- for acv = add_coeff_var @@ -630,7 +645,7 @@ uiwait(hHeaderFig); % loop for each value of coefficient variable % ------------------------------------------- for ii=1:numel(tsg.(var)) - + tsg.([var '_CONV']); cle = tsg.([var '_CONV'])(ii,:); % if fillValue, don't display uicontrol diff --git a/tsg_util/netcdfTOtsgqc.m b/tsg_util/netcdfTOtsgqc.m index da8b96f30e8ba51b993a6cbf0038c2f9cf5f7708..8af9c0e5469a7f7da194e49dbdd51e8a91832298 100644 --- a/tsg_util/netcdfTOtsgqc.m +++ b/tsg_util/netcdfTOtsgqc.m @@ -123,9 +123,9 @@ for i = 1 : nfiles year = str2num(tsg.DATE(:,1:4)); month = str2num(tsg.DATE(:,5:6)); day = str2num(tsg.DATE(:,7:8)); - hour = str2num(tsg.DATE(:,9:10)); - min = str2num(tsg.DATE(:,11:12)); - sec = str2num(tsg.DATE(:,13:14)); + hour = str2num(tsg.DATE(:,10:11)); + min = str2num(tsg.DATE(:,12:13)); + sec = str2num(tsg.DATE(:,14:15)); %[year, month, day, hour, min, sec] = datevec( julianToDatenum(tsg.DAYD) ); tsg_data = [year month day hour min fix(sec) tsg.LATX mod(tsg.LONX+180,360)-180 ]; diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m index 12fdbfa0401f1a7975632dd57224c75de4799f5c..dd983a27f231b8c5afd7481054b7f770635c1161 100644 --- a/tsg_util/tsg_initialisation.m +++ b/tsg_util/tsg_initialisation.m @@ -62,7 +62,8 @@ end % define netcdf dimensions % ------------------------ tsg.dim.STRING256 = 256; -tsg.dim.STRING14 = 14; +tsg.dim.STRING16 = 16; % use for ISO8601 date format +tsg.dim.STRING14 = 14; % use for oldest date format tsg.dim.STRING8 = 8; tsg.dim.STRING4 = 4; tsg.dim.N1 = 1; @@ -77,9 +78,9 @@ tsg.dim.COEF_CONV_SIZE = tsg.dim.STRING8; % ------------------------------------------------------ REFERENCE_DATE_TIME = '19500101000000'; -% get actual date -% --------------- -date = datestr(now,30); +% get actual date with ISO8601 +% ---------------------------- +date = datestr(now, 'yyyyddmmHHMMSS'); % ------------------------------------------------------------------------- %% Levitus fields for climatology @@ -229,9 +230,10 @@ end % set some fields % --------------- tsg.FORMAT_VERSION = NETCDF_FORMAT_VERSION; -tsg.DATE_CREATION = [date(1:8) date(10:15)]; +tsg.DATE_CREATION = date; tsg.DATE_UPDATE = tsg.DATE_CREATION; tsg.REFERENCE_DATE_TIME = REFERENCE_DATE_TIME; +tsg.conventions = []; % Save tsg structure % ------------------ diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m index b7b2dbe921ba7fa626202669ef0aa5c6d4d66e9c..a7d77cd20a0ae57f1dd2e7206792693a3d07e353 100644 --- a/tsg_util/tsg_preferences.m +++ b/tsg_util/tsg_preferences.m @@ -153,8 +153,12 @@ set(hTsgGUI,'Pointer','arrow'); preference.ssjt_max_string = {'40'}; preference.sstp_min_string = {'-3'}; preference.sstp_max_string = {'40'}; - preference.date_format_variable = {'yyyyMMddHHmmss'}; - preference.date_format_attribute = {'yyyy-MM-ddTHH:mm:ssZ'}; + + % according with tsg_netcdf.xls file + % change version number or delete tsgqc.mat + % ----------------------------------------- + preference.date_format_variable = 'yyyymmddHHMMSS'; + preference.date_format_attribute = 'yyyymmddHHMMSS'; % save preference struct to 'prefdir.mat' file % --------------------------------------------- diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m index 61185549f962fb2b971c8fc17f4230dc4485fb03..fc31f616bf3998424a5de99546bc5de0daa4964c 100644 --- a/tsg_util/updateTsgStruct.m +++ b/tsg_util/updateTsgStruct.m @@ -61,11 +61,43 @@ else end % get date start and end value and set to globals attributes -% ----------------------------------------------------------------- -date = datestr(min(tsg.DAYD), 30); -tsg.DATE_START = [date(1:8) date(10:15)]; -date = datestr(max(tsg.DAYD), 30); -tsg.DATE_END = [date(1:8) date(10:15)]; +% by default db-oceano use this format yyyymmddHHMMSS +% ---------------------------------------------------------- +tsg.DATE_START = datestr(min(tsg.DAYD), tsg.preference.date_format_attribute); +tsg.DATE_END = datestr(max(tsg.DAYD), tsg.preference.date_format_attribute); + +% if date is in standard format, change, if not, user need to update +% inside headerform +% ------------------------------------------------------------------ +if size(tsg.DATE, 2) == 14 + tsg.DATE_CREATION = datestr(datenum(tsg.DATE_CREATION, ... + 'yyyyddmmHHMMSS'), tsg.preference.date_format_attribute); +end +if size(tsg.DATE, 2) == 14 + tsg.DATE_UPDATE = datestr(datenum(tsg.DATE_UPDATE, ... + 'yyyyddmmHHMMSS'), tsg.preference.date_format_attribute); +end + +% update tsg.xxx_DATE_xxx with new or ISO8601 format if necessary +% conventions for variables are saved in tsg.conventions structure +% see updateTsgStruct.m +% ---------------------------------------------------------------- +if ~isempty(tsg.REFERENCE_DATE_TIME) && ~isempty(tsg.conventions) + tsg.REFERENCE_DATE_TIME = datestr(datenum(tsg.REFERENCE_DATE_TIME,... + tsg.conventions.REFERENCE_DATE_TIME), tsg.preference.date_format_variable); +end +if ~isempty(tsg.DATE) && ~isempty(tsg.conventions) + tsg.DATE = datestr(datenum(tsg.DATE, ... + tsg.conventions.DATE), tsg.preference.date_format_variable); +end +if ~isempty(tsg.DATE_EXT) && ~isempty(tsg.conventions) + tsg.DATE_EXT = datestr(datenum(tsg.DATE_EXT, ... + tsg.conventions.DATE_EXT), tsg.preference.date_format_variable); +end +if ~isempty(tsg.SSPS_EXT_ANALDATE) && ~isempty(tsg.conventions) + tsg.SSPS_EXT_ANALDATE = datestr(datenum(tsg.DATE_EXT, ... + tsg.conventions.SSPS_EXT_ANALDATE), tsg.preference.date_format_variable); +end % Variables must exists % --------------------- @@ -112,6 +144,21 @@ end % ------------------ setappdata( hMainFig, 'tsg_data', tsg); +% reset calibration coefficients for this not comptatible version +% --------------------------------------------------------------- +if strcmp(tsg.FORMAT_VERSION, '1.4') + tsg.SSJT_CALCOEF = []; + tsg.CNDC_CALCOEF = []; + tsg.SSTP_CALCOEF = []; + tsg.SSJT_LINCOEF = []; + tsg.CNDC_LINCOEF = []; + tsg.SSTP_LINCOEF = []; + + % Save tsg structure + % ------------------ + setappdata( hMainFig, 'tsg_data', tsg); +end + % fill tsg calibration variables % ------------------------------ updateTsgStructWithCalCoeff(hMainFig); diff --git a/tsgqc.m b/tsgqc.m index 5a09877bd00b769b693191eb068d5e6b133647bf..e947e5d68556f677e2dc210c752bfc47947d11ea 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -37,8 +37,8 @@ global NETCDF_FORMAT_VERSION % version number, may be used to initialize some files when it change % 0.90x -> 1.0RCx % ------------------------------------------------------------------- -VERSION = 1.3; % -> 1.3 -CHAR_VERSION = '1.3'; +VERSION = 1.22; % -> 1.3 +CHAR_VERSION = '1.22'; % netcdf file version, see DATA FORMAT TSG document: % CORTSG_format_gosud_1.5.doc