# HG changeset patch # User A.M. Thurnherr # Date 1373633220 0 # Node ID 0f89b15236486f1a23499d821cd3bc2dd3654cac # Parent 9c3b147b4372c58a6dfc20f18f88afb7cfb0300f V1.1 diff --git a/HISTORY b/HISTORY --- a/HISTORY +++ b/HISTORY @@ -1,9 +1,9 @@ ====================================================================== H I S T O R Y doc: Tue May 15 18:04:39 2012 - dlm: Tue May 15 18:31:09 2012 + dlm: Fri Jul 12 12:46:50 2013 (c) 2012 A.M. Thurnherr - uE-Info: 10 18 NIL 0 0 72 3 2 8 NIL ofnI + uE-Info: 17 30 NIL 0 0 72 3 2 8 NIL ofnI ====================================================================== May 15, 2012: @@ -11,3 +11,8 @@ - began history - uploaded current version to server for use with first version of re-implemented shear method + +Jul 11, 2013: + - V1.1 [.hg/hgrc] + - various minor improvements + diff --git a/RDI_BB_Read.pl b/RDI_BB_Read.pl --- a/RDI_BB_Read.pl +++ b/RDI_BB_Read.pl @@ -1,9 +1,9 @@ #====================================================================== # R D I _ B B _ R E A D . P L # doc: Sat Jan 18 14:54:43 2003 -# dlm: Mon Mar 25 21:38:37 2013 +# dlm: Mon Apr 29 12:49:40 2013 # (c) 2003 A.M. Thurnherr -# uE-Info: 632 0 NIL 0 0 72 74 2 4 NIL ofnI +# uE-Info: 53 46 NIL 0 0 72 74 2 4 NIL ofnI #====================================================================== # Read RDI BroadBand Binary Data Files (*.[0-9][0-9][0-9]) @@ -49,6 +49,8 @@ # Mar 19, 2013: - added support for WH600 data file (58 fixed leader bytes) # Mar 20, 2013: - removed DATA_FORMAT stuff # - added support for BT data in subset of ensembles +# Apr 29, 2013: - changed semantics to assume EOF when unexpected number of data types +# are present in an ensemble # FIRMWARE VERSIONS: # It appears that different firmware versions generate different file @@ -532,7 +534,7 @@ ($hid,$did,$ens_length,$dummy,$ndt) = unpack('CCvCC',$buf); $hid == 0x7f || die(sprintf($FmtErr,$WBRcfn,"Header",$hid,0)); $did == 0x7f || die(sprintf($FmtErr,$WBRcfn,"Data Source",$did,0)); - printf(STDERR "\n$WBRcfn: WARNING: unexpected number of data types (%d)\n",$ndt) + printf(STDERR "\n$WBRcfn: WARNING: unexpected number of data types (%d, ens=$ens)\n",$ndt),last unless ($ndt == 6 || $ndt == 7); $BT_present = ($ndt == 7); read(WBRF,$buf,2*$ndt) == 2*$ndt || die("$WBRcfn: $!"); diff --git a/RDI_Utils.pl b/RDI_Utils.pl --- a/RDI_Utils.pl +++ b/RDI_Utils.pl @@ -1,9 +1,9 @@ #====================================================================== # R D I _ U T I L S . P L # doc: Wed Feb 12 10:21:32 2003 -# dlm: Fri Apr 12 09:22:10 2013 +# dlm: Thu Jun 20 15:26:47 2013 # (c) 2003 A.M. Thurnherr -# uE-Info: 44 68 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 125 0 NIL 0 0 72 2 2 4 NIL ofnI #====================================================================== # miscellaneous RDI-specific utilities @@ -42,6 +42,9 @@ # Mar 27, 2013: - BUG: 3-beam solutions were not used in ref_lr_w # - disabled apparently unused code # Apr 12, 2013: - added $min_pctg as optional parameter to mk_prof +# May 14, 2013: - added incident-velocity, w12 & w34 to mkProfile +# Jun 5, 2013: - BUG: incident-flow warning was printed repeatedly +# Jun 20, 2013: - BUG: warning had used &antsInfo() use strict; @@ -218,10 +221,15 @@ # mk_prof($dta,$check,$filter,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap); #====================================================================== -sub ref_lr_w($$$$$$$) # calc ref-level vert vels +# calculate reference-layer vertical and incident velocities + +{ my($warned); # static scope + +sub ref_lr_w($$$$$$$) { my($dta,$ens,$rl_b0,$rl_b1,$min_corr,$max_e,$min_pctg) = @_; - my($i,@n,@bn,@v,@vel,@bv,@w); + my($i,@n,@bn,@v,@vi,@vel,@veli,@bv,@w); + my($w,$e,$nvi,$vi12,$vi43,@vbp,@velbp,@nbp,$w12,$w34,@w12,@w34); for ($i=$rl_b0; $i<=$rl_b1; $i++) { undef($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][0]) @@ -241,26 +249,44 @@ if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] < $min_pctg); undef($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][3]) if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < $min_pctg); - @v = velInstrumentToEarth($dta,$ens, - velBeamToInstrument($dta, - @{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]})); + @vi = velBeamToInstrument($dta,@{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]}); + @v = velInstrumentToEarth($dta,$ens,@vi); + @vbp = velBeamToBPEarth($dta,$ens,@{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]}); } else { next if ($dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][0] > 0 || $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][1] > 0 || $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] > 0 || $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < $min_pctg); @v = @{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]}; - # NB: no need to apply heading bias, as long as we only use w! + unless ($warned) { + print(STDERR "WARNING: incident-flow & beam-pair velocities not yet implemented for earth coordinates"); + $warned = 1; + } } ### next if (!defined($v[3]) || abs($v[3]) > $max_e); # disallow 3-beam solutions next if (defined($v[3]) && abs($v[3]) > $max_e); # allow 3-beam solutions - if (defined($v[2])) { # valid w - $vel[2] += $v[2]; $n[2]++; - $vel[3] += $v[3], $n[3]++ if defined($v[3]); - push(@w,$v[2]); # for stderr test + if (defined($v[2])) { # valid velocity + $vel[2] += $v[2]; $n[2]++; # vertical velocity + $vel[3] += $v[3], $n[3]++ if defined($v[3]); # error velocity + push(@w,$v[2]); # save for stderr calculation + } + + if (defined($vbp[1])) { # beam-pair vertical velocities + $velbp[0] += $vbp[1]; $nbp[0]++; + push(@w12,$vbp[1]); + } + if (defined($vbp[3])) { + $velbp[1] += $vbp[3]; $nbp[1]++; + push(@w34,$vbp[1]); } + if (defined($vi[0])) { # incident velocity + $veli[0] += $vi[0]; + $veli[1] += $vi[1]; + $nvi++; + } + # The following code calculates beam-averaged ref-lr velocities. # I do not recall what this was implemented for. Disabled Mar 27, 2013. # @@ -274,22 +300,63 @@ # $bv[3] += $dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][3], $bn[3]++ # if defined($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i][3]); # } + } # loop over ref-lr bins + + $w = ($n[2] > 0) ? $vel[2]/$n[2] : undef; # calc means + $e = ($n[3] > 0) ? $vel[3]/$n[3] : undef; + if ($nvi > 0) { + $vi12 = $veli[0] / $nvi; + $vi43 = $veli[1] / $nvi; + } else { + $vi12 = $vi43 = undef; + } + $w12 = ($nbp[0] > 0) ? $velbp[0]/$nbp[0] : undef; + $w34 = ($nbp[1] > 0) ? $velbp[1]/$nbp[1] : undef; + + if (@w12) { # w uncertainty + my($sumsq) = 0; + for ($i=0; $i<=$#w12; $i++) { + $sumsq += ($w12-$w12[$i])**2; + } + $dta->{ENSEMBLE}[$ens]->{W12} = $w12; + $dta->{ENSEMBLE}[$ens]->{W12_ERR} = sqrt($sumsq)/($nbp[0]-1) + if ($nbp[0]>=2); } - my($w) = $n[2] ? $vel[2]/$n[2] : undef; # w uncertainty - my($sumsq) = 0; + if (@w34) { # w uncertainty + my($sumsq) = 0; + for ($i=0; $i<=$#w34; $i++) { + $sumsq += ($w34-$w34[$i])**2; + } + $dta->{ENSEMBLE}[$ens]->{W34} = $w34; + $dta->{ENSEMBLE}[$ens]->{W34_ERR} = sqrt($sumsq)/($nbp[1]-1) + if ($nbp[1]>=2); + } + + my($sumsq) = 0; # w uncertainty for ($i=0; $i<=$#w; $i++) { $sumsq += ($w-$w[$i])**2; } my($stderr) = $n[2]>=2 ? sqrt($sumsq)/($n[2]-1) : undef; + # The following stderr test introduces a huge gap near the bottom of # the profiles. Without it, they seem more reasonable. # next if ($stderr > 0.05); - if (defined($w)) { # valid w + if (defined($w)) { # valid velocity $dta->{ENSEMBLE}[$ens]->{W} = $w; $dta->{ENSEMBLE}[$ens]->{W_ERR} = $stderr; } + $dta->{ENSEMBLE}[$ens]->{ERR_VEL} = $e if (defined($e)); + + $dta->{ENSEMBLE}[$ens]->{W12} = $w12 if (defined($w12)); + $dta->{ENSEMBLE}[$ens]->{W34} = $w34 if (defined($w34)); + + if (defined($vi12)) { + $dta->{ENSEMBLE}[$ens]->{INCIDENT_VEL_T12} = $vi12; + $dta->{ENSEMBLE}[$ens]->{INCIDENT_VEL_T43} = $vi43; + } + # The following code calculates beam-averaged ref-lr velocities. # I do not recall what this was implemented for. Disabled Mar 27, 2013. # @@ -299,8 +366,11 @@ # $dta->{ENSEMBLE}[$ens]->{V3} = $bn[2]>=2 ? $bv[2]/$bn[2] : undef; # $dta->{ENSEMBLE}[$ens]->{V4} = $bn[3]>=2 ? $bv[3]/$bn[3] : undef; # } + } +} # static scope + sub mk_prof(...) # make profile { diff --git a/checkIX b/checkIX --- a/checkIX +++ b/checkIX @@ -2,37 +2,47 @@ #====================================================================== # C H E C K I X # doc: Wed Dec 12 15:58:56 2012 -# dlm: Wed Dec 12 16:27:11 2012 +# dlm: Mon Apr 22 15:17:17 2013 # (c) 2012 A.M. Thurnherr -# uE-Info: 31 0 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 43 0 NIL 0 0 72 2 2 4 NIL ofnI #====================================================================== # HISTORY: # Dec 12, 2012: - created -die("Usage: $0 \n") - unless (@ARGV == 1); +die("Usage: $0 \n") + unless (@ARGV > 0); + +foreach my $id (`count @ARGV`) { -$id = $ARGV[0]; # determine station id -$id = sprintf('%03d',$id) - unless (-f "$id.lad"); + $id = sprintf('%03d',$id) + unless (-f "$id.log"); + + unless (-f "$id.log") { + print(STDERR "$id: missing station\n"); + next; + } -die("file <$id.lad> missing\n") # ensure required output is here - unless (-f "$id.lad"); -die("file <$id.log> missing\n") - unless (-f "$id.log"); -die("file <$id.mat> missing\n") - unless (-f "$id.mat"); -die("file <$id.txt> missing\n") - unless (-f "$id.txt"); + die("$id: file <$id.lad> missing\n") # ensure required output is here + unless (-f "$id.lad"); + die("$id: file <$id.log> missing\n") + unless (-f "$id.log"); + die("$id: file <$id.mat> missing\n") + unless (-f "$id.mat"); + die("$id: file <$id.txt> missing\n") + unless (-f "$id.txt"); + + if (-f "${id}_11.ps" && # handle warnings figure + length(`grep 'LADCP profile OK' ${id}_11.ps`) == 0) { + print("$id: warnings produced\n"); + system("gv ${id}_11.ps &"); + } + + print("$id: no valid BT data\n") # check validity of ancillary data + unless (-f "$id.bot"); + print("$id: no valid SADCP data\n") + unless (length(`grep 'all SADCP values removed' $id.log`) == 0); -if (-f "${id}_11.ps" && # handle warnings figure - length(`grep 'LADCP profile OK' ${id}_11.ps`) == 0) { - print("warnings produced\n"); - system("gv ${id}_11.ps &"); } -print("no valid BT data\n") # check validity of ancillary data - unless (-f "$id.bot"); -print("no valid SADCP data\n") - unless (length(`grep 'all SADCP values removed' $id.log`) == 0); +exit(0); diff --git a/listBins b/listBins --- a/listBins +++ b/listBins @@ -2,9 +2,9 @@ #====================================================================== # L I S T B I N S # doc: Fri Aug 25 15:57:05 2006 -# dlm: Sun Aug 22 22:40:32 2010 +# dlm: Mon Apr 29 11:50:06 2013 # (c) 2006 A.M. Thurnherr -# uE-Info: 45 28 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 108 20 NIL 0 0 72 2 2 4 NIL ofnI #====================================================================== # Split data file into per-bin time series. @@ -43,6 +43,8 @@ # May 22, 2009: - added -B) # May 23, 2009: - adapted to changed beampair-velocity fun name # Aug 22, 2010: - added -R +# Apr 29, 2013: - cosmetics +# - added warning on missing -S # General Notes: # - everything (e.g. beams) is numbered from 1 @@ -76,7 +78,7 @@ "[-S)oundspeed correction " . "[-P)itch/Roll ] [-B)eamvel ] " . "[require -4)-beam solutions] [-d)iscard ] " . - "[-%)good ] " . + "[-p)ct-good ] " . "[output -b)eam coordinates] [output two separate -w) estimates] " . "\n") unless (&Getopts("4abB:d:f:M:p:r:P:RS:w") && @ARGV == 1); @@ -103,9 +105,12 @@ ($first_ens,$last_ens) = split(',',$opt_r) if defined($opt_r); -($SS_salin,$SS_temp,$SS_depth) = split(',',$opt_S) - if defined($opt_S); -$variable_ssCorr = ($SS_salin eq '*' || $SS_temp eq '*' || $SS_depth eq '*'); +if (defined($opt_S)) { + ($SS_salin,$SS_temp,$SS_depth) = split(',',$opt_S); + $variable_ssCorr = ($SS_salin eq '*' || $SS_temp eq '*' || $SS_depth eq '*'); +} else { + print(STDERR "WARNING: no soundspeed correction applied!\n"); +} #---------------------------------------------------------------------- diff --git a/mkProfile b/mkProfile --- a/mkProfile +++ b/mkProfile @@ -2,9 +2,9 @@ #====================================================================== # M K P R O F I L E # doc: Sun Jan 19 18:55:26 2003 -# dlm: Fri Apr 12 09:24:14 2013 +# dlm: Tue May 14 11:37:04 2013 # (c) 2003 A.M. Thurnherr -# uE-Info: 269 72 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 169 15 NIL 0 0 72 2 2 4 NIL ofnI #====================================================================== # Make an LADCP Profile by Integrating W (similar to Firing's scan*). @@ -79,6 +79,10 @@ # valid velocities # Sep 21, 2010: - added %rms_heave_acceleration # Apr 12, 2013: - added -p +# May 10, 2013: - BUG: mkProfile bombed when ADCP file is truncated at deepest location +# May 14, 2013: - added heading to output +# - added err_vel to output +# - finally removed -d/-g # NOTES: # - the battery values are based on transmission voltages (different @@ -104,15 +108,14 @@ die("Usage: $0 " . "[-Q)uiet] [-F)ilter