53 require "$PERL_TOOLS/RDI_BB_Read.pl"; |
58 require "$PERL_TOOLS/RDI_BB_Read.pl"; |
54 require "$PERL_TOOLS/RDI_Coords.pl"; |
59 require "$PERL_TOOLS/RDI_Coords.pl"; |
55 require "$PERL_TOOLS/RDI_Utils.pl"; |
60 require "$PERL_TOOLS/RDI_Utils.pl"; |
56 |
61 |
57 $antsParseHeader = 0; |
62 $antsParseHeader = 0; |
58 &antsUsage('24ab:c:df:g:i:kl:n:o:ps:t:w:',2, |
63 &antsUsage('24a:b:c:df:g:i:kl:n:o:ps:t:w:',2, |
59 '[use -2)dary CTD sensor pair]', |
64 '[use -2)dary CTD sensor pair]', |
60 '[require -4)-beam LADCP solutions]', |
65 '[require -4)-beam LADCP solutions]', |
61 '[-s)etup <file>] [-g)ps <lat,lon>]', |
66 '[-s)etup <file>] [-g)ps <lat,lon>]', |
62 '[-c)ompass-corr <offset,cos-fac,sin-fac>]', |
67 '[-c)ompass-corr <offset,cos-fac,sin-fac>]', |
63 '[enable -p)PI editing]', |
68 '[enable -p)PI editing]', |
64 '[-o)utput grid <resolution[5m]>]', |
69 '[-o)utput grid <resolution[5m]>]', |
65 '[-i)nitial LADCP time lag <guestimate>]', |
70 '[-i)nitial LADCP time lag <guestimate>]', |
66 '[-l)ag LADCP <by>] [auto-lag -w)indow <size[120s]>] [-n) <auto-lag windows[20]]', |
71 '[-l)ag LADCP <by>] [auto-lag -w)indow <size[120s]>] [-n) <auto-lag windows[20]]', |
67 '[-d)iagnostic output]', |
72 '[-d)iagnostic output]', |
68 'output: [-t)ime series <file>] [-f)lag <file>] [-b)ottom-track <file>]', |
73 'output: [-t)ime series <file>] [-f)lag <file>] [-b)ottom-track <file>]', |
69 ' [per-bin -a)coustic backscatter profiles] [bottom-trac-k) profs]', |
74 ' [-a)coustic backscatter <depth-time-series file] [bottom-trac-k) profs]', |
70 '<RDI file> <SeaBird file>'); |
75 '<RDI file> <SeaBird file>'); |
71 |
76 |
72 $RDI_Coords::minValidVels = 4 if ($opt_4); |
77 $RDI_Coords::minValidVels = 4 if ($opt_4); |
73 |
78 |
74 &antsFloatOpt($opt_l); |
79 &antsFloatOpt($opt_l); |
151 # Step 3: Read CTD data |
158 # Step 3: Read CTD data |
152 #---------------------------------------------------------------------- |
159 #---------------------------------------------------------------------- |
153 |
160 |
154 print(STDERR "Reading CTD data ($CTD_file)..."); |
161 print(STDERR "Reading CTD data ($CTD_file)..."); |
155 readCTD($CTD_file,\%CTD); |
162 readCTD($CTD_file,\%CTD); |
156 printf(STDERR "\n\t%d scans\n",scalar(@{$CTD{press}})); |
163 printf(STDERR "\n\t%d scans",scalar(@{$CTD{press}})) if ($opt_d); |
|
164 print(STDERR "\n"); |
157 |
165 |
158 #---------------------------------------------------------------------- |
166 #---------------------------------------------------------------------- |
159 # Step 4: Pre-Process CTD & LADCP Data |
167 # Step 4: Pre-Process CTD & LADCP Data |
160 #---------------------------------------------------------------------- |
168 #---------------------------------------------------------------------- |
161 |
169 |
162 printf(STDERR "Pre-processing data..."); |
170 printf(STDERR "Pre-processing data..."); |
163 printf(STDERR "\n\tCTD..."); |
171 printf(STDERR "\n\tCTD...") if ($opt_d); |
164 |
172 |
165 #------------------------ |
173 #------------------------ |
166 # clean CTD pressure data |
174 # clean CTD pressure data |
167 #------------------------ |
175 #------------------------ |
168 my($pSpikes) = 0; |
176 my($pSpikes) = 0; |
285 |
291 |
286 $opt_l = defined($opt_l) ? -$opt_l : &lagLADCP2CTD(); |
292 $opt_l = defined($opt_l) ? -$opt_l : &lagLADCP2CTD(); |
287 |
293 |
288 print(STDERR "Associating CTD data with LADCP ensembles..."); |
294 print(STDERR "Associating CTD data with LADCP ensembles..."); |
289 |
295 |
290 for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
296 for (my($min_depth)=9e99,my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
291 my($lastSvel); |
297 my($lastSvel); |
292 my($r) = int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint}); |
298 my($r) = int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint}); |
293 if ($r < 0 && $ens == $LADCP_start) { |
299 if ($r < 0 && $ens == $LADCP_start) { |
294 $r = int(($LADCP{ENSEMBLE}[++$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint}) |
300 $r = int(($LADCP{ENSEMBLE}[++$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint}) |
295 while ($r < 0); |
301 while ($r < 0); |
296 printf(STDERR "\n\tCTD data begin with instrument already in water => skipping %ds of LADCP data", |
302 printf(STDERR "\n\tCTD data begin with instrument already in water => skipping %ds of LADCP data", |
297 $LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}); |
303 $LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}); |
298 $LADCP_start = $ens; |
304 $LADCP_start = $ens; |
299 } |
305 } |
300 if ($r > $#{$CTD{press}}) { |
306 if ($r > $#{$CTD{press}}) { |
301 printf(STDERR "\n\tCTD data end while instrument is still in water => truncating %ds of LADCP data", |
307 printf(STDERR "\n\tCTD data end while instrument is still in water => truncating %ds of LADCP data", |
302 $LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}); |
308 $LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}) |
|
309 if ($opt_d); |
303 $LADCP_end = $ens - 1; |
310 $LADCP_end = $ens - 1; |
304 last; |
311 last; |
305 } |
312 } |
306 my($dr); |
313 my($dr); |
307 for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {} |
314 for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {} |
308 $LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{lat}); |
315 $LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{lat}); |
|
316 if ($LADCP{ENSEMBLE}[$ens]->{DEPTH} < $min_depth) { |
|
317 $min_depth = $LADCP{ENSEMBLE}[$ens]->{DEPTH}; |
|
318 $LADCP_top = $ens; |
|
319 } |
309 $LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r]; |
320 $LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r]; |
310 $LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r]; |
321 $LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r]; |
311 $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = sVel($CTD{salin}[$r],$CTD{temp}[$r],$CTD{press}[$r+$dr]); |
322 $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = sVel($CTD{salin}[$r],$CTD{temp}[$r],$CTD{press}[$r+$dr]); |
312 if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) { |
323 if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) { |
313 $lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}; |
324 $lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}; |
321 $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr; |
332 $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr; |
322 $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr; |
333 $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr; |
323 } |
334 } |
324 } |
335 } |
325 |
336 |
326 &antsAddParams('bottom_depth',round($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}), |
337 &antsAddParams('top_depth',,round($LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}), |
|
338 'bottom_depth',round($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}), |
327 'start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE}, |
339 'start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE}, |
328 'start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
340 'start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
329 'bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE}, |
341 'bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE}, |
330 'bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
342 'bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
331 'end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE}, |
343 'end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE}, |
335 |
347 |
336 #---------------------------------------------------------------------- |
348 #---------------------------------------------------------------------- |
337 # Step 6: Calculate Acoustic Backscatter Profile |
349 # Step 6: Calculate Acoustic Backscatter Profile |
338 #---------------------------------------------------------------------- |
350 #---------------------------------------------------------------------- |
339 |
351 |
340 print(STDERR "Finding seabed in acoustic backscatter profiles..."); |
352 print(STDERR "Calculating acoustic backscatter profiles..."); |
341 |
|
342 mk_backscatter_profs($LADCP_start,$LADCP_end); |
353 mk_backscatter_profs($LADCP_start,$LADCP_end); |
343 ($water_depth,$sig_water_depth) = |
|
344 find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
|
345 |
|
346 $min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
347 printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); |
|
348 printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
|
349 |
|
350 print(STDERR "\n"); |
354 print(STDERR "\n"); |
351 |
355 |
352 #---------------------------------------------------------------------- |
356 #---------------------------------------------------------------------- |
353 # Step 7: Find Seabed |
357 # Step 7: Find Seabed |
354 #---------------------------------------------------------------------- |
358 #---------------------------------------------------------------------- |
355 |
359 |
356 print(STDERR "Finding seabed in BT data..."); |
360 if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
357 |
361 |
358 ($BT_water_depth,$sig_BT_water_depth) = |
362 print(STDERR "Finding seabed..."); |
359 find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES}); |
363 |
360 |
364 print(STDERR "\n\tin acoustic backscatter profiles...") if ($opt_d); |
361 if (defined($BT_water_depth)) { |
365 ($water_depth,$sig_water_depth) = |
362 $min_hab = $BT_water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
366 find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
363 printf(STDERR "\n\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth); |
367 |
|
368 $min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
369 printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); |
364 printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
370 printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
365 # $water_depth = $BT_water_depth; # assume BT data are better |
371 |
366 # $sig_water_depth = $sig_BT_water_depth; # (at least they are higher vertical resolution) |
372 print(STDERR "\n\tin RDI BT data...") if ($opt_d); |
367 } |
373 ($BT_water_depth,$sig_BT_water_depth) = |
368 |
374 find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES}); |
369 unless (defined($water_depth)) { |
375 |
370 print(STDERR "\n\tno seabed found\n"); |
376 if (defined($BT_water_depth)) { |
371 print(STDERR "\n\tunknown water depth => PPI editing disabled\n") |
377 $min_hab = $BT_water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
378 printf(STDERR "\n\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth); |
|
379 printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
|
380 # $water_depth = $BT_water_depth; # assume BT data are better |
|
381 # $sig_water_depth = $sig_BT_water_depth; # (at least they are higher vertical resolution) |
|
382 } |
|
383 |
|
384 unless (defined($water_depth)) { |
|
385 print(STDERR "\n\tno seabed found\n"); |
|
386 print(STDERR "\n\tunknown water depth => PPI editing disabled\n") |
|
387 if ($opt_d); |
|
388 $clip_margin = 0; |
|
389 } |
|
390 |
|
391 print(STDERR "\n"); |
|
392 |
|
393 } else { # UPLOOKER |
|
394 $water_depth = $sig_water_depth = $min_hab = nan; |
|
395 print(STDERR "Uplooker data => PPI editing disabled\n") |
372 if ($opt_d); |
396 if ($opt_d); |
373 $clip_margin = 0; |
397 } |
374 } |
|
375 |
|
376 print(STDERR "\n"); |
|
377 |
398 |
378 #---------------------------------------------------------------------- |
399 #---------------------------------------------------------------------- |
379 # Step 8: Edit Data |
400 # Step 8: Edit Data |
380 #---------------------------------------------------------------------- |
401 #---------------------------------------------------------------------- |
381 |
402 |
382 print(STDERR "Calculating shear profiles...\n"); |
403 print(STDERR "Calculating shear profiles..."); |
383 |
404 |
384 $LADCP_start = 1 if ($LADCP_start == 0); # ensure that there is previous ensemble |
405 $LADCP_start = 1 if ($LADCP_start == 0); # ensure that there is previous ensemble |
385 |
406 |
386 print(STDERR "\tdowncast..."); |
407 print(STDERR "\n\tdowncast...") if ($opt_d); |
387 edit_velocity($LADCP_start,$LADCP_bottom); # downcast |
408 edit_velocity($LADCP_start,$LADCP_bottom); # downcast |
388 calc_shear($LADCP_start,$LADCP_bottom,$SHEAR_PREGRID_DZ,0); # pre-grid shear @SHEAR_PREGRID_DZm resolution |
409 calc_shear($LADCP_start,$LADCP_bottom,$SHEAR_PREGRID_DZ,0); # pre-grid shear @SHEAR_PREGRID_DZm resolution |
389 calc_shear($LADCP_start,$LADCP_bottom,$GRID_DZ,1); # calculate final gridded shear profile |
410 calc_shear($LADCP_start,$LADCP_bottom,$GRID_DZ,1); # calculate final gridded shear profile |
390 |
411 |
391 @dc_sh_n = @sh_n; # save downcast results |
412 @dc_sh_n = @sh_n; # save downcast results |
392 @dc_ush_mu = @ush_mu; @dc_ush_sig = @ush_sig; |
413 @dc_ush_mu = @ush_mu; @dc_ush_sig = @ush_sig; |
393 @dc_vsh_mu = @vsh_mu; @dc_vsh_sig = @vsh_sig; |
414 @dc_vsh_mu = @vsh_mu; @dc_vsh_sig = @vsh_sig; |
394 @dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig; |
415 @dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig; |
395 |
416 |
396 print(STDERR "\n\tupcast..."); |
417 print(STDERR "\n\tupcast...") if ($opt_d); |
397 edit_velocity($LADCP_end,$LADCP_bottom); # upcast |
418 edit_velocity($LADCP_end,$LADCP_bottom); # upcast |
398 calc_shear($LADCP_end,$LADCP_bottom,$SHEAR_PREGRID_DZ,0); |
419 calc_shear($LADCP_end,$LADCP_bottom,$SHEAR_PREGRID_DZ,0); |
399 calc_shear($LADCP_end,$LADCP_bottom,$GRID_DZ,1); |
420 calc_shear($LADCP_end,$LADCP_bottom,$GRID_DZ,1); |
400 |
421 |
401 @uc_sh_n = @sh_n; # save upcast results |
422 @uc_sh_n = @sh_n; # save upcast results |
402 @uc_ush_mu = @ush_mu; @uc_ush_sig = @ush_sig; |
423 @uc_ush_mu = @ush_mu; @uc_ush_sig = @ush_sig; |
403 @uc_vsh_mu = @vsh_mu; @uc_vsh_sig = @vsh_sig; |
424 @uc_vsh_mu = @vsh_mu; @uc_vsh_sig = @vsh_sig; |
404 @uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig; |
425 @uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig; |
405 |
426 |
406 print(STDERR "\n\tcombined..."); |
427 print(STDERR "\n\tcombined...") if ($opt_d); |
407 for (my($gi)=0; $gi<@dc_ush_mu; $gi++) { |
428 for (my($gi)=0; $gi<@dc_ush_mu; $gi++) { |
408 if ($dc_sh_n[$gi]>0 && $uc_sh_n[$gi]>0) { |
429 if ($dc_sh_n[$gi]>0 && $uc_sh_n[$gi]>0) { |
409 $sh_n[$gi] = $dc_sh_n[$gi] + $uc_sh_n[$gi]; |
430 $sh_n[$gi] = $dc_sh_n[$gi] + $uc_sh_n[$gi]; |
410 $ush_mu[$gi] = ($dc_sh_n[$gi]*$dc_ush_mu[$gi] + $uc_sh_n[$gi]*$uc_ush_mu[$gi]) / $sh_n[$gi]; |
431 $ush_mu[$gi] = ($dc_sh_n[$gi]*$dc_ush_mu[$gi] + $uc_sh_n[$gi]*$uc_ush_mu[$gi]) / $sh_n[$gi]; |
411 $vsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_vsh_mu[$gi] + $uc_sh_n[$gi]*$uc_vsh_mu[$gi]) / $sh_n[$gi]; |
432 $vsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_vsh_mu[$gi] + $uc_sh_n[$gi]*$uc_vsh_mu[$gi]) / $sh_n[$gi]; |
432 |
453 |
433 #---------------------------------------------------------------------- |
454 #---------------------------------------------------------------------- |
434 # Step 9: Get bottom track profile |
455 # Step 9: Get bottom track profile |
435 #---------------------------------------------------------------------- |
456 #---------------------------------------------------------------------- |
436 |
457 |
437 print(STDERR "Getting BT profile..."); |
458 if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
438 getBTprof($LADCP_start,$LADCP_end); |
459 print(STDERR "Getting BT profile..."); |
439 print(STDERR "\n"); |
460 getBTprof($LADCP_start,$LADCP_end); |
440 |
461 print(STDERR "\n"); |
441 #---------------------------------------------------------------------- |
462 } |
442 # Step 10: Write Output |
463 |
|
464 #---------------------------------------------------------------------- |
|
465 # Step 10: Write Output Files |
443 #---------------------------------------------------------------------- |
466 #---------------------------------------------------------------------- |
444 |
467 |
445 print(STDERR "Writing shear profiles..."); |
468 print(STDERR "Writing shear profiles..."); |
446 |
469 |
447 @antsNewLayout = ('depth','dc_nshear','dc_u_z','dc_u_z.sig','dc_v_z','dc_v_z.sig','dc_w_z','dc_w_z.sig', |
470 @antsNewLayout = ('depth','dc_nshear','dc_u_z','dc_u_z.sig','dc_v_z','dc_v_z.sig','dc_w_z','dc_w_z.sig', |
458 'e_max',$e_max,'min_cor',$min_cor, |
481 'e_max',$e_max,'min_cor',$min_cor, |
459 'max_shdev',$max_shdev,'max_shdev_sum',$max_shdev_sum, |
482 'max_shdev',$max_shdev,'max_shdev_sum',$max_shdev_sum, |
460 'water_depth',round($water_depth),'water_depth.sig',round($sig_water_depth), |
483 'water_depth',round($water_depth),'water_depth.sig',round($sig_water_depth), |
461 'min_hab',round($min_hab), |
484 'min_hab',round($min_hab), |
462 'clip_margin',$clip_margin,'first_clip_bin',$first_clip_bin, |
485 'clip_margin',$clip_margin,'first_clip_bin',$first_clip_bin, |
463 'Svbin_start',$Svbin_start,'Svbin_end',$Svbin_end); |
486 'Svbin_start',$Svbin_start,'Svbin_end',$Svbin_end, |
|
487 'BT_bin_start',$BT_bin_start,'BT_bin_search_above',$BT_bin_search_above, |
|
488 'BT_max_bin_spread',$BT_max_bin_spread,'BT_max_w_difference',$BT_max_w_difference, |
|
489 ); |
|
490 if (defined($BT_min_depth)) { |
|
491 &antsAddParams('BT_min_depth',$BT_min_depth,'BT_max_depth',$BT_max_depth); |
|
492 } else { |
|
493 &antsAddParams('BT_max_depth_error',$BT_max_depth_error); |
|
494 } |
464 |
495 |
465 for (my($gi)=0; $gi<@ush_mu; $gi++) { |
496 for (my($gi)=0; $gi<@ush_mu; $gi++) { |
466 &antsOut(depthOfGI($gi), # depth in center of bin |
497 &antsOut(depthOfGI($gi), # depth in center of bin |
467 numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0, # downcast |
498 numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0, # downcast |
468 $dc_ush_mu[$gi],$dc_ush_sig[$gi], |
499 $dc_ush_mu[$gi],$dc_ush_sig[$gi], |
481 ); |
512 ); |
482 } |
513 } |
483 |
514 |
484 print(STDERR "\n"); |
515 print(STDERR "\n"); |
485 |
516 |
486 #---------------------------------------------------------------------- |
517 #--------------------------------------- |
|
518 # Acoustic backscatter depth-time-series |
|
519 #--------------------------------------- |
487 |
520 |
488 if (defined($opt_a)) { |
521 if (defined($opt_a)) { |
489 print(STDERR "Writing per-bin acoustic backscatter profiles..."); |
522 print(STDERR "Writing acoustic backscatter depth-time-series to <$opt_a>..."); |
490 |
523 |
491 for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
524 |
492 my($fn) = sprintf("bin%02d.Sv",$bin); |
525 @antsNewLayout = ('ens','elapsed','CTD_depth','depth','bin','downcast', |
493 print(STDERR " $fn"); |
526 'Sv_beam1','Sv_beam2','Sv_beam3','Sv_beam4','Sv.median'); |
494 |
527 &antsOut('EOF'); |
495 @antsNewLayout = ('depth','Sv'); |
528 close(STDOUT); |
496 &antsOut('EOF'); |
529 open(STDOUT,">$opt_a") || croak("$opt_a: $!\n"); |
497 $antsCurParams = $commonParams; |
530 |
498 close(STDOUT); |
531 $antsCurParams = $commonParams; |
499 open(STDOUT,">$fn") || croak("$fn: $!\n"); |
532 &antsAddParams('min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}, |
500 |
533 'max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}, |
501 for (my($gi)=0; $gi<@sSv; $gi++) { |
534 'min_depth',$LADCP{ENSEMBLE}[$LADCP_top]->{XDUCER_FACING_UP} ? |
502 &antsOut(depthOfGI($gi), |
535 &depthOfBin($LADCP_top,$LADCP{N_BINS}-1) : $LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}, |
503 $nSv[$gi][$bin] ? $sSv[$gi][$bin]/ $nSv[$gi][$bin] : nan); |
536 'max_depth',$LADCP{ENSEMBLE}[$LADCP_bottom]->{XDUCER_FACING_UP} ? |
504 } |
537 $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} : &depthOfBin($LADCP_bottom,$LADCP{N_BINS}-1) |
505 } |
538 ); |
|
539 |
|
540 for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
541 for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
542 &antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
|
543 $LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}, |
|
544 $LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
|
545 &depthOfBin($ens,$bin),$bin, |
|
546 ($ens <= $LADCP_bottom) ? 1 : 0, |
|
547 @{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}, |
|
548 median(@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}) |
|
549 ); |
|
550 } |
|
551 } |
|
552 |
506 print(STDERR "\n"); |
553 print(STDERR "\n"); |
507 } |
554 } |
508 |
555 |
509 #---------------------------------------------------------------------- |
556 #---------------------------------------------------------------------- |
510 |
557 |
511 if (defined($opt_t)) { |
558 if (defined($opt_t)) { |
512 print(STDERR "Writing time series to $opt_t..."); |
559 print(STDERR "Writing time series to <$opt_t>..."); |
513 |
560 |
514 @antsNewLayout = ('ens','elapsed','depth','CTD_w','LADCP_w'); |
561 @antsNewLayout = ('ens','elapsed','depth','CTD_w','LADCP_w'); |
515 &antsOut('EOF'); |
562 &antsOut('EOF'); |
516 $antsCurParams = $commonParams; |
563 $antsCurParams = $commonParams; |
517 close(STDOUT); |
564 close(STDOUT); |