# HG changeset patch # User A.M. Thurnherr # Date 1401826454 14400 # Node ID e23a5fd2923adab8edd0b926f636d571e42f0f1b # Parent bb7bb9f83db93eff5e6b73396f76d7acb3637a75 after adapting RDI_Coords to calc w even without valid heading diff --git a/RDI_Coords.pl b/RDI_Coords.pl --- a/RDI_Coords.pl +++ b/RDI_Coords.pl @@ -1,9 +1,9 @@ #====================================================================== # R D I _ C O O R D S . P L # doc: Sun Jan 19 17:57:53 2003 -# dlm: Tue Mar 4 13:35:21 2014 +# dlm: Thu May 29 09:19:54 2014 # (c) 2003 A.M. Thurnherr -# uE-Info: 273 60 NIL 0 0 72 0 2 4 NIL ofnI +# uE-Info: 282 0 NIL 0 0 72 0 2 4 NIL ofnI #====================================================================== # RDI Workhorse Coordinate Transformations @@ -34,7 +34,11 @@ # Aug 7, 2013: - BUG: &velBeamToBPInstrument did not return any val unless # all beam velocities are defined # Nov 27, 2013: - added &RDI_pitch(), &tilt_azimuth() -# Mar 4, 2014: - added support for missing PITCH/ROLL/HEADING +# Mar 4, 2014: - added support for ensembles with missing PITCH/ROLL/HEADING +# May 29, 2014: - BUG: vertical velocity can be calculated even without +# heading +# - removed some old debug statements +# - removed unused code from &velBeamToBPInstrument use strict; use POSIX; @@ -65,7 +69,6 @@ >= $RDI_Coords::minValidVels); unless (@B2I) { -# print(STDERR "RDI_Coords::minValidVels = $RDI_Coords::minValidVels\n"); my($a) = 1 / (2 * sin(rad($dta->{BEAM_ANGLE}))); my($b) = 1 / (4 * cos(rad($dta->{BEAM_ANGLE}))); my($c) = $dta->{CONVEX_BEAM_PATTERN} ? 1 : -1; @@ -74,7 +77,6 @@ [0, 0, -$c*$a, $c*$a], [$b, $b, $b, $b ], [$d, $d, -$d, -$d ]); -# print(STDERR "@{$B2I[0]}\n@{$B2I[1]}\n@{$B2I[2]}\n@{$B2I[3]}\n"); } if (!defined($v1)) { # 3-beam solutions @@ -114,22 +116,21 @@ return undef unless (defined($v1) && defined($v2) && defined($v3) && defined($v4) && defined($dta->{ENSEMBLE}[$ens]->{PITCH}) && - defined($dta->{ENSEMBLE}[$ens]->{ROLL}) && - defined($dta->{ENSEMBLE}[$ens]->{HEADING})); + defined($dta->{ENSEMBLE}[$ens]->{ROLL})); unless (@I2E && - $hdg == $dta->{ENSEMBLE}[$ens]->{HEADING} - - $dta->{HEADING_BIAS} && $pitch == $dta->{ENSEMBLE}[$ens]->{PITCH} && $roll == $dta->{ENSEMBLE}[$ens]->{ROLL}) { printf(STDERR "$0: warning HEADING_ALIGNMENT == %g ignored\n", $dta->{HEADING_ALIGNMENT}) if ($dta->{HEADING_ALIGNMENT}); - $hdg = $dta->{ENSEMBLE}[$ens]->{HEADING} - $dta->{HEADING_BIAS}; + $hdg = $dta->{ENSEMBLE}[$ens]->{HEADING} - $dta->{HEADING_BIAS} + if defined($dta->{ENSEMBLE}[$ens]->{HEADING}); $pitch = $dta->{ENSEMBLE}[$ens]->{PITCH}; $roll = $dta->{ENSEMBLE}[$ens]->{ROLL}; my($rad_gimbal_pitch) = atan(tan(rad($pitch)) * cos(rad($roll))); - my($sh,$ch) = (sin(rad($hdg)), cos(rad($hdg))); + my($sh,$ch) = (sin(rad($hdg)),cos(rad($hdg))) + if defined($hdg); my($sp,$cp) = (sin($rad_gimbal_pitch),cos($rad_gimbal_pitch)); my($sr,$cr) = (sin(rad($roll)), cos(rad($roll))); @I2E = $dta->{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} @@ -143,11 +144,14 @@ [-$cp*$sr, $sp, $cp*$cr, ], ); } - return ($v1*$I2E[0][0]+$v2*$I2E[0][1]+$v3*$I2E[0][2], - $v1*$I2E[1][0]+$v2*$I2E[1][1]+$v3*$I2E[1][2], - $v1*$I2E[2][0]+$v2*$I2E[2][1]+$v3*$I2E[2][2], - $v4); - + return defined($dta->{ENSEMBLE}[$ens]->{HEADING}) + ? ($v1*$I2E[0][0]+$v2*$I2E[0][1]+$v3*$I2E[0][2], + $v1*$I2E[1][0]+$v2*$I2E[1][1]+$v3*$I2E[1][2], + $v1*$I2E[2][0]+$v2*$I2E[2][1]+$v3*$I2E[2][2], + $v4) + : (undef,undef, + $v1*$I2E[2][0]+$v2*$I2E[2][1]+$v3*$I2E[2][2], + $v4); } } # STATIC SCOPE @@ -168,8 +172,7 @@ return (undef,undef,undef,undef) unless (defined($dta->{ENSEMBLE}[$ens]->{PITCH}) && - defined($dta->{ENSEMBLE}[$ens]->{ROLL}) && - defined($dta->{ENSEMBLE}[$ens]->{HEADING})); + defined($dta->{ENSEMBLE}[$ens]->{ROLL})); unless (defined($TwoCosBAngle)) { $TwoCosBAngle = 2 * cos(rad($dta->{BEAM_ANGLE})); @@ -227,17 +230,12 @@ return (undef,undef,undef,undef) unless (defined($dta->{ENSEMBLE}[$ens]->{PITCH}) && - defined($dta->{ENSEMBLE}[$ens]->{ROLL}) && - defined($dta->{ENSEMBLE}[$ens]->{HEADING})); + defined($dta->{ENSEMBLE}[$ens]->{ROLL})); unless (defined($TwoCosBAngle)) { $TwoCosBAngle = 2 * cos(rad($dta->{BEAM_ANGLE})); $TwoSinBAngle = 2 * sin(rad($dta->{BEAM_ANGLE})); } - my($roll) = rad($dta->{ENSEMBLE}[$ens]->{ROLL}); - my($sr) = sin($roll); my($cr) = cos($roll); - my($pitch) = atan(tan(rad($dta->{ENSEMBLE}[$ens]->{PITCH})) * $cr); # gimbal pitch - my($sp) = sin($pitch); my($cp) = cos($pitch); # Sign convention: # - refer to Coord manual Fig. 3 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: Sat Feb 22 16:57:30 2014 +# dlm: Thu May 29 09:23:46 2014 # (c) 2003 A.M. Thurnherr -# uE-Info: 463 0 NIL 0 0 72 10 2 4 NIL ofnI +# uE-Info: 302 0 NIL 0 0 72 10 2 4 NIL ofnI #====================================================================== # miscellaneous RDI-specific utilities @@ -49,6 +49,7 @@ # - added set_range_lim() # Feb 22, 2014: - changed gap heuristic # - Earth coord beam-pair warning removed +# May 29, 2014: - removed unused code (disabled warning) from ref_lr_w use strict; @@ -261,8 +262,6 @@ # 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) = @_; @@ -296,15 +295,11 @@ $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] > 0 || $dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < $min_pctg); @v = @{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$i]}; - 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 velocity + if (defined($v[2])) { # valid vertical 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 @@ -407,8 +402,6 @@ } -} # static scope - sub mk_prof(...) # make profile {