Commit 9030f34401b77b442980662d08213f9114c56aff

Authored by Jean-Luc Shaw
1 parent e33787ac
Exists in master

Centralised updating plots to update_plots.m , added support for filtering out d…

…ata according to depth (beached drifters out), fixed indexing bugs
GUI_drifter_cleanup.m
... ... @@ -22,7 +22,7 @@ function varargout = GUI_drifter_cleanup(varargin)
22 22  
23 23 % Edit the above text to modify the response to help GUI_drifter_cleanup
24 24  
25   -% Last Modified by GUIDE v2.5 09-Apr-2018 17:14:52
  25 +% Last Modified by GUIDE v2.5 10-Apr-2018 10:08:14
26 26  
27 27 % Begin initialization code - DO NOT EDIT
28 28 gui_Singleton = 1;
... ... @@ -58,11 +58,16 @@ handles.output = hObject;
58 58 % Link to dependencies
59 59 addpath(genpath('lib')) ;
60 60  
61   -% Get input spot files
62   -info = dir('data/raw/*.mat');
  61 +% Get available input spot files
  62 +info = dir('data/gps/raw/*.mat');
63 63 list = {info.name}';
64 64 set(handles.menu_files,'String',list) ;
65 65  
  66 +% Get available input bathy files
  67 +info = dir('data/bathy/*.mat');
  68 +list = {info.name}';
  69 +set(handles.menu_bathy_files,'String',list) ;
  70 +
66 71 % Update handles structure
67 72 guidata(hObject, handles);
68 73  
... ... @@ -184,3 +189,75 @@ function edit_interpolate_step_CreateFcn(hObject, eventdata, handles)
184 189 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
185 190 set(hObject,'BackgroundColor','white');
186 191 end
  192 +
  193 +
  194 +% --- Executes on button press in but_undo.
  195 +function but_undo_Callback(hObject, eventdata, handles)
  196 +% hObject handle to but_undo (see GCBO)
  197 +% eventdata reserved - to be defined in a future version of MATLAB
  198 +% handles structure with handles and user data (see GUIDATA)
  199 +
  200 +
  201 +% --- Executes during object creation, after setting all properties.
  202 +function menu_bathy_files_CreateFcn(hObject, eventdata, handles)
  203 +% hObject handle to menu_bathy_files (see GCBO)
  204 +% eventdata reserved - to be defined in a future version of MATLAB
  205 +% handles empty - handles not created until after all CreateFcns called
  206 +
  207 +% Hint: popupmenu controls usually have a white background on Windows.
  208 +% See ISPC and COMPUTER.
  209 +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  210 + set(hObject,'BackgroundColor','white');
  211 +end
  212 +
  213 +
  214 +function edit_zmin_Callback(hObject, eventdata, handles)
  215 +% hObject handle to edit_zmin (see GCBO)
  216 +% eventdata reserved - to be defined in a future version of MATLAB
  217 +% handles structure with handles and user data (see GUIDATA)
  218 +
  219 +% Hints: get(hObject,'String') returns contents of edit_zmin as text
  220 +% str2double(get(hObject,'String')) returns contents of edit_zmin as a double
  221 +
  222 +
  223 +% --- Executes during object creation, after setting all properties.
  224 +function edit_zmin_CreateFcn(hObject, eventdata, handles)
  225 +% hObject handle to edit_zmin (see GCBO)
  226 +% eventdata reserved - to be defined in a future version of MATLAB
  227 +% handles empty - handles not created until after all CreateFcns called
  228 +
  229 +% Hint: edit controls usually have a white background on Windows.
  230 +% See ISPC and COMPUTER.
  231 +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  232 + set(hObject,'BackgroundColor','white');
  233 +end
  234 +
  235 +
  236 +% --- Executes on button press in but_get_time_step.
  237 +function but_get_time_step_Callback(hObject, eventdata, handles)
  238 +% hObject handle to but_get_time_step (see GCBO)
  239 +% eventdata reserved - to be defined in a future version of MATLAB
  240 +% handles structure with handles and user data (see GUIDATA)
  241 +
  242 +
  243 +
  244 +function edit_get_time_step_Callback(hObject, eventdata, handles)
  245 +% hObject handle to edit_get_time_step (see GCBO)
  246 +% eventdata reserved - to be defined in a future version of MATLAB
  247 +% handles structure with handles and user data (see GUIDATA)
  248 +
  249 +% Hints: get(hObject,'String') returns contents of edit_get_time_step as text
  250 +% str2double(get(hObject,'String')) returns contents of edit_get_time_step as a double
  251 +
  252 +
  253 +% --- Executes during object creation, after setting all properties.
  254 +function edit_get_time_step_CreateFcn(hObject, eventdata, handles)
  255 +% hObject handle to edit_get_time_step (see GCBO)
  256 +% eventdata reserved - to be defined in a future version of MATLAB
  257 +% handles empty - handles not created until after all CreateFcns called
  258 +
  259 +% Hint: edit controls usually have a white background on Windows.
  260 +% See ISPC and COMPUTER.
  261 +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  262 + set(hObject,'BackgroundColor','white');
  263 +end
... ...
lib/but_bathy_filter_Callback.m 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +function but_bathy_filter_Callback(hObject, eventdata, handles)
  2 +
  3 +global S
  4 +
  5 +if isfield(S,'z')
  6 + zmin = str2num(handles.edit_zmin.String) ;
  7 + I = find(S.z < zmin) ;
  8 + S.lon(I) = [] ;
  9 + S.lat(I) = [] ;
  10 + S.dnum(I) = [] ;
  11 + S.z(I) = [] ;
  12 + If = str2num(handles.edit_If.String) - numel(I) ;
  13 + handles.edit_If.String = num2str(If) ;
  14 + guidata(hObject, handles);
  15 + update_plots(hObject, eventdata, handles) ;
  16 +else
  17 + msgbox('No z computed for GPS track. Load bathymetry file!')
  18 +end
  19 +
  20 +end
  21 +
... ...
lib/but_delete_Callback.m
... ... @@ -17,47 +17,8 @@ If = N ;
17 17 handles.edit_I0.String = '1' ;
18 18 handles.edit_If.String = num2str(N) ;
19 19  
20   -axes(handles.ax_track) ;
21   -plot(S.lon,S.lat,'b',S.lon,S.lat,'ko')
22   -
23   -%% update aux plot
24   -blah = get(handles.grp_aux_data,'SelectedObject') ;
25   -whatever = get(blah,'String') ;
26   -
27   -switch whatever
28   - case 'Speed'
29   - axes(handles.ax_aux_data);
30   - try delete(handles.aux_line) ; catch ; end
31   -
32   - [~,~,spd,~] = llt2spd(S.lon(I0:If),S.lat(I0:If),S.dnum(I0:If)) ;
33   - handles.aux_line = plot(I0:If,spd,'k') ;
34   - xlim([I0 If])
35   - xlabel('Index')
36   - ylabel('Speed (m/s)')
37   - case 'Time'
38   - axes(handles.ax_aux_data);
39   - try delete(handles.aux_line) ; catch ; end
40   - handles.aux_line = plot(I0:If,S.dnum(I0:If),'k') ;
41   - xlim([I0 If])
42   - xlabel('Index')
43   - ylabel('Time (mm/dd)')
44   - datetick('y','mm/dd') ;
45   - case 'Distance'
46   - axes(handles.ax_aux_data);
47   - try delete(handles.aux_line) ; catch ; end
48   - dist = [0 ; m_lldist(S.lon(I0:If),S.lat(I0:If))] ;
49   - handles.aux_line = plot(I0:If,dist,'k') ;
50   - xlim([I0 If])
51   - xlabel('Index')
52   - ylabel('Distance (km)')
53   - case 'None'
54   - axes(handles.ax_aux_data);
55   - XL = handles.ax_aux_data.XLim;
56   - YL = handles.ax_aux_data.YLim;
57   - try delete(handles.aux_line) ; catch ; end
58   - handles.ax_aux_data.XLim = XL ;
59   - xlabel('Index')
60   -end
  20 +guidata(hObject, handles);
  21 +update_plots(hObject, eventdata, handles) ;
61 22  
62 23 % Update handles structure
63 24 guidata(hObject, handles);
... ...
lib/but_interpolate_Callback.m
1 1 function edit_interpolate_step_Callback(hObject, eventdata, handles)
2 2  
3   -global S
  3 +global S bathy
4 4  
5 5 step = str2num(handles.edit_interpolate_step.String)/(24*3600) ;
6 6  
... ... @@ -12,61 +12,28 @@ iN = numel(tq) ;
12 12 %% get interpolated coordinate values
13 13 ilon = interp1(S.dnum(I0:If),S.lon(I0:If),tq) ;
14 14 ilat = interp1(S.dnum(I0:If),S.lat(I0:If),tq) ;
  15 +if isfield(S,'z') ; iz = bathy(ilon,ilat) ; end
15 16  
16 17 %% Cut this data from the S raw structure
17 18 S.lon(I0:If) = [];
18 19 S.lat(I0:If) = [];
19 20 S.dnum(I0:If) = [];
  21 +if isfield(S,'z') ; S.z(I0:If) = [] ; end
20 22  
21 23 %% Insert the interpolated values at I0
22 24 S.lon = insertAt(S.lon ,I0,ilon) ;
23 25 S.lat = insertAt(S.lat ,I0,ilat) ;
24 26 S.dnum = insertAt(S.dnum,I0,tq) ;
  27 +if isfield(S,'z') ; S.z = insertAt(S.z,I0,iz); end
25 28  
26 29 %% Update plots
27 30 If = I0 + iN -1 ;
28 31  
29   -axes(handles.ax_track) ;
30   -plot(S.lon(I0:If),S.lat(I0:If),'b',S.lon(I0:If),S.lat(I0:If),'ko')
  32 +% Update index fields
  33 +handles.edit_If.String = num2str(If) ;
31 34  
32   -%% update aux plot
33   -blah = get(handles.grp_aux_data,'SelectedObject') ;
34   -whatever = get(blah,'String') ;
35   -
36   -switch whatever
37   - case 'Speed'
38   - axes(handles.ax_aux_data);
39   - try delete(handles.aux_line) ; catch ; end
40   -
41   - [~,~,spd,~] = llt2spd(S.lon(I0:If),S.lat(I0:If),S.dnum(I0:If)) ;
42   - handles.aux_line = plot(I0:If,spd,'k') ;
43   - xlim([I0 If])
44   - xlabel('Index')
45   - ylabel('Speed (m/s)')
46   - case 'Time'
47   - axes(handles.ax_aux_data);
48   - try delete(handles.aux_line) ; catch ; end
49   - handles.aux_line = plot(I0:If,S.dnum(I0:If),'k') ;
50   - xlim([I0 If])
51   - xlabel('Index')
52   - ylabel('Time (mm/dd)')
53   - datetick('y','mm/dd') ;
54   - case 'Distance'
55   - axes(handles.ax_aux_data);
56   - try delete(handles.aux_line) ; catch ; end
57   - dist = [0 ; m_lldist(S.lon(I0:If),S.lat(I0:If))] ;
58   - handles.aux_line = plot(I0:If,dist,'k') ;
59   - xlim([I0 If])
60   - xlabel('Index')
61   - ylabel('Distance (km)')
62   - case 'None'
63   - axes(handles.ax_aux_data);
64   - XL = handles.ax_aux_data.XLim;
65   - YL = handles.ax_aux_data.YLim;
66   - try delete(handles.aux_line) ; catch ; end
67   - handles.ax_aux_data.XLim = XL ;
68   - xlabel('Index')
69   -end
  35 +guidata(hObject, handles);
  36 +update_plots(hObject, eventdata, handles) ;
70 37  
71 38 % Update handles structure
72 39 guidata(hObject, handles);
... ...
lib/but_punch_out_Callback.m
... ... @@ -13,13 +13,15 @@ O.lon = S.lon(I0:If) ;
13 13 O.lat = S.lat(I0:If) ;
14 14 O.dnum = S.dnum(I0:If) ;
15 15 [O.u,O.v,O.spd,O.head] = llt2spd(O.lon,O.lat,O.dnum) ;
  16 +if isfield(S,'z'); O.z = S.z(I0:If) ; end
16 17  
17   -save(['data/clean/' fname '_' sprintf('%03d',cnt) '.mat'],'O') ; cnt = cnt+1 ;
  18 +save(['data/gps/clean/' fname '_' sprintf('%03d',cnt) '.mat'],'O') ; cnt = cnt+1 ;
18 19  
19 20 %% Cut this data from the S raw structure
20 21 S.lon(I0:If) = [];
21 22 S.lat(I0:If) = [];
22 23 S.dnum(I0:If) = [];
  24 +if isfield(S,'z'); S.z(I0:If) = [] ; end
23 25  
24 26 %% Update plots zooming out
25 27 N = numel(S.dnum) ;
... ... @@ -28,47 +30,8 @@ If = N ;
28 30 handles.edit_I0.String = '1' ;
29 31 handles.edit_If.String = num2str(N) ;
30 32  
31   -axes(handles.ax_track) ;
32   -plot(S.lon,S.lat,'b',S.lon,S.lat,'ko')
33   -
34   -%% update aux plot
35   -blah = get(handles.grp_aux_data,'SelectedObject') ;
36   -whatever = get(blah,'String') ;
37   -
38   -switch whatever
39   - case 'Speed'
40   - axes(handles.ax_aux_data);
41   - try delete(handles.aux_line) ; catch ; end
42   -
43   - [~,~,spd,~] = llt2spd(S.lon(I0:If),S.lat(I0:If),S.dnum(I0:If)) ;
44   - handles.aux_line = plot(I0:If,spd,'k') ;
45   - xlim([I0 If])
46   - xlabel('Index')
47   - ylabel('Speed (m/s)')
48   - case 'Time'
49   - axes(handles.ax_aux_data);
50   - try delete(handles.aux_line) ; catch ; end
51   - handles.aux_line = plot(I0:If,S.dnum(I0:If),'k') ;
52   - xlim([I0 If])
53   - xlabel('Index')
54   - ylabel('Time (mm/dd)')
55   - datetick('y','mm/dd') ;
56   - case 'Distance'
57   - axes(handles.ax_aux_data);
58   - try delete(handles.aux_line) ; catch ; end
59   - dist = [0 ; m_lldist(S.lon(I0:If),S.lat(I0:If))] ;
60   - handles.aux_line = plot(I0:If,dist,'k') ;
61   - xlim([I0 If])
62   - xlabel('Index')
63   - ylabel('Distance (km)')
64   - case 'None'
65   - axes(handles.ax_aux_data);
66   - XL = handles.ax_aux_data.XLim;
67   - YL = handles.ax_aux_data.YLim;
68   - try delete(handles.aux_line) ; catch ; end
69   - handles.ax_aux_data.XLim = XL ;
70   - xlabel('Index')
71   -end
  33 +guidata(hObject, handles);
  34 +update_plots(hObject, eventdata, handles) ;
72 35  
73 36 % Update handles structure
74 37 guidata(hObject, handles);
... ...
lib/edit_I0_Callback.m
... ... @@ -13,7 +13,8 @@ if I0&gt;N ; I0 = N; end
13 13 axes(handles.ax_track) ;
14 14 cla;
15 15  
16   -plot(S.lon(I0:If),S.lat(I0:If),'b',S.lon(I0:If),S.lat(I0:If),'ko')
  16 +guidata(hObject, handles);
  17 +update_plots(hObject, eventdata, handles) ;
17 18  
18 19  
19 20 end
... ...
lib/edit_If_Callback.m
... ... @@ -19,47 +19,8 @@ end
19 19 axes(handles.ax_track) ;
20 20 cla;
21 21  
22   -%% update main plot
23   -plot(S.lon(I0:If),S.lat(I0:If),'b',S.lon(I0:If),S.lat(I0:If),'ko')
24   -
25   -%% update aux plot
26   -blah = get(handles.grp_aux_data,'SelectedObject') ;
27   -whatever = get(blah,'String') ;
28   -
29   -switch whatever
30   - case 'Speed'
31   - axes(handles.ax_aux_data);
32   - try delete(handles.aux_line) ; catch ; end
33   -
34   - [~,~,spd,~] = llt2spd(S.lon(I0:If),S.lat(I0:If),S.dnum(I0:If)) ;
35   - handles.aux_line = plot(I0:If,spd,'k') ;
36   - xlim([I0 If])
37   - xlabel('Index')
38   - ylabel('Speed (m/s)')
39   - case 'Time'
40   - axes(handles.ax_aux_data);
41   - try delete(handles.aux_line) ; catch ; end
42   - handles.aux_line = plot(I0:If,S.dnum(I0:If),'k') ;
43   - xlim([I0 If])
44   - xlabel('Index')
45   - ylabel('Time (mm/dd)')
46   - datetick('y','mm/dd') ;
47   - case 'Distance'
48   - axes(handles.ax_aux_data);
49   - try delete(handles.aux_line) ; catch ; end
50   - dist = [0 ; m_lldist(S.lon(I0:If),S.lat(I0:If))] ;
51   - handles.aux_line = plot(I0:If,dist,'k') ;
52   - xlim([I0 If])
53   - xlabel('Index')
54   - ylabel('Distance (km)')
55   - case 'None'
56   - axes(handles.ax_aux_data);
57   - XL = handles.ax_aux_data.XLim;
58   - YL = handles.ax_aux_data.YLim;
59   - try delete(handles.aux_line) ; catch ; end
60   - handles.ax_aux_data.XLim = XL ;
61   - xlabel('Index')
62   -end
  22 +guidata(hObject, handles);
  23 +update_plots(hObject, eventdata, handles) ;
63 24  
64 25 % Update handles structure
65 26 guidata(hObject, handles);
... ...
lib/menu_bathy_files_Callback.m 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +function menu_bathy_files_Callback(hObject, eventdata, handles)
  2 +
  3 +global bathy S
  4 +
  5 +%% Put the list of mat files in the file list menu
  6 +liste = get(hObject,'String') ;
  7 +I = get(hObject,'Value') ;
  8 +file = liste{I} ;
  9 +fpath = ['data/bathy/' file] ;
  10 +load(['data/bathy/' file]) ;
  11 +bathy = F_BSI ; % inelegant but simple
  12 +
  13 +if isstruct(S)
  14 + S.z = bathy(S.lon,S.lat) ;
  15 +else
  16 + msgbox('WARNING! load GPS file first and then reload bathymetry. No Z computed !') ;
  17 +end
  18 +
  19 +% Update handles structure
  20 +guidata(hObject, handles);
  21 +
  22 +end
0 23 \ No newline at end of file
... ...
lib/menu_files_Callback.m
... ... @@ -6,8 +6,8 @@ global S cnt
6 6 liste = get(hObject,'String') ;
7 7 I = get(hObject,'Value') ;
8 8 file = liste{I} ;
9   -fpath = ['data/raw/' file] ;
10   -load(['data/raw/' file]) ;
  9 +fpath = ['data/gps/raw/' file] ;
  10 +load(['data/gps/raw/' file]) ;
11 11  
12 12 N = numel(data.timeM) ;
13 13 handles.edit_I0.String = '1' ;
... ...
lib/update_plots.m 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +function update_plots(hObject, eventdata, handles)
  2 +
  3 +global S
  4 +
  5 +I0 = str2num(handles.edit_I0.String);
  6 +If = str2num(handles.edit_If.String);
  7 +
  8 +% update track plot
  9 +axes(handles.ax_track) ;
  10 +plot(S.lon(I0:If),S.lat(I0:If),'b',S.lon(I0:If),S.lat(I0:If),'ko')
  11 +
  12 +%% update aux plot
  13 +blah = get(handles.grp_aux_data,'SelectedObject') ;
  14 +whatever = get(blah,'String') ;
  15 +
  16 +switch whatever
  17 + case 'Speed'
  18 + axes(handles.ax_aux_data);
  19 + try delete(handles.aux_line) ; catch ; end
  20 +
  21 + [~,~,spd,~] = llt2spd(S.lon(I0:If),S.lat(I0:If),S.dnum(I0:If)) ;
  22 + handles.aux_line = plot(I0:If,spd,'k') ;
  23 + xlim([I0 If])
  24 + xlabel('Index')
  25 + ylabel('Speed (m/s)')
  26 + case 'Time'
  27 + axes(handles.ax_aux_data);
  28 + try delete(handles.aux_line) ; catch ; end
  29 + handles.aux_line = plot(I0:If,S.dnum(I0:If),'k') ;
  30 + xlim([I0 If])
  31 + xlabel('Index')
  32 + ylabel('Time (mm/dd)')
  33 + datetick('y','mm/dd') ;
  34 + case 'Distance'
  35 + axes(handles.ax_aux_data);
  36 + try delete(handles.aux_line) ; catch ; end
  37 + dist = [0 ; m_lldist(S.lon(I0:If),S.lat(I0:If))] ;
  38 + handles.aux_line = plot(I0:If,dist,'k') ;
  39 + xlim([I0 If])
  40 + xlabel('Index')
  41 + ylabel('Distance (km)')
  42 + case 'None'
  43 + axes(handles.ax_aux_data);
  44 + XL = handles.ax_aux_data.XLim;
  45 + YL = handles.ax_aux_data.YLim;
  46 + try delete(handles.aux_line) ; catch ; end
  47 + handles.ax_aux_data.XLim = XL ;
  48 + xlabel('Index')
  49 +end
  50 +
  51 +% Update handles structure
  52 +guidata(hObject, handles);
  53 +
  54 +end
0 55 \ No newline at end of file
... ...