-
Notifications
You must be signed in to change notification settings - Fork 23
/
docBathy.m
145 lines (112 loc) · 3.4 KB
/
docBathy.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
function [bathy, myErr] = docBathy( fn )
%%
% do cBathy function. Wrapper around actual code, is
% called by perl automation wrapper with name of stack file
% to work on.
%%
% WARNING: this function is used by production CIL processing.
% PLEASE do not change or remove this. Please do not "fix" it so
% it runs for you. It is here so that the git version of cBathy
% can be run in production mode at CIL without having to remember to
% fix the repository version to add this back. Thank you.
%
% you are probably looking for analyzeBathyCollect.
% from BWLiteBatch by YHS.
%% set up returns
myErr = -999;
bathy = [];
%%
tic;
try
DBConnect;
catch
%myErr = -998;
disp( 'failed to connect to database' );
return;
end
pn = parseFilename( fn );
% do I even DO this one?
% look it up! all of them, I'll need them later
stack = DBGetTableEntry('stack','epoch',[str2num(pn.time)-5 str2num(pn.time)+5], ...
'station', pn.station );
%disp( stack );
if( ~isempty(stack) )
rinfo = DBGetTableEntry('R', 'station', pn.station, ...
'epoch', stack(1).aoiEpoch, ...
'camNum', pn.camera );
if( isempty( rinfo ) )
disp( ['no r file for ' fn] );
myErr = -803;
return;
end
if( isempty( strfind( rinfo.names, 'mBW' ) ) )
disp( [ 'no instrument mBW in ' fn ] );
myErr = -800;
return;
end
else
myErr = -801;
return;
end
addpath(strrep(which('cBathyBatch'), 'cBathyBatch.m', 'SETTINGS'));
paramsFile = [ pn.station ];
try
eval( paramsFile );
catch
myErr = -802;
return;
end
%params.DOPLOTTILES = 0; % per tile plot option
%params.DOPLOTCollect = 0; % per collection plot option
%params.DOPLOTTRANSECTS = 0; % primary debugging
bathy.epoch = pn.time;
bathy.sName = fn;
bathy.params = params;
params.DECIMATE = 1;
[xyz, epoch, data, cam] = loadBathyStack( fn, params.DECIMATE );
%%
bathy = analyzeBathyCollect( xyz, epoch, data, cam, bathy );
%%
pn.camera = 'x';
pn.type = 'cBathy';
pn.format = 'mat';
nfn = argusFilename( pn );
save( nfn, 'bathy' );
myErr = toc;
% one last step, move the data where it goes.
comm = ['perl ~/bin/move.data.2000 -q ' pn.station ' ' nfn ];
system(comm);
%%
% one real last thing -- update stack database with this
for i = 1:length(stack)
ostack = stack(i);
nstack = stack(i);
nstack.cBathyTime = floor(epochtime);
if( isnan(bathy.tide.zt ) )
nstack.tide = 0;
else
nstack.tide = bathy.tide.zt;
end
nstack.tideType = bathy.tide.source;
ns = createUpdateString( 'stack', ostack, nstack, {'seq' 'epoch'} );
DBQueryRaw( ns );
end
%
% Copyright (C) 2017 Coastal Imaging Research Network
% and Oregon State University
% This program is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation, version 3 of the
% License.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
% You should have received a copy of the GNU General Public License
% along with this program. If not, see
% <http://www.gnu.org/licenses/>.
% CIRN: https://coastal-imaging-research-network.github.io/
% CIL: http://cil-www.coas.oregonstate.edu
%
%key cBathy
%