diff --git a/@tsg_nc/tsg_nc.m b/@tsg_nc/tsg_nc.m index 3a143f49cc5675d7af43d7f4b65e84145c3f5074..6caad295c31075e9699e82d35657f5612e2bb35b 100644 --- a/@tsg_nc/tsg_nc.m +++ b/@tsg_nc/tsg_nc.m @@ -89,6 +89,9 @@ for i=1:ncv.size switch type case 'char' theStruct.(member) = value; + case 'cell' + %c = textscan(value,'%s','delimiter',','); + theStruct.(member) = value; case {'integer','double'} theStruct.(member) = str2double(value); otherwise diff --git a/@tsg_nc/tsg_ncvar.csv b/@tsg_nc/tsg_ncvar.csv index 86b71a60f1fcdcbbc9e54080bf8a764219fd3814..775116e9f6dcbe08464739b594ab30a586848a6e 100644 --- a/@tsg_nc/tsg_ncvar.csv +++ b/@tsg_nc/tsg_ncvar.csv @@ -2,11 +2,11 @@ % $Id$ % id;code;dimension;long_name;standard_name;units;conventions;valid_min;valid_max;format;FillValue;epic_code;axis;resolution;comment; -integer;char;char;char;char;char;char;integer;integer;char;double;integer;char;double;char; +integer;char;cell;char;char;char;char;integer;integer;char;double;integer;char;double;char; 1;REFERENCE_DATE_TIME;STRING14;;;;yyyymmddhhmmss;;;;;;;;Reference date for julian days origin; 2;DATE;DAYD,STRING14;DATE OF MAIN INSTRUMENT MEASUREMENT;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost; -3;DATE_WS;DAYD,STRING14;DATE OF WATER SAMPLE;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost; -4;DATE_EXT;DAYD,STRING14;DATE OF EACH EXTERNAL DATA MEASUREMENT;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost; +3;DATE_WS;DAYD','STRING14;DATE OF WATER SAMPLE;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost; +4;DATE_EXT;DAYD','STRING14;DATE OF EACH EXTERNAL DATA MEASUREMENT;;;yyyymmddhhmmss;;;;;;;;This is the original data describing the date, it must not be lost; 5;DAYD;DAYD;DECIMAL JULIAN DAY (UTC) OF EACH MEASUREMENT;time;days since 1950/01/01 00:00:00;Relative julian days with decimal part (as parts of the day);0.0;36600.0;%9.5lf;9999999.;601;t;;Julian day of the measurement; 6;DAYD_WS;DAYD_WS;DECIMAL JULIAN DAY (UTC) OF EACH WATER SAMPLE;time;days since 1950/01/01 00:00:00;Relative julian days with decimal part (as parts of the day);0.0;36600.0;%9.5lf;9999999.;601;t;;Julian day of the measurement; 7;DAYD_EXT;DAYD_EXT;DECIMAL JULIAN DAY (UTC) OF EXTERNAL DATA MEASUREMENT;time;Days since 1950/01/01 00:00:00;Relative julian days with decimal part (as parts of the day);0.0;36600.0;%9.5lf;9999999.;601;t;;Julian day of the measurement; diff --git a/tsg_io/writeTSGDataNetCDF.m b/tsg_io/writeTSGDataNetCDF.m index 0126d7f23fda58228a2d641b99870c126eaa6697..65607ff2c4431cdfa06ad857b6cc61fa31770633 100644 --- a/tsg_io/writeTSGDataNetCDF.m +++ b/tsg_io/writeTSGDataNetCDF.m @@ -54,7 +54,7 @@ nca_keys = keys(nca); % Get GF3 variables list codes from class tsg_nc with file 'tsg_ncvar.csv' % ----------------------------------------------------------------------- -ncv = tsg_nc('tsg_ncvar.csv'); +ncv = tsg_nc('tsg_test.csv'); ncv_keys = keys(ncv); ncv_fieldNames = get_fieldnames(ncv); @@ -88,23 +88,31 @@ waitbar(1/50,wb,['Writing file: ' filename ' Please wait...']); %% Create NetCDF global attributes % ------------------------------- for i=1:numel(nca_keys) - nc.(nca_keys{i}) = tsg.(nca_keys{i}); + global_att = nca_keys{i}; + nc.(global_att) = tsg.(global_att); end % Create NetCDF variables and attributes % -------------------------------------- for i=1:numel(ncv_keys) for j=1:numel(ncv_fieldNames) - fn = ncv_fieldNames{j}; + variable = ncv_keys{i}; + fieldName = ncv_fieldNames{j}; + value = get(ncv, variable, fieldName); + % define dimension - if strcmp(fn,'dimension') - nc{ncv_keys{i}} = ncfloat(get(ncv, ncv_keys{i}, fn)); - % define variable atributes - elseif ~isempty(get(ncv, ncv_keys{i}, fn)) - if ischar(get(ncv, ncv_keys{i}, fn)) - nc{ncv_keys{i}}.(fn) = ncchar(get(ncv, ncv_keys{i}, fn)); + % ---------------- + if strcmp(fieldName,'dimension') + s = ['nc{''' variable '''} = {''' value '''}']; + eval(s); + + % define variable attributes + % -------------------------- + elseif ~isempty(value) + if ischar(value) + nc{variable}.(fieldName) = ncchar(value); else - nc{ncv_keys{i}}.(fn) = ncfloat(get(ncv, ncv_keys{i}, fn)); + nc{variable}.(fieldName) = ncfloat(value); end end end @@ -116,7 +124,12 @@ end % Write global attributes % ----------------------- for i=1:numel(nca_keys) - nc.(nca_keys{i}) = tsg.(nca_keys{i}); + + % get netcdf global attribute name + % -------------------------------- + global_attr = nca_keys{i}; + + nc.(global_attr) = tsg.(global_attr); end % Convert Matlab julian days (datenum) to 1950 reference @@ -129,22 +142,28 @@ end % Write measurements (variables) % ------------------------------- for i=1:numel(ncv_keys) + + % get netcdf variable name + % ------------------------ + variable = ncv_keys{i}; + % display waitbar - waitbar( i/numel(ncv_keys), wb, ['writing ' ncv_keys{i} ' variable']); + % --------------- + waitbar( i/numel(ncv_keys), wb, ['writing ' variable ' variable']); + % DATE as two dimension % don't work under windows - % nc{ncv_keys{i}}(:) = tsg.(ncv_keys{i}); - if strmatch('DATE',ncv_keys(i)) - nc{ncv_keys{i}}(:,:) = tsg.(ncv_keys{i}); + % nc{variable}(:) = tsg.(variable); + if strmatch('DATE', variable) + nc{variable}(:,:) = tsg.(variable); else % other one dimension % under Linux, when you write an with empty matrix to an unlimited % variable dimension, nc was corrupted to double object % works well on windows - if ~isempty(tsg.(ncv_keys{i})) - %ncv_keys{i} - %nc{ncv_keys{i}}(1:length(tsg.(ncv_keys{i}))) = tsg.(ncv_keys{i}); - nc{ncv_keys{i}}(:) = tsg.(ncv_keys{i}); + if ~isempty(tsg.(variable)) + %nc{variable}(1:length(tsg.(variable))) = tsg.(variable); + nc{variable}(:) = tsg.(variable); end end end diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m index 33bdf49502d874e3fc24bf515cdaf65be206255f..87afc5710babbe3f568418bfd68aa8482943d36e 100644 --- a/tsgqc_GUI.m +++ b/tsgqc_GUI.m @@ -28,7 +28,10 @@ function tsgqc_GUI %% Initialization tasks % ******************** -clc + +% Clear Command Window display, giving up a "clean screen." +% --------------------------------------------------------- +clc; % Find program directory. % functions (icons) should be store at a lower level @@ -564,7 +567,7 @@ tsg_initialisation(hMainFig, hQcCmenu) % returns the plot to its initial zoom setting % -------------------------------------------- - zoom out; + %zoom out; % turns interactive zooming off % ----------------------------- @@ -607,7 +610,7 @@ tsg_initialisation(hMainFig, hQcCmenu) % reset to original figure % ------------------------ - zoom out; + %zoom out; end @@ -1280,8 +1283,12 @@ tsg_initialisation(hMainFig, hQcCmenu) rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] ); rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] ); rmpath( [DEFAULT_PATH_FILE filesep 'tsg_io'] ); + + % Refresh file system caches + % -------------------------- rehash; + end -end +end % end of tsgqc_GUI