diff --git a/tsg_map/world_c.mat b/tsg_map/world_c.mat new file mode 100644 index 0000000000000000000000000000000000000000..0c5e4ab5e92086ce170d76ba5a9eb0ef1245caef Binary files /dev/null and b/tsg_map/world_c.mat differ diff --git a/tsg_map/world_f.mat b/tsg_map/world_f.mat new file mode 100644 index 0000000000000000000000000000000000000000..110b3f5086579bfc60993fcb75e627cd3057f0d5 Binary files /dev/null and b/tsg_map/world_f.mat differ diff --git a/tsg_map/world_h.mat b/tsg_map/world_h.mat new file mode 100644 index 0000000000000000000000000000000000000000..d6de8536764bee8df2e84b76998d3ed4b5fb7ef8 Binary files /dev/null and b/tsg_map/world_h.mat differ diff --git a/tsg_map/world_i.mat b/tsg_map/world_i.mat new file mode 100644 index 0000000000000000000000000000000000000000..08347102e4fd8cdbb3afdd0db232791a931352c1 Binary files /dev/null and b/tsg_map/world_i.mat differ diff --git a/tsg_map/world_l.mat b/tsg_map/world_l.mat new file mode 100644 index 0000000000000000000000000000000000000000..55329caa5cfab8aac0b9f8d6d6e9b5d058862b42 Binary files /dev/null and b/tsg_map/world_l.mat differ diff --git a/tsg_util/plot_map.m b/tsg_util/plot_map.m index 23ffbce132213695d8aca73f741b6dfb97b712aa..20ba92a022a9b05b7f7be22fc04bb0ccadfbcadf 100644 --- a/tsg_util/plot_map.m +++ b/tsg_util/plot_map.m @@ -13,7 +13,7 @@ function plot_map(hTsgGUI, hPlotAxes) % % TODOS % -% note that a decimal degree notation is used, so that a longitude of +% note that a decimal degree notation is used, so that a longitude of % 120?30'W is specified as -120.5 % % PROBLEM NOT YET RESOLVED @@ -27,7 +27,7 @@ tsg = getappdata( hTsgGUI, 'tsg_data'); % Retrieve map border % -------------------- -border = str2double(tsg.preference.map_border_string(tsg.preference.map_border_value)); +border = tsg.preference.map_border; % Get the Geographic limit of the TSG time series % ----------------------------------------------- @@ -40,7 +40,7 @@ latx = double(tsg.LATX); lonx = double(tsg.LONX); if ~isempty( ind ) - + latMin = min(latx(ind) ); if latMin < -90 latMin = -90; @@ -51,17 +51,17 @@ if ~isempty( ind ) end lonMin = min( lonx(ind) ); lonMax = max( lonx(ind) ); - + % Oversize window due to the large frame %-------------------------------------- latRange = (latMax-latMin); latMin = max(floor(latMin), -90); latMax = min(ceil(latMax), 90); - + lonRange = (lonMax-lonMin); lonMin = floor(lonMin); lonMax = ceil(lonMax); - + lonRange = (lonMax-lonMin); if lonRange>=360 lonMin = -183.6; %to account for fancy frame @@ -72,75 +72,109 @@ if ~isempty( ind ) tsg.lonplus = 0; tsg.lonmod = 0; end - + % Positionning the right axes (set map current axe) % ------------------------------------------------- axes(hPlotAxes(4)); - + % Use of Mercator projection % -------------------------- m_proj('Mercator','lat',[latMin-border latMax+border],'long',[lonMin-border lonMax+border]); - + switch tsg.preference.map_resolution - + case 1 - % Low-resolution coast lines + % Low-resolution coast lines, % -------------------------- - m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); - + if tsg.preference.map_patch_value == 2 + m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + else + s = load('world_c.mat'); + end + case 2 % Medium-resolution coast lines % ----------------------------- - m_gshhs_l('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); - + if tsg.preference.map_patch_value == 2 + m_gshhs_l('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + else + s = load('world_l.mat'); + end + + case 3 % Intermediate-resolution coast lines % ---------------------------- - m_gshhs_i('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + if tsg.preference.map_patch_value == 2 + m_gshhs_i('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + else + s = load('world_i.mat'); + end + case 4 % High-resolution coast lines % ---------------------------- - m_gshhs_h('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + if tsg.preference.map_patch_value == 2 + m_gshhs_h('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + else + s = load('world_h.mat'); + end + otherwise tsg.preference.map_resolution = 1; % Low-resolution coast lines % -------------------------- - m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); - + if tsg.preference.map_patch_value == 2 + m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST'); + else + s = load('world_c.mat'); + end + end - + + % Make a grid on the map with fancy box % ------------------------------------- m_grid('box', 'fancy', 'tickdir', 'in', 'TAG', 'TAG_PLOT4_LINE_GRID', ... 'Fontsize', tsg.fontSize); - + + + % use 'world_x.mat' as tsg.preference.map_patch_string == 'off' + % -------------------------------------------------------------- + if tsg.preference.map_patch_value == 1 + x = s.ncst(:,1); + y = s.ncst(:,2); + m_line(x,y, 'color','k'); + end + + % Plot the ship track - Check if LAT-LON in deg-decimal % ----------------------------------------------------- %m_line(lonx, latx, 'TAG', 'TAG_PLOT4_LINE_SHIPTRACK', 'marker','.','markersize',3,'color','b'); % m_line(lonx, latx, 'LineStyle', 'none', 'marker','*','markersize',2,'color','b'); - + % Plot using QC % ------------- - + % Get list of keys from hashtable tsg.qc.hash, defined inside % tsg_initialisation.m % ----------------------------------------------------------- qc_list = keys(tsg.qc.hash); - + % Plot Sample/TSG differences on axe 2 % iterate (loop) on each key store inside hastable % Iterate from the end of the cell array : fliplr % ------------------------------------------------ for key = fliplr( qc_list ) - + % get some values in hashtable % ----------------------------- %qcState = tsg.qc.hash.(key).state; qcCode = tsg.qc.hash.(key).code; qcColor = tsg.qc.hash.(key).color; - + % plot tsg salinity sample with right code/color % ---------------------------------------------- ind = find( tsg.SSPS_QC == qcCode & isnan(tsg.SSPS) == 0); @@ -149,26 +183,26 @@ if ~isempty( ind ) % Create line on the map % ---------------------- m_line( mod(lonx(ind) + tsg.lonplus, tsg.lonmod) - tsg.lonplus,... - latx(ind), 'LineStyle', 'none', 'marker','*',... - 'markersize', 2, 'color', qcColor); + latx(ind), 'LineStyle', 'none', 'marker','*',... + 'markersize', 2, 'color', qcColor); end end - + % Write title % ----------- title( ['Cruise: ' tsg.file.name], 'fontsize',tsg.fontSize +2, ... 'fontweight', 'bold','interpreter','none'); - + % Set tag for each line % --------------------- hLines = get(hPlotAxes(4), 'Children'); for i=1:length(hLines) set(hLines(i), 'Tag', ['TAG_PLOT4_LINE_MAP' int2str(i)]); end - + % Save tsg structure % ------------------ setappdata( hTsgGUI, 'tsg_data', tsg); - + end diff --git a/tsg_util/preferencesForm.m b/tsg_util/preferencesForm.m index a75d00b0f52e4fed79c2d05e5164c2ed0197c638..3d74fdba598ae7475b795a097dee54e015e11b9f 100644 --- a/tsg_util/preferencesForm.m +++ b/tsg_util/preferencesForm.m @@ -251,6 +251,34 @@ if bottom < .1 left = left + inc_x; end +% display map with patch +% ----------------------- +uicontrol(... + 'Parent', hPreferencesFig, ... + 'Units', 'normalized', ... + 'Style', 'Text', 'Fontsize', tsg.fontSize-1, ... + 'HorizontalAlignment', 'left', 'Position',[left, bottom, length, height], ... + 'TooltipString', 'Much slower with high resolution', ... + 'String', 'Map with patch (slower)'); + +% display map resolution uicontrol +% -------------------------------- +uicontrol(... + 'Parent', hPreferencesFig, ... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', 'Style', 'popupmenu', 'Fontsize', tsg.fontSize-2, ... + 'HorizontalAlignment', 'right', ... + 'Position', [left + length, bottom, length, height], ... + 'String', tsg.preference.map_patch_string, ... + 'Value', tsg.preference.map_patch_value, ... + 'Tag', 'PREFERENCES_MAP_PATCH'); + +bottom = bottom - inc_y - height; +if bottom < .1 + bottom = 0.95; + left = left + inc_x; +end + % display map border % ------------------ uicontrol(... @@ -259,7 +287,7 @@ uicontrol(... 'Style', 'Text', 'Fontsize', tsg.fontSize-1, ... 'HorizontalAlignment', 'left', 'Position',[left, bottom, length, height], ... 'TooltipString', 'select map border in degrees', ... - 'String', 'Map Border'); + 'String', 'Map Border in degrees'); % display map resolution uicontrol % -------------------------------- @@ -521,6 +549,11 @@ if bottom < .1 left = left + inc_x; end +% goto next column +% ---------------- +bottom = 0.95; +left = left + inc_x; + % display format for dates TITLE % ------------------------------- uicontrol(... @@ -616,12 +649,6 @@ uicontrol(... 'String', tsg.preference.positions_format_string, ... 'Value', tsg.preference.positions_format_value, ... 'Tag', 'PREFERENCES_POSITIONS_FORMAT'); - - -% goto next column -% ---------------- -bottom = 0.95; -left = left + inc_x; % display DT_SMOOTH TITLE % ------------------------------- @@ -824,6 +851,8 @@ uiwait(hPreferencesFig); get(prefs.PREFERENCES_MAP_RESOLUTION, 'value'); tsg.preference.map_border_value = ... get(prefs.PREFERENCES_MAP_BORDER, 'value'); + tsg.preference.map_patch_value = ... + get(prefs.PREFERENCES_MAP_PATCH, 'value'); tsg.preference.positions_format_value = ... get(prefs.PREFERENCES_POSITIONS_FORMAT, 'value'); % QC Tests diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m index a8db667ad6adc3527d684683dd1bb8c9176a4f6a..da551d3bad5cbb9ee7d87e19fe09fdd6844366f3 100644 --- a/tsg_util/tsg_preferences.m +++ b/tsg_util/tsg_preferences.m @@ -98,6 +98,12 @@ end % ----------------------------------- tsg.preference = preference; +% map_border could be set to zero when zoom is active +% --------------------------------------------------- +tsg.preference.map_border = ... + str2double(tsg.preference.map_border_string(tsg.preference.map_border_value)); + + % Save structure tsg % ------------------ setappdata( hTsgGUI, 'tsg_data', tsg); @@ -149,8 +155,11 @@ return % Plot preference.map_resolution_string = {'low','medium','intermediate','high'}; preference.map_resolution = 1; - preference.map_border_string = {'1','2','5','10','15'}; + preference.map_patch_string = {'off', 'on'}; + preference.map_patch_value = 1; + preference.map_border_string = {'0','1','2','5','10','15'}; preference.map_border_value = 4; + preference.map_border = 5; % default preference.plot_connected_string = {'none', '-', '--', ':', '-.'}; preference.plot_connected_value = 1; % 0, line not connected % QC test diff --git a/tsgqc.m b/tsgqc.m index 43c4a1d33c6578aef574103ed9c223e4f72f81b2..978c69ae8f02fb8373f52b1c3608e2505d9ebf1d 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -38,9 +38,9 @@ global GOSUD_FORMAT_VERSION % version number, may be used to initialize some files when it change % 0.90x -> 1.0RCx % ------------------------------------------------------------------- -VERSION = 1.482; % -> 1.44 -CHAR_VERSION = '1.48.2'; -DATE_VERSION = '18/06/2018'; +VERSION = 1.483; % -> 1.44 +CHAR_VERSION = '1.48.3b2'; +DATE_VERSION = '19/06/2018'; % netcdf file version, see DATA FORMAT TSG document: % CORTSG_format_gosud.doc @@ -78,7 +78,8 @@ if (~isdeployed) DEFAULT_PATH_FILE,[ 'tsg_util' pathsep],... DEFAULT_PATH_FILE,[ 'tsg_data' pathsep],... DEFAULT_PATH_FILE,[ 'tsg_io' pathsep],... - DEFAULT_PATH_FILE,[ 'tsg_icon' pathsep] + DEFAULT_PATH_FILE,[ 'tsg_icon' pathsep],... + DEFAULT_PATH_FILE,[ 'tsg_map' pathsep] ]; addpath( p, '-end' ); rehash; @@ -126,8 +127,11 @@ help = 'off'; % parse and set optional arguments with couple 'property', 'value' % ----------------------------------------------------------------- +if length(varargin) == 1 + inputFile = varargin{1}; +end property_argin = varargin(1:end); -while length(property_argin) >= 2, +while length(property_argin) >= 2 property = property_argin{1}; value = property_argin{2}; property_argin = property_argin(3:end); @@ -156,8 +160,9 @@ end % ----------------------------------------------------------- if strcmp(help, 'on') fprintf('tsgqc\n'); - fprintf('tsgqc(inputfile,<file>, outputfile, <file>)\n'); - fprintf('tsgqc(inputfile,<file>, outputfile, <file>),''display'',''on''\n'); + fprintf('tsgqc(''<file>'')\n'); + fprintf('tsgqc(''inputfile'', <file>, ''outputfile'', <file>)\n'); + fprintf('tsgqc(''inputfile'', <file>, ''outputfile'', <file>),''display'',''on''\n'); fprintf('tsgqc(''help'',''on'')\n'); return; end @@ -786,8 +791,10 @@ hbgQc = uibuttongroup(... % ----------------------------------------------- set(hbgQc,'SelectionChangeFcn',@RadiobuttonQc); -%% Context Menu and RadioButtons for Quality control -% ----------------------------------------------------------------------- +%% Context Menus + +% RadioButtons for Quality control +% ----------------------------------------------------------------------- hQcCmenu = uicontextmenu(... 'Parent', hMainFig, ... 'HandleVisibility','on' ); @@ -855,6 +862,11 @@ for key = qc_list end % end of for loop +% zoom context menu +% ----------------- +zoom_context_menu = uicontextmenu('Parent', hMainFig, 'HandleVisibility','on' ); +uimenu('parent',zoom_context_menu, 'Label', 'Reset to Original view', 'Callback', @reset_zoom_callback); + %% uipanel for checkboxes % -------------------------------------- hCorPanel = uipanel(... @@ -1222,6 +1234,10 @@ hrbInterpCancel = uicontrol( ... % % end of main function (GUI definition) % +if ~isempty(inputFile) + OpenMenuCallback +end + %% *************************** CALLBACKS ********************************** % All following callback are in nested functions @@ -1257,7 +1273,15 @@ hrbInterpCancel = uicontrol( ... % Open standard dialog box for retrieving files % --------------------------------------------- - [fileName, pathname, filterIndex] = uigetfile( tsg.preference.fileExtension, 'Pick a file'); + if isempty(inputFile) + [fileName, pathname, filterIndex] = uigetfile( tsg.preference.fileExtension, 'Pick a file'); + else + % batch mode + [pathname,fileName,ext] = fileparts(inputFile); + fileName = strcat(fileName, ext); + inputFile = []; + filterIndex = 1; + end % flushes the event queue and updates the closed uigetfile window % --------------------------------------------------------------- @@ -1279,21 +1303,18 @@ hrbInterpCancel = uicontrol( ... % construct valid and full file path % ----------------------------------- - fullFileName = strcat(pathname, fileName); - + fullFileName = fullfile(pathname, fileName); + % the last extension selected move on top in cell array preference.fileExtensions % ---------------------------------------------------------------------- tsg.preference.fileExtension = ... circshift(tsg.preference.fileExtension, 1 - filterIndex); setappdata( hMainFig, 'tsg_data', tsg); - + % Read the data % ------------- [errTsg, errSpl] = read_data( hMainFig, strcat('*',ext), fullFileName); - - - % Keep the pathname of the tsgqc m_file % ------------------------------------- % tsgqcname = mfilename; @@ -1843,6 +1864,10 @@ hrbInterpCancel = uicontrol( ... % --------------------------------------------------------- hZoom = zoom(hMainFig); + % Set the UI Context Menu to the custom menu + % ----------------------------------------- + set(hZoom, 'UIContextMenu', zoom_context_menu) + % Turns off the automatic adaptation of date ticks % ------------------------------------------------ zoomAdaptiveDateTicks('off'); @@ -1865,6 +1890,12 @@ hrbInterpCancel = uicontrol( ... % ------------------------------------------------------------- set(hZoom, 'ActionPostCallback', @ZoomPan_PostCallback); + + % Set map with border and save tsg + % -------------------------------- + tsg.preference.map_border = 0; + setappdata( hMainFig, 'tsg_data', tsg ); + end %% ZoomIn_OffMenuCallback @@ -1902,6 +1933,10 @@ hrbInterpCancel = uicontrol( ... % --------------------------------------------------------- hZoom = zoom(hMainFig); + % Set the UI Context Menu to the custom menu + % ----------------------------------------- + set(hZoom, 'UIContextMenu', zoom_context_menu) + % turns interactive zooming out (decrease) % ---------------------------------------- set(hZoom, 'direction', 'out'); @@ -1938,6 +1973,23 @@ hrbInterpCancel = uicontrol( ... end +% callback function run from context menu from right clic in zoom mode +% -------------------------------------------------------------------- + function reset_zoom_callback(src, evnt) + + % returns the plot to its initial zoom setting. + % --------------------------------------------- + zoom out; + + % restore map border to its preference setting + % --------------------------------------------- + tsg.preference.map_border = ... + str2double(tsg.preference.map_border_string(tsg.preference.map_border_value)); + tsg.preference.map_border + setappdata( hMainFig, 'tsg_data', tsg ); + + end + %% Pan_OnMenuCallback %---------------------------------------------------------------------- % Callback function run when the pan toggle toolbar is selected @@ -2143,8 +2195,8 @@ hrbInterpCancel = uicontrol( ... return end -% fprintf(1, 'p1: %f %f size = %d\n', p1, length(p1)); -% fprintf(1, 'p2: %f %f size = %d\n', p2, length(p2)); + % fprintf(1, 'p1: %f %f size = %d\n', p1, length(p1)); + % fprintf(1, 'p2: %f %f size = %d\n', p2, length(p2)); % The following code is only executed if the left mouse button is clicked. % If the right mouse button is clicked, this code must not be @@ -2727,6 +2779,12 @@ hrbInterpCancel = uicontrol( ... % --------------------------------------------------------------------- zoom out; + % reset map border + % ---------------- + tsg.preference.map_border = ... + str2double(tsg.preference.map_border_string(tsg.preference.map_border_value)); + setappdata( hMainFig, 'tsg_data', tsg ); + % Get the information on time limits of the time series % Write them in the uipanel % ----------------------------------------------------- @@ -2779,6 +2837,12 @@ hrbInterpCancel = uicontrol( ... plot_Validation( hMainFig, hPlotAxes, 3, tsg.plot.parameter{3} ); zoom out; + % reset map border + % ---------------- + tsg.preference.map_border = ... + str2double(tsg.preference.map_border_string(tsg.preference.map_border_value)); + setappdata( hMainFig, 'tsg_data', tsg ); + % Set the pointer % --------------- set( hMainFig, 'Pointer', 'arrow'); @@ -4007,6 +4071,7 @@ hrbInterpCancel = uicontrol( ... rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] ); rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] ); rmpath( [DEFAULT_PATH_FILE filesep 'tsg_io'] ); + rmpath( [DEFAULT_PATH_FILE filesep 'tsg_map'] ); end % Refresh file system caches