1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 #====================================================================== |
2 #====================================================================== |
3 # L A D C P _ W _ O C E A N |
3 # L A D C P _ W _ O C E A N |
4 # doc: Fri Dec 17 18:11:13 2010 |
4 # doc: Fri Dec 17 18:11:13 2010 |
5 # dlm: Mon Jun 29 11:03:22 2020 |
5 # dlm: Tue Mar 23 09:16:10 2021 |
6 # (c) 2010 A.M. Thurnherr |
6 # (c) 2010 A.M. Thurnherr |
7 # uE-Info: 306 76 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 308 65 NIL 0 0 72 2 2 4 NIL ofnI |
8 #====================================================================== |
8 #====================================================================== |
9 |
9 |
10 # TODO: |
10 # TODO: |
11 # ! use instrument tilt in sidelobe editing |
11 # ! use instrument tilt in sidelobe editing |
12 # - use instrument tilt in e.g. calculation of Sv |
12 # - use instrument tilt in e.g. calculation of Sv |
302 # - BUG: before re-binning, upcast v12 and v34 were actuall from DC data |
302 # - BUG: before re-binning, upcast v12 and v34 were actuall from DC data |
303 # - BUG: all beam-pair velocity stats were contaminated by missing values |
303 # - BUG: all beam-pair velocity stats were contaminated by missing values |
304 # - made bin residuals per beam pair |
304 # - made bin residuals per beam pair |
305 # May 16, 2020: - BUG: write_residual_profs() clobbered layout |
305 # May 16, 2020: - BUG: write_residual_profs() clobbered layout |
306 # Jun 22, 2020: - sscorr_w renamed to remove conflict with [RDI_Coords.pl] |
306 # Jun 22, 2020: - sscorr_w renamed to remove conflict with [RDI_Coords.pl] |
|
307 # Mar 17, 2021: - turned multi-ping error into warning (for Nortek files) |
|
308 # Mar 23, 3021: - adapted to ADCP_tools V2.4 (Nortek PD0 files) |
307 # HISTORY END |
309 # HISTORY END |
308 |
310 |
309 # CTD REQUIREMENTS |
311 # CTD REQUIREMENTS |
310 # - elapsed elapsed seconds; see note below |
312 # - elapsed elapsed seconds; see note below |
311 # - depth |
313 # - depth |
607 while ($ens < @{$LADCP{ENSEMBLE}} && $LADCP{ENSEMBLE}[$ens]->{NUMBER}<$valid_ensemble_range[1]) { $ens++ } |
609 while ($ens < @{$LADCP{ENSEMBLE}} && $LADCP{ENSEMBLE}[$ens]->{NUMBER}<$valid_ensemble_range[1]) { $ens++ } |
608 splice(@{$LADCP{ENSEMBLE}},$ens); |
610 splice(@{$LADCP{ENSEMBLE}},$ens); |
609 progress("\t%d invalid trailing ensembles removed\n",@{$LADCP{ENSEMBLE}}-$ens) |
611 progress("\t%d invalid trailing ensembles removed\n",@{$LADCP{ENSEMBLE}}-$ens) |
610 } |
612 } |
611 |
613 |
612 error("$LADCP_file: cannot process multi-ping ensembles\n") |
614 warning(2,"$LADCP_file: multi-ping ensembles\n") |
613 unless ($LADCP{PINGS_PER_ENSEMBLE} == 1); |
615 unless ($LADCP{PINGS_PER_ENSEMBLE} == 1); |
614 warning(2,"$LADCP_file: wide-bandwidth setting\n") |
616 warning(2,"$LADCP_file: wide-bandwidth setting\n") |
615 if ($LADCP{WIDE_BANDWIDTH}); |
617 if ($LADCP{WIDE_BANDWIDTH}); |
616 warning(2,"$LADCP_file: low transmit-power setting\n") |
618 warning(2,"$LADCP_file: low transmit-power setting\n") |
617 unless ($LADCP{TRANSMIT_POWER_HIGH}); |
619 unless ($LADCP{TRANSMIT_POWER_MAX}); |
618 |
620 |
619 error("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n") |
621 error("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n") |
620 unless ($LADCP{N_BINS} >= $refLr_lastBin); |
622 unless ($LADCP{N_BINS} >= $refLr_lastBin); |
621 |
623 |
622 error("$0: first reference-layer bin outside valid range\n") |
624 error("$0: first reference-layer bin outside valid range\n") |
1337 &antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft); |
1339 &antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft); |
1338 } else { |
1340 } else { |
1339 &antsAddParams('sidelobe_editing','seabed'); |
1341 &antsAddParams('sidelobe_editing','seabed'); |
1340 } |
1342 } |
1341 |
1343 |
1342 if (&PPI_seabed_editing_required()) { |
1344 # Setting $DEBUG_DL_SURFACE_PPI_EDITING to 1 enables sea-surface PPI editing for |
1343 &antsAddParams('PPI_editing','seabed'); |
1345 # downlookers (but disabled seabed editing). This was used on 2021 A20 for testing. |
|
1346 |
|
1347 if ($DEBUG_DL_SURFACE_PPI_EDITING) { |
|
1348 &antsAddParams('PPI_editing','surface'); |
1344 &antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
1349 &antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
1345 if numberp($PPI_extend_upper_limit); |
1350 if numberp($PPI_extend_upper_limit); |
1346 progress("Editing data to remove PPI from seabed...\n"); |
1351 progress("Editing data to remove PPI from sea surface...\n"); |
1347 progress("\tConstructing depth-average soundspeed profile...\n"); |
1352 progress("\tConstructing depth-average soundspeed profile...\n"); |
1348 die("assertion failed") unless defined($water_depth); |
1353 $DASSprof[0] = my($sum) = 0; |
1349 my($dz) = $water_depth - $#sVelProf; # $#sVelProf = max_depth(profile) in meters |
1354 for (my($d)=1; $d<=$#sVelProf; $d++) { |
1350 my($sum) = $dz * $sVelProf[$#sVelProf]; |
1355 die("assertion failed") unless numberp($sVelProf[$d]); |
1351 if ($dz == 0) { # water-depth <= max CTD depth |
|
1352 warning(1,"inferred water depth very close to max(CTD depth)\n"); |
|
1353 $DASSprof[$#sVelProf] = $sVelProf[$#sVelProf]; |
|
1354 } else { |
|
1355 die("assertion failed") unless defined($dz > 0); |
|
1356 $DASSprof[$#sVelProf] = $sum/$dz; |
|
1357 } |
|
1358 for (my($d)=$#sVelProf-1; $d>=0; $d--) { |
|
1359 die("assertion failed (d=$d, #sVelProf=$#sVelProf)") unless numberp($sVelProf[$d]); |
|
1360 $sum += $sVelProf[$d]; |
1356 $sum += $sVelProf[$d]; |
1361 $dz++; |
1357 $DASSprof[$d] = $sum/$d; |
1362 $DASSprof[$d] = $sum/$dz; |
1358 } |
1363 } |
1359 ($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,undef); |
1364 ($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,$water_depth); |
|
1365 progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
1360 progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
1361 } else { |
|
1362 if (&PPI_seabed_editing_required()) { |
|
1363 &antsAddParams('PPI_editing','seabed'); |
|
1364 &antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit) |
|
1365 if numberp($PPI_extend_upper_limit); |
|
1366 progress("Editing data to remove PPI from seabed...\n"); |
|
1367 progress("\tConstructing depth-average soundspeed profile...\n"); |
|
1368 die("assertion failed") unless defined($water_depth); |
|
1369 my($dz) = $water_depth - $#sVelProf; # $#sVelProf = max_depth(profile) in meters |
|
1370 my($sum) = $dz * $sVelProf[$#sVelProf]; |
|
1371 if ($dz == 0) { # water-depth <= max CTD depth |
|
1372 warning(1,"inferred water depth very close to max(CTD depth)\n"); |
|
1373 $DASSprof[$#sVelProf] = $sVelProf[$#sVelProf]; |
|
1374 } else { |
|
1375 die("assertion failed") unless defined($dz > 0); |
|
1376 $DASSprof[$#sVelProf] = $sum/$dz; |
|
1377 } |
|
1378 for (my($d)=$#sVelProf-1; $d>=0; $d--) { |
|
1379 die("assertion failed (d=$d, #sVelProf=$#sVelProf)") unless numberp($sVelProf[$d]); |
|
1380 $sum += $sVelProf[$d]; |
|
1381 $dz++; |
|
1382 $DASSprof[$d] = $sum/$dz; |
|
1383 } |
|
1384 ($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,$water_depth); |
|
1385 progress("\t$nvrm velocities from $nerm ensembles removed\n"); |
|
1386 } |
1366 } |
1387 } |
1367 } |
1388 } |
1368 |
1389 |
1369 } else { # UPLOOKER |
1390 } else { # UPLOOKER |
1370 &antsAddParams('ADCP_orientation','UL'); |
1391 &antsAddParams('ADCP_orientation','UL'); |