Commit 6b6023ba58d7015e79506db436e78e273a6738f6

Authored by Jean-Luc Shaw
1 parent 47c77104
Exists in master

Finished writing documentation

GUI_drifter_cleanup.m
... ... @@ -68,6 +68,11 @@ info = dir('data/bathy/*.mat');
68 68 list = {info.name}';
69 69 set(handles.menu_bathy_files,'String',list) ;
70 70  
  71 +% Get available input bathy files
  72 +info = dir('data/tide/*.mat');
  73 +list = {info.name}';
  74 +set(handles.menu_tide_files,'String',list) ;
  75 +
71 76 % Update handles structure
72 77 guidata(hObject, handles);
73 78  
... ... @@ -278,17 +283,6 @@ if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgr
278 283 set(hObject,'BackgroundColor','white');
279 284 end
280 285  
281   -
282   -% --- Executes on selection change in menu_tide_files.
283   -function menu_tide_files_Callback(hObject, eventdata, handles)
284   -% hObject handle to menu_tide_files (see GCBO)
285   -% eventdata reserved - to be defined in a future version of MATLAB
286   -% handles structure with handles and user data (see GUIDATA)
287   -
288   -% Hints: contents = cellstr(get(hObject,'String')) returns menu_tide_files contents as cell array
289   -% contents{get(hObject,'Value')} returns selected item from menu_tide_files
290   -
291   -
292 286 % --- Executes during object creation, after setting all properties.
293 287 function menu_tide_files_CreateFcn(hObject, eventdata, handles)
294 288 % hObject handle to menu_tide_files (see GCBO)
... ...
documentation.txt
... ... @@ -13,6 +13,10 @@ Upon output, several useful parameters are also calculated. The cleaned
13 13 level and time after high tide. The latter two are only calculated if
14 14 bathymetric and tidal have been provided.
15 15  
  16 +The software was written and tested with matlab version R2016b under the
  17 +student license. It will run into problems with earlier versions but
  18 +should run on later ones.
  19 +
16 20 Other than the very useful m_lldist.m function which is from Rich
17 21 Pawlowicz's m_map package and which he owns, all software is written
18 22 by Jean-Luc Shaw in 2018. You can freely use and distribute but you can
... ... @@ -54,7 +58,8 @@ triscatteredInterp object stored in a '.mat' file and built using
54 58 depth positive towards the sea floor and a geographical grid in
55 59 latitude and longitude coordinates.
56 60 The tide file should be a matlab structure stored in a '.mat'
57   -file and contain the following fields:
  61 +file and contain the following fields. It may be called anything, but
  62 +assuming it would be called 'T':
58 63  
59 64 T.dnum : time in matlab format ( fraction of day )
60 65 T.nm : local sea level (m)
... ... @@ -82,18 +87,75 @@ sequence of operations as guidelines to quality control of your data.
82 87  
83 88 ===== FUNCTION DESCRIPTION =====
84 89  
85   -RANGE (I0 and If) :
  90 +RANGE (I0 and If) :
  91 +
  92 + The I0 and If are index values of the raw data vector. They select
  93 +which portion of the raw data will display in both the geographical
  94 +track and auxilliary data monitors as well as the portion of the raw
  95 +data vector which will be operated on. Let's call data points corres-
  96 +ponding to indexes I0 to If inclusively the 'active data'.
86 97  
87 98 DELETE :
88 99  
  100 + Removes the active data from the working data structure BUT does
  101 +not touch the raw data file! It zooms out to full view making I0 and
  102 +If the first and last index values of the working data structure.
  103 +
89 104 UNDO :
90 105  
  106 + Reloads the selected raw data file, reads the operation log, and
  107 +chronologically applies the operation history up to last operation
  108 +exclusively. This way, only the last applied operation is undone.
  109 +
91 110 FILTER z < X :
92 111  
  112 + Uses the loaded bathymetry to locate elements of the active data
  113 +which are in water shallower than X, and deletes them from the working
  114 +data structure BUT not from the raw data file.
  115 +
93 116 GET TIME STEP :
  117 +
  118 + Computes the median time between pings from the active data. Displays
  119 +it in the adjacent field and in the interpolation step field for con-
  120 +venience.
94 121  
95 122 INTERPOLATE :
96 123  
  124 + Interpolates the active data on a regular time grid, deletes the
  125 +active data from the working data structure, and replaces it with the
  126 +interpolated data. The value of the adjacent field in seconds is used
  127 +as the new time step. In matlab's synthax, the new time grid is :
  128 +
  129 + time_wds(I0):step:time_wds(If)
  130 +
97 131 PUNCH OUT :
98 132  
99   -OPERATION LOG :
100 133 \ No newline at end of file
  134 + Computes u, v, speed, heading, water depth*, local sea level*, and
  135 +time after high tide*, for the active data, exports it to a '.mat' file
  136 +in the data/gps/clean directory, and removes the active data from the
  137 +working data structure. The output 'clean' matfile is named the following
  138 +way:
  139 +
  140 + raw-input-file-name_XXX.mat
  141 +
  142 +where Xs are integers. The number XXX will be 000 the first time the
  143 +PUNCH OUT function is used and be incremented every following time,
  144 +producing a sequence of cleaned data tracks stored in independent '.mat'
  145 +files for every raw input file analysed.
  146 +
  147 +OPERATION LOG :
  148 +
  149 + Operations DELETE, FILTER Z > X, INTERPOLATE, and PUNCH OUT are
  150 +logged to a file created automatically in the log directory. This
  151 +file is name the same as the selected gps input file but appended with
  152 +the extension '.log' .
  153 + The log entries contain the name of the operation applied, the I0 and
  154 +If values, a parameter value, and the new size of the working data struc-
  155 +ture. For the different operations prameter definition varies:
  156 +
  157 + Delete : parameter = nan
  158 + Filter : parameter = minimum water depth
  159 + Interpolate : parameter = interpolation time step in seconds
  160 + Output : parameter = sequential number of the punch (XXX)
  161 +
  162 +======================================================================
101 163 \ No newline at end of file
... ...
lib/but_punch_out_Callback.m
1 1 function but_punch_out_Callback(hObject, eventdata, handles)
2 2  
3   -global S O cnt
  3 +global S O tide cnt
4 4  
5 5 I0 = str2num(handles.edit_I0.String);
6 6 If = str2num(handles.edit_If.String);
... ... @@ -12,7 +12,10 @@ O = [] ;
12 12 O.lon = S.lon(I0:If) ;
13 13 O.lat = S.lat(I0:If) ;
14 14 O.dnum = S.dnum(I0:If) ;
15   -[O.u,O.v,O.spd,O.head] = llt2spd(O.lon,O.lat,O.dnum) ;
  15 +[O.u,O.v,O.spd,head] = llt2spd(O.lon,O.lat,O.dnum) ;
  16 +O.head = theta2heading(head) ;
  17 +
  18 +if isstruct(tide); O.time_AHT = interp1(tide.dnum,tide.time_AHT,S.dnum(I0:If)) ; end
16 19 if isfield(S,'z'); O.z = S.z(I0:If) ; end
17 20  
18 21 save(['data/gps/clean/' fname '_' sprintf('%03d',cnt) '.mat'],'O') ; cnt = cnt+1 ;
... ...
lib/menu_bathy_files_Callback.m
... ... @@ -8,7 +8,7 @@ I = get(hObject,&#39;Value&#39;) ;
8 8 file = liste{I} ;
9 9 A = load(['data/bathy/' file]) ;
10 10 B = fieldnames(A);
11   -bathy = getfield(A,B{1}) ; % inelegant but simple
  11 +bathy = getfield(A,B{1}) ;
12 12  
13 13 if isstruct(S)
14 14 S.z = bathy(S.lon,S.lat) ;
... ...
lib/menu_tide_files_Callback.m 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +function menu_tide_files_Callback(hObject, eventdata, handles)
  2 +
  3 +global tide
  4 +
  5 +liste = get(hObject,'String') ;
  6 +I = get(hObject,'Value') ;
  7 +file = liste{I} ;
  8 +A = load(['data/tide/' file]) ;
  9 +B = fieldnames(A) ;
  10 +C = getfield(A,B{1}) ;
  11 +tide = struct('dnum',C.dnum,'time_AHT',C.time_AHT,'nm',C.nm) ;
  12 +
  13 +end
... ...
lib/theta2heading.m 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +
  2 +function output = theta2heading(input)
  3 +% Synthax : output = theta2heading(input)
  4 +%
  5 +% Takes as input angle vector in cartesian coordinates running counter-
  6 +% clockwise from 0 (east) to 360 degrees and transforms it into a heading
  7 +% vector running clockwise from 0 to the north to 360 degrees.
  8 +%
  9 +
  10 +input = input - 90;
  11 +input = 360 - input ;
  12 +input(input < 0) = input(input < 0) + 360 ;
  13 +output = mod(input,360) ;
  14 +
  15 +end
... ...