mkProfile
author A.M. Thurnherr <athurnherr@yahoo.com>
Tue, 29 Jun 2021 12:21:32 -0400
changeset 59 4f4530fa35da
parent 58 78607e2e8add
permissions -rwxr-xr-x
V2.4 - New Features: - support for Nortek PD0 files - patchPD0 support for moored ADCP data - bug fixes & minor improvements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     1
#!/usr/bin/perl
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     2
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     3
#                    M K P R O F I L E 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     4
#                    doc: Sun Jan 19 18:55:26 2003
58
78607e2e8add Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 47
diff changeset
     5
#                    dlm: Sat Apr 10 05:51:48 2021
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     6
#                    (c) 2003 A.M. Thurnherr
58
78607e2e8add Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 47
diff changeset
     7
#                    uE-Info: 99 35 NIL 0 0 72 0 2 4 NIL ofnI
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     8
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     9
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    10
# Make an LADCP Profile by Integrating W (similar to Firing's scan*).
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    11
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    12
# HISTORY:
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    13
#	Jan 19, 2003: - written in order to test the RDI libs
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    14
#	Jan 20, 2003: - added ensemble number
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    15
#	Jan 21, 2003: - added horizontal integration
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    16
#	Jan 22, 2003: - corrected magnetic declination
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    17
#	Jan 23, 2003: - added -F)ilter
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    18
#	Jan 24, 2003: - added more %PARAMs; started integration from 1st bin
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    19
#				  - added -g, -f, battery status
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    20
#	Jan 25, 2003: - added more %PARAMs
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    21
#	Feb  1, 2003: - BUG: bottom-track quality checking was bad
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    22
#	Feb  8, 2003: - allowed for array-indices on -f
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    23
#	Feb  9, 2003: - added 50% goodvelbin
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    24
#				  - removed unknown-field err on -f to allow -f W
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    25
#	Feb 10, 2003: - changed initialization depth to 0m
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    26
#				  - changed %bottom_depth to %max_depth
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    27
#	Feb 11, 2003: - changed sign of magnetic declination
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    28
#	Feb 12, 2003: - corrected BT-range scaling
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    29
#	Feb 14, 2003: - added %pinging_hours, %min_range
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    30
#				  - removed magnetic declination from default
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    31
#	Feb 26, 2004: - added earth coordinates
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    32
#	Mar  3, 2004: - removed requirement for -M on !-Q
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    33
#				  - corrected range-stats on earth coordinates
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    34
#	Mar  4, 2004: - added number of ensebles to output
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    35
#	Mar 11, 2004: - BUG: rename ACD -> ADC
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    36
#	Mar 12, 2004: - added %bottom_xmit_{current|voltage}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    37
#	Mar 16, 2004: - BUG: on -M u/v/x/y were wrong
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    38
#	Mar 17, 2004: - added error estimates on u/v/x/y
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    39
#				  - removed battery stuff (has to be done btw casts)
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    40
#	Mar 18, 2004: - totally re-did u/v integration
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    41
#	Mar 19, 2004: - re-designed u/v uncertainty estimation
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    42
#	Mar 28, 2004: - added MEAN_CORRELATION, MEAN_ECHO_AMPLITUDE
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    43
#	Sep 15, 2005: - changed BinRead library name
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    44
#				  - made max gap length variable
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    45
#	Sep 16, 2005: - re-did u,v,w uncertainties
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    46
#	Nov  8, 2005: - UNIXTIME => UNIX_TIME
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    47
#				  - added unix_time, secno, z_BT to default output
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    48
#	Dec  1, 2005: - moved profile-building code to [RDI_utils.pl]
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    49
#				  - changed -f syntax to allow name=FIELD
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    50
#				  - added %bin1_dist, %bin_length
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    51
#	Dec  8, 2005: - remove spaces from -f argument to allow multiline
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    52
#				    definitions in Makefiles
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    53
#	Nov 13, 2006: - BUG: end-of-cast depth had not been reported correctly
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    54
#				  - cosmetics
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    55
#	Nov 30, 2007: - adapted to 3-beam solutions
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    56
#	Dec 11, 2007: - adapted to earlier modifications (Sep 2007) of
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    57
#					[RDI_BB_Read.pl]
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    58
#	Dec 14, 2007: - replaced z by depth
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    59
#	Dec 17, 2007: - BUG: downcast flag was set incorrectly
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    60
#	Jan 24, 2008: - rotation had been output as degrees/s; to make it more
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    61
#				    consistent with pitch/roll, I changed it to simple degrees
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    62
#				  - added net rotations [deployment]/down/up/[recovery]
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    63
#	Apr  9, 2008: - added profile -B)ottom depth
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    64
#				  - BUG: depth of first bin was reported as beginning of cast
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    65
#	Oct 24, 2008: - added RANGE and RANGE_BINS fields
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    66
#	Mar 18, 2009: - BUG: pitch/roll calculation had typo
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    67
#				  - calc pitch/roll separately for down-/upcasts
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    68
#				  - removed approximations in pitch/roll calcs
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    69
#	Jul 30, 2009: - typo '<' removed from output
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    70
#				  - NaN => nan
3
ladcp@ladcp-mac.local
parents: 0
diff changeset
    71
#	Dec  8, 2010: - added zmax/zend labels to output
ladcp@ladcp-mac.local
parents: 0
diff changeset
    72
#	Dec 10, 2010: - made mkProfile exit with status 0 if no good ens found but -Q is set
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
    73
#	Dec 19, 2010: - finally made -A default and activated output file
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
    74
#	Jan  5, 2011: - made no-good-ensembles found test much more robust
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
    75
#	Jun 22, 2011: - added bandwith/power warnings
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
    76
#				  - added ping-interval calculation
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
    77
#				  - BUG: post-recovery rotations were always zero
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
    78
#	Sep  9, 2011: - BUG: range calculation for Earth coordinate data included bins without
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
    79
#						 valid velocities
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
    80
#	Sep 21, 2010: - added %rms_heave_acceleration
11
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 8
diff changeset
    81
#	Apr 12, 2013: - added -p
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    82
#	May 10, 2013: - BUG: mkProfile bombed when ADCP file is truncated at deepest location
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    83
#	May 14, 2013: - added heading to output
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    84
#				  - added err_vel to output
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    85
#				  - finally removed -d/-g
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    86
#	Nov 25, 2013: - expunged checkEnsemble
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    87
#	Feb 13, 2014: - added support set_range_lim()
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    88
#	Mar  4, 2014: - added support to allow missing PITCH/ROLL/HEADING values
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    89
#	May 24, 2014: - finally added (gimbal-)pitch & roll to default output
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    90
#				  - renamed heading to hdg and pitchroll to tilt
23
fb0c269b1eaa V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 21
diff changeset
    91
#	Mar 22, 2015: - made it work for moored time series as well
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 23
diff changeset
    92
#	Mar 17, 2015: - adapted to new Getopt library
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 23
diff changeset
    93
#				  - removed warning
37
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
    94
#	Sep 12, 2016: - added %PD0_file
39
3bddaa514ef5 before Hamburg
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 37
diff changeset
    95
#	Oct 13, 2017: - added instrument orientation
43
b63fa355644c commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
    96
#	Apr  2, 2018: - BUG: velBeamToInstrument() used old usage
b63fa355644c commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
    97
#	Apr 24, 2018: - BUG: bin1 was used even with zero blanking
47
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
    98
#	Apr 18, 2019: - added coord-transformation %PARAMs
58
78607e2e8add Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 47
diff changeset
    99
#	Apr 10, 2021: - adapted to V2.4
78607e2e8add Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 47
diff changeset
   100
# HISTORY END
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   101
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   102
# NOTES:
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   103
#	- the battery values are based on transmission voltages (different
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   104
#	  from battery voltages) and reported without units (raw 8-bit a2d
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   105
#	  values)
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   106
#	- -B with the CTD max depth can be used to linearly scale the depths;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   107
#	  even so, the profile can have negative depths, in particular when
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   108
#	  the CTD is sent to a shallow depth first and then returned to the surface
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   109
#	  before beginning the cast
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   110
#	- in one case that I looked at (Anslope ][, cast 82), there are large
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   111
#	  depth errors, even when -B is used
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   112
#	- this utility works only approximately for uplookers (profile is
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   113
#	  roughly ok, but apparently contaminated by surface reflection,
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   114
#	  but stats are not ok; e.g. NBP0402 037U.prof)
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   115
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   116
$0 =~ m{(.*)/[^/]+}; 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   117
require "$1/RDI_BB_Read.pl";
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   118
require "$1/RDI_Coords.pl";
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   119
require "$1/RDI_Utils.pl";
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 23
diff changeset
   120
use Getopt::Std;
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   121
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   122
$USAGE = "$0 @ARGV";
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   123
die("Usage: $0 " .
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   124
	"[-Q)uiet] [-F)ilter <script>] " .
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   125
	"[require -4)-beam solutions] [-d)iscard <beam#>] [apply beamvel-m)ask <file>] " .
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   126
	"[-r)ef-layer <bin|1,bin|6>] [-n) vels <min|2>] " .
11
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 8
diff changeset
   127
	"[-e)rr-vel <max[0.1]] [-c)orrelation <min>] [-p)ct-good <min[100]>] " .
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   128
	"[max -g)ap <len>] " .
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   129
	"[output -f)ields <field[,...]> " .
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   130
	"[-M)agnetic <declination>] [profile -B)ottom <depth>] " .
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   131
	"<RDI file>\n")
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 23
diff changeset
   132
		unless (&getopts("4AB:F:M:Qd:g:r:n:e:c:f:m:p:") && @ARGV == 1);
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   133
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   134
$RDI_Coords::minValidVels = 4 if ($opt_4);			# no 3-beam solutions
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   135
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   136
require $opt_F if defined($opt_F);					# load filter
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   137
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   138
$opt_r = "1,6" 	unless defined($opt_r);				# defaults
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   139
$opt_n = 2	   	unless defined($opt_n);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   140
$opt_e = 0.1   	unless defined($opt_e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   141
$opt_c = 70	   	unless defined($opt_c);
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   142
$opt_g = 120	unless defined($opt_g);
11
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 8
diff changeset
   143
$opt_p = 100	unless defined($opt_p);
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   144
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   145
($minb,$maxb) = split(',',$opt_r);					# reference layer
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   146
die("$0: can't decode -r $opt_r\n") unless defined($maxb);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   147
                                        
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   148
print(STDERR "Reading $ARGV[0]...");				# read data
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   149
readData($ARGV[0],\%dta);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   150
print(STDERR "done\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   151
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   152
die("$ARGV[0]: not enough bins for choice of -r\n")	# enough bins?
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   153
	unless ($dta{N_BINS} >= $maxb);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   154
if ($dta{BEAM_COORDINATES}) {						# coords used
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   155
	$beamCoords = 1;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   156
} elsif (!$dta{EARTH_COORDINATES}) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   157
	die("$ARGV[0]: only beam and earth coordinates implemented so far\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   158
}
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   159
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   160
if (defined($opt_m) && -r $opt_m) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   161
	die("$ARGV[0]: -m only implemented for data collected in beam coordinates\n")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   162
		unless ($beamCoords);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   163
	print(STDERR "Masking beam velocities as prescribed in $opt_m...");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   164
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   165
	open(BVM,$opt_m) || die("$opt_m: $!\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   166
	while (<BVM>) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   167
		s/#.*//;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   168
		s/^\s*$//;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   169
		next if ($_ eq '');
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   170
		my($fe,$te,$db) = split;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   171
		die("$opt_m: cannot decode $_\n")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   172
			unless (numberp($fe) && numberp($te) && $te>=$fe && $db>=1 && $db<=4);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   173
		die("$0: assertion failed")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   174
			unless ($dta{ENSEMBLE}[$fe-1]->{NUMBER} == $fe &&
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   175
					$dta{ENSEMBLE}[$te-1]->{NUMBER} == $te);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   176
		for (my($ens)=$fe-1; $ens<=$te-1; $ens++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   177
			$nens++;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   178
			for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   179
				undef($dta{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$db-1]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   180
			}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   181
	    }       
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   182
    }
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   183
	close(BVM);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   184
	print(STDERR " $nens ensembles edited\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   185
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   186
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   187
if (defined($opt_d)) {								# discard entire beam
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   188
	die("$ARGV[0]: -d only implemented for data collected in beam coordinates\n")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   189
		unless ($beamCoords);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   190
	print(STDERR "Discarding beam-$opt_d velocities...");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   191
    for (my($ens)=0; $ens<=$#{$dta{ENSEMBLE}}; $ens++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   192
        for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   193
            undef($dta{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$opt_d-1]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   194
        }
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   195
    }       
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   196
	print(STDERR "done\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   197
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   198
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   199
if (defined($opt_M)) {								# magnetic declination
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   200
	$dta{HEADING_BIAS} = -1*$opt_M;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   201
} else {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   202
	$dta{HEADING_BIAS} = 0;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   203
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   204
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   205
ensure_BT_RANGE(\%dta);								# set BT_RANGE field if it is missing (old firmware bug)
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   206
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   207
if ($opt_f) {										# additional fields
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   208
	@f = split(',',$opt_f);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   209
	foreach $f (@f) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   210
		$f =~ s/\s//g;								# remove spaces
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   211
		@def = split('=',$f);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   212
		if (@def == 2) {							# name=field
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   213
			$addFields .= " {$def[0]}";
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   214
			$f = $def[1];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   215
		} else {									# field
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   216
			$addFields .= " {$f}";
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   217
		}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   218
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   219
#	print(STDERR "addFields = $addFields\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   220
#	print(STDERR "\@f = @f\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   221
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   222
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   223
#======================================================================
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   224
# Step 0: Check data & Calculate Ping Rates
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   225
#======================================================================
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   226
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   227
unless ($dta{NARROW_BANDWIDTH}) {
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   228
	print(STDERR "WARNING: $0 WIDE BANDWIDTH!\n");
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   229
}
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   230
58
78607e2e8add Nortek files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 47
diff changeset
   231
unless ($dta{TRANSMIT_POWER_MAX}) {
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   232
	print(STDERR "WARNING: $0 LOW TRANSMIT POWER!\n");
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   233
}
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   234
39
3bddaa514ef5 before Hamburg
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 37
diff changeset
   235
printf(STDERR "ADCP                  : %s (s/n %d) %s\n",
3bddaa514ef5 before Hamburg
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 37
diff changeset
   236
											$dta{INSTRUMENT_TYPE},$dta{SERIAL_NUMBER},
3bddaa514ef5 before Hamburg
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 37
diff changeset
   237
											$dta{ENSEMBLE}[0]->{XDUCER_FACING_UP} ? 'UL' : 'DL');
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   238
printf(STDERR "# of ensembles        : %d\n",scalar(@{$dta{ENSEMBLE}}));
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   239
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   240
my($sdt1,$sdt2,$ndt);
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   241
my($mindt1) = my($mindt2) = 9e99;
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   242
my($maxdt1) = my($maxdt2) = 0;
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   243
for (my($e)=2; $e<=$#{$dta{ENSEMBLE}}; $e+=2,$ndt++) {
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   244
	my($dt1) = $dta{ENSEMBLE}[$e-1]->{UNIX_TIME} - $dta{ENSEMBLE}[$e-2]->{UNIX_TIME};
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   245
	my($dt2) = $dta{ENSEMBLE}[$e-0]->{UNIX_TIME} - $dta{ENSEMBLE}[$e-1]->{UNIX_TIME};
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   246
	$mindt1 = $dt1 if ($dt1 < $mindt1);
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   247
	$mindt2 = $dt2 if ($dt2 < $mindt2);
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   248
	$maxdt1 = $dt1 if ($dt1 > $maxdt1);
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   249
	$maxdt2 = $dt2 if ($dt2 > $maxdt2);
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   250
	$sdt1 += $dt1; $sdt2 += $dt2;
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   251
}
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   252
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   253
printf(STDERR "Ping intervals        : %.1fs/%.1fs",$sdt1/$ndt,$sdt2/$ndt);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   254
if ($maxdt1-$mindt1>=0.1 || $maxdt2-$mindt2>=0.1) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   255
	printf(STDERR " (%.1fs-%.1fs/%.1fs-%.1fs)\n",$mindt1,$maxdt1,$mindt2,$maxdt2);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   256
} else {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   257
	print(STDERR "\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   258
}
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   259
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   260
#======================================================================
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   261
# Step 1: Integrate w & determine water depth 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   262
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   263
43
b63fa355644c commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   264
$minb = 2 if ($dta{BLANKING_DISTANCE} == 0);
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   265
($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz,$rms_heave_accel) =
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   266
	mk_prof(\%dta,0,$opt_F,$minb,$maxb,$opt_c,$opt_e,$opt_g,$opt_p);
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   267
21
0b5bbe60131c version sent to P16N
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   268
if ($lastgood == $atbottom) {
0b5bbe60131c version sent to P16N
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   269
	print(STDERR "$ARGV[0]: truncated file (ends at max depth)\n")
0b5bbe60131c version sent to P16N
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   270
} elsif (($atbottom > $firstgood) && ($lastgood > $atbottom)) {
0b5bbe60131c version sent to P16N
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   271
	# all good
23
fb0c269b1eaa V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 21
diff changeset
   272
} elsif ($lastgood > $firstgood) {
fb0c269b1eaa V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 21
diff changeset
   273
	print(STDERR "$ARGV[0]: no bottom depth found\n")
fb0c269b1eaa V1.2 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 21
diff changeset
   274
		unless ($atbottom > 0);
21
0b5bbe60131c version sent to P16N
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   275
} else {
3
ladcp@ladcp-mac.local
parents: 0
diff changeset
   276
	if ($opt_Q) {
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   277
		print(STDERR "$ARGV[0]: no valid cast data found\n");
3
ladcp@ladcp-mac.local
parents: 0
diff changeset
   278
		exit(0);
ladcp@ladcp-mac.local
parents: 0
diff changeset
   279
    } else {
21
0b5bbe60131c version sent to P16N
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   280
		die(sprintf("$ARGV[0]: no valid cast data found (firstgood=%d atbottom=%d lastgood=%d)\n",$firstgood,$atbottom,$lastgood));
3
ladcp@ladcp-mac.local
parents: 0
diff changeset
   281
	}
ladcp@ladcp-mac.local
parents: 0
diff changeset
   282
}
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   283
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   284
if (defined($opt_B)) {										# scale Z
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   285
	my($zscale) = $opt_B / ($dta{ENSEMBLE}[$atbottom]->{DEPTH} -# downcast
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   286
				     	    $dta{ENSEMBLE}[$firstgood]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   287
#	printf(STDERR "scaling downcast depths by %.2f\n",$zscale);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   288
	for (my($e)=$firstgood; $e<$atbottom; $e++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   289
		next unless defined($dta{ENSEMBLE}[$e]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   290
		$dta{ENSEMBLE}[$e]->{DEPTH} =
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   291
			$dta{ENSEMBLE}[$firstgood]->{DEPTH} + $zscale *
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   292
				($dta{ENSEMBLE}[$e]->{DEPTH}-$dta{ENSEMBLE}[$firstgood]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   293
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   294
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   295
	$zscale = $opt_B / ($dta{ENSEMBLE}[$atbottom]->{DEPTH} -	# upcast
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   296
				 		$dta{ENSEMBLE}[$lastgood]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   297
#	printf(STDERR "scaling upcast depths by %.2f\n",$zscale);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   298
	for (my($e)=$atbottom; $e<=$lastgood; $e++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   299
		next unless defined($dta{ENSEMBLE}[$e]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   300
		$dta{ENSEMBLE}[$e]->{DEPTH} =
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   301
			$dta{ENSEMBLE}[$firstgood]->{DEPTH} + $zscale *
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   302
				($dta{ENSEMBLE}[$e]->{DEPTH}-$dta{ENSEMBLE}[$lastgood]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   303
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   304
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   305
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   306
set_range_lim(\%dta);										# set {range_lim} field
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   307
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   308
($water_depth,$sig_wd) =									# sea bed
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   309
	find_seabed(\%dta,$atbottom,$beamCoords);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   310
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   311
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   312
# Step 2: Integrate u & v
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   313
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   314
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   315
sub ref_lr_uv($$$)									# calc ref-level u/v
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   316
{
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   317
	my($ens,$z,$water_depth) = @_;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   318
	my($i,$n,@v,@goodU,@goodV);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   319
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   320
	$water_depth = 99999 unless defined($water_depth);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   321
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   322
	for ($i=$minb; $i<=$maxb; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   323
		next if ($dta{ENSEMBLE}[$ens]->{CORRELATION}[$i][0] < $opt_c ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   324
				 $dta{ENSEMBLE}[$ens]->{CORRELATION}[$i][1] < $opt_c ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   325
				 $dta{ENSEMBLE}[$ens]->{CORRELATION}[$i][2] < $opt_c ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   326
				 $dta{ENSEMBLE}[$ens]->{CORRELATION}[$i][3] < $opt_c);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   327
		if ($beamCoords) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   328
			next if ($dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][0] < 100 ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   329
					 $dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][1] < 100 ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   330
					 $dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] < 100 ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   331
					 $dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < 100);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   332
			@v = velInstrumentToEarth(\%dta,$ens,
43
b63fa355644c commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   333
					velBeamToInstrument(\%dta,$ens,
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   334
						@{$dta{ENSEMBLE}[$ens]->{VELOCITY}[$i]}));
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   335
		} else {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   336
			next if ($dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][0] > 0 ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   337
					 $dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][1] > 0 ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   338
					 $dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][2] > 0 ||
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   339
					 $dta{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$i][3] < 100);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   340
			@v = velApplyHdgBias(\%dta,$ens,
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   341
					@{$dta{ENSEMBLE}[$ens]->{VELOCITY}[$i]});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   342
		}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   343
		next if (!defined($v[3]) || abs($v[3]) > $opt_e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   344
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   345
#		Martin's BT routines show strong shear just above sea bed
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   346
#		=> skip lowest 20m.
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   347
		if (defined($v[0])) {							# valid u,v
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   348
			if ($dta{ENSEMBLE}[$ens]->{XDUCER_FACING_UP}) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   349
				if ($z - $dta{DISTANCE_TO_BIN1_CENTER}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   350
					   - $i*$dta{BIN_LENGTH} > 0) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   351
					push(@goodU,$v[0]); push(@goodV,$v[1]);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   352
					$dta{ENSEMBLE}[$ens]->{U} += $v[0];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   353
					$dta{ENSEMBLE}[$ens]->{V} += $v[1];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   354
					$n++;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   355
			   }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   356
			} else {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   357
				if ($z + $dta{DISTANCE_TO_BIN1_CENTER}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   358
					   + $i*$dta{BIN_LENGTH} < $water_depth-20) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   359
					push(@goodU,$v[0]); push(@goodV,$v[1]);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   360
					$dta{ENSEMBLE}[$ens]->{U} += $v[0];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   361
					$dta{ENSEMBLE}[$ens]->{V} += $v[1];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   362
					$n++;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   363
			   }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   364
			}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   365
		}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   366
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   367
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   368
	if ($n >= 2) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   369
		my(@sumsq) = (0,0);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   370
		$dta{ENSEMBLE}[$ens]->{U} /= $n;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   371
		$dta{ENSEMBLE}[$ens]->{V} /= $n;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   372
		for ($i=0; $i<$n; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   373
			$sumsq[0] += ($dta{ENSEMBLE}[$ens]->{U}-$goodU[$i])**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   374
			$sumsq[1] += ($dta{ENSEMBLE}[$ens]->{V}-$goodV[$i])**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   375
		}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   376
		$dta{ENSEMBLE}[$ens]->{U_ERR} = sqrt($sumsq[0])/($n-1);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   377
		$dta{ENSEMBLE}[$ens]->{V_ERR} = sqrt($sumsq[1])/($n-1);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   378
    } else {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   379
		$dta{ENSEMBLE}[$ens]->{U} = undef;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   380
		$dta{ENSEMBLE}[$ens]->{V} = undef;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   381
    }    	
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   382
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   383
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   384
#----------------------------------------------------------------------
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   385
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   386
($x,$y) = (0,0);											# init
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   387
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   388
$dta{ENSEMBLE}[$firstgood]->{X} = $dta{ENSEMBLE}[$firstgood]->{X_ERR} = 0;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   389
$dta{ENSEMBLE}[$firstgood]->{Y} = $dta{ENSEMBLE}[$firstgood]->{Y_ERR} = 0;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   390
$prevgood = $firstgood;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   391
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   392
for ($e=$firstgood+1; defined($opt_M)&&$e<=$lastgood; $e++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   393
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   394
	#--------------------------------------------------
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   395
	# within profile: both $firstgood and $prevgood set
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   396
	#--------------------------------------------------
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   397
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   398
	ref_lr_uv($e,$dta{ENSEMBLE}[$e]->{DEPTH},$water_depth)	# instrument vel
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   399
		if (defined($dta{ENSEMBLE}[$e]->{W}));
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   400
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   401
	if (!defined($dta{ENSEMBLE}[$e]->{U})) {				# gap
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   402
		$uv_gap_time += $dta{ENSEMBLE}[$e]->{UNIX_TIME} -
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   403
				   		$dta{ENSEMBLE}[$e-1]->{UNIX_TIME};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   404
		next;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   405
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   406
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   407
	my($dt) = $dta{ENSEMBLE}[$e]->{UNIX_TIME} -			# time step since
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   408
			  $dta{ENSEMBLE}[$prevgood]->{UNIX_TIME};		# ...last good ens
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   409
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   410
	#-----------------------------------
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   411
	# The current ensemble has valid u/v
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   412
	#-----------------------------------
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   413
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   414
	$x -= $dta{ENSEMBLE}[$prevgood]->{U} * $dt;			# integrate
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   415
	$xErr += ($dta{ENSEMBLE}[$prevgood]->{U_ERR} * $dt)**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   416
	$dta{ENSEMBLE}[$e]->{X} = $x;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   417
	$dta{ENSEMBLE}[$e]->{X_ERR} = sqrt($xErr);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   418
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   419
	$y -= $dta{ENSEMBLE}[$prevgood]->{V} * $dt;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   420
	$yErr += ($dta{ENSEMBLE}[$prevgood]->{V_ERR} * $dt)**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   421
	$dta{ENSEMBLE}[$e]->{Y} = $y;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   422
	$dta{ENSEMBLE}[$e]->{Y_ERR} = sqrt($yErr);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   423
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   424
	$prevgood = $e;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   425
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   426
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   427
unless (defined($dta{ENSEMBLE}[$lastgood]->{X})) {		# last is bad in u/v
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   428
	my($dt) = $dta{ENSEMBLE}[$lastgood]->{UNIX_TIME} -		# time step since
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   429
			  $dta{ENSEMBLE}[$prevgood]->{UNIX_TIME};		# ...last good ens
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   430
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   431
	$x -= $dta{ENSEMBLE}[$prevgood]->{U} * $dt;			# integrate
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   432
	$xErr += ($dta{ENSEMBLE}[$prevgood]->{U_ERR} * $dt)**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   433
	$dta{ENSEMBLE}[$lastgood]->{X} = $x;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   434
	$dta{ENSEMBLE}[$lastgood]->{X_ERR} = sqrt($xErr);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   435
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   436
	$y -= $dta{ENSEMBLE}[$prevgood]->{V} * $dt;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   437
	$yErr += ($dta{ENSEMBLE}[$prevgood]->{V_ERR} * $dt)**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   438
	$dta{ENSEMBLE}[$lastgood]->{Y} = $y;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   439
	$dta{ENSEMBLE}[$lastgood]->{Y_ERR} = sqrt($yErr);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   440
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   441
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   442
$firstgood++ if ($firstgood == 0);							# centered diff
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   443
$lastgood-- if ($lastgood == $#{$dta{ENSEMBLE}});			# in step 6
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   444
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   445
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   446
# Step 3: Calculate Uncertainties
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   447
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   448
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   449
# Time series of W_ERR indicate that errors are very large near the
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   450
# surface and near the sea bed, perhaps because of reflections.
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   451
# A reasonable estimate for typical uncertainty is therefore the mode
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   452
# of the std errors.
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   453
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   454
my(@histUErr,@histVErr,@histWErr);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   455
my($histRez) = 1e-4;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   456
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   457
for ($e=$firstgood; $e<=$lastgood; $e++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   458
	$histWErr[int($dta{ENSEMBLE}[$e]->{W_ERR}/$histRez+0.5)]++
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   459
		if defined($dta{ENSEMBLE}[$e]->{W_ERR});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   460
	$histUErr[int($dta{ENSEMBLE}[$e]->{U_ERR}/$histRez+0.5)]++
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   461
		if defined($dta{ENSEMBLE}[$e]->{U_ERR});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   462
	$histVErr[int($dta{ENSEMBLE}[$e]->{V_ERR}/$histRez+0.5)]++
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   463
		if defined($dta{ENSEMBLE}[$e]->{V_ERR});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   464
}	
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   465
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   466
my($max) = 0; my($mode);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   467
for (my($i)=0; $i<=$#histWErr; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   468
	next if ($histWErr[$i] < $max);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   469
	$max = $histWErr[$i]; $mode = $i;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   470
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   471
$wErr = $mode * $histRez if defined($mode);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   472
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   473
$max = 0; $mode = undef;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   474
for (my($i)=0; $i<=$#histUErr; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   475
	next if ($histUErr[$i] < $max);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   476
	$max = $histUErr[$i]; $mode = $i;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   477
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   478
$uErr = $mode * $histRez if defined($mode);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   479
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   480
$max = 0; $mode = undef;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   481
for (my($i)=0; $i<=$#histVErr; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   482
	next if ($histVErr[$i] < $max);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   483
	$max = $histVErr[$i]; $mode = $i;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   484
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   485
$vErr = $mode * $histRez if defined($mode);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   486
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   487
#print(STDERR "u: mu = $meanU / sigma = $uErr\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   488
#print(STDERR "v: mu = $meanV / sigma = $vErr\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   489
#print(STDERR "w: mu = $meanW / sigma = $wErr\n");
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   490
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   491
if (defined($opt_M)) {									# displacement errors
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   492
	$x_err = $uErr * $uv_gap_time + $dta{ENSEMBLE}[$lastgood]->{X_ERR};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   493
	$y_err = $vErr * $uv_gap_time + $dta{ENSEMBLE}[$lastgood]->{Y_ERR};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   494
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   495
$z_err = $wErr * $w_gap_time + $dta{ENSEMBLE}[$lastgood]->{DEPTH_ERR};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   496
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   497
#printf(STDERR "x_err = $dta{ENSEMBLE}[$lastgood]->{X_ERR} + %g\n",
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   498
#				$uErr * $uv_gap_time);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   499
#printf(STDERR "y_err = $dta{ENSEMBLE}[$lastgood]->{Y_ERR} + %g\n",
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   500
#				$vErr * $uv_gap_time);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   501
#printf(STDERR "z_err = $dta{ENSEMBLE}[$lastgood]->{DEPTH_ERR} + %g\n",
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   502
#				$wErr * $w_gap_time);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   503
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   504
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   505
# Step 4: Calculate Beam Range Stats
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   506
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   507
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   508
my($min_good_bins) = 999;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   509
my($worst_beam);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   510
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   511
sub count_good_vels($)								# count good vels
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   512
{
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   513
	my($ens) = @_;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   514
	my($good) = -1; my($this_worst_beam);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   515
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   516
	if ($beamCoords) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   517
		for (my($i)=0; $i<$dta{N_BINS}; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   518
			for (my($b)=0; $b<4; $b++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   519
				$good=$i,$this_worst_beam=$b,$nVels[$i][$b]++
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   520
					if defined($dta{ENSEMBLE}[$ens]->{VELOCITY}[$i][$b]);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   521
			}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   522
	    }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   523
	} else {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   524
		for (my($i)=0; $i<$dta{N_BINS}; $i++) {
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   525
			next unless defined($dta{ENSEMBLE}[$ens]->{VELOCITY}[$i][0]);
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   526
			for (my($b)=0; $b<4; $b++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   527
				$good=$i,$this_worst_beam=$b,$nVels[$i][$b]++
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   528
					if ($dta{ENSEMBLE}[$ens]->{CORRELATION}[$i][$b] >=
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   529
						$dta{MIN_CORRELATION});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   530
			}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   531
	    }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   532
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   533
	$min_good_ens=$ens, $min_good_bins=$good, $worst_beam=$this_worst_beam
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   534
		if ((!defined($water_depth) || 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   535
			  $dta{ENSEMBLE}[$ens]->{DEPTH} < $water_depth-200)
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   536
			&& $good >= 0 && $good < $min_good_bins);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   537
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   538
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   539
#----------------------------------------------------------------------
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   540
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   541
for ($e=$firstgood; $e<=$lastgood; $e++) {					# range
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   542
	my($i);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   543
	for ($i=0; $i<$dta{N_BINS}; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   544
		last if (defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$i][0]) +
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   545
				 defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$i][1]) +
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   546
				 defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$i][2]) +
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   547
				 defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$i][3]) < 3);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   548
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   549
	$dta{ENSEMBLE}[$e]->{RANGE_BINS} = $i;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   550
	$dta{ENSEMBLE}[$e]->{RANGE} =
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   551
		$dta{DISTANCE_TO_BIN1_CENTER} + $i * $dta{BIN_LENGTH};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   552
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   553
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   554
for ($e=$firstgood; $e<=$lastgood; $e++) {					# mean corr/amp
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   555
	$sumcor = $sumamp = $ndata = 0;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   556
	for (my($i)=0; $i<$dta{N_BINS}; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   557
		for (my($b)=0; $b<4; $b++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   558
			next unless ($dta{ENSEMBLE}[$e]->{CORRELATION}[$i][$b]);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   559
			$sumcor += $dta{ENSEMBLE}[$e]->{CORRELATION}[$i][$b];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   560
			$sumamp += $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$i][$b];
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   561
			$ndata++;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   562
		}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   563
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   564
	$dta{ENSEMBLE}[$e]->{MEAN_CORRELATION} = $sumcor/$ndata;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   565
	$dta{ENSEMBLE}[$e]->{MEAN_ECHO_AMPLITUDE} = $sumamp/$ndata;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   566
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   567
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   568
for ($e=$firstgood+50; $e<=$lastgood-50; $e++) {			# range stats
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   569
	count_good_vels($e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   570
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   571
for ($i=0; $i<$dta{N_BINS}; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   572
	for ($b=0; $b<4; $b++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   573
		$maxVels = $nVels[$i][$b] unless ($maxVels > $nVels[$i][$b]);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   574
	}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   575
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   576
for ($i=0; $i<$dta{N_BINS}; $i++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   577
	for ($b=0; $b<4; $b++) {
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   578
		$gb[$b] = $i if ($nVels[$i][$b] >= 0.8*$maxVels);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   579
    }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   580
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   581
$gb = ($gb[0]+$gb[1]+$gb[2]+$gb[3]) / 4;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   582
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   583
#======================================================================
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   584
# Step 5: Remove Ship Drift (probably not useful => removed)
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   585
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   586
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   587
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   588
# Step 6: Pitch, Roll, Rotation
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   589
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   590
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   591
# in case of PITCH/ROLL/HEADING data gaps (IMP data), the calculations
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   592
# are not entirely correct, as
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   593
# 	i)  the rotation implied by the pre-/post-gap headings is not counted
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   594
#	ii) the gappy ensembles are counted for calculating the rms vals
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   595
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   596
my($prrms,$dnprrms,$upprrms) = (0,0,0);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   597
my($rotrms,$prerot,$dnrot,$uprot,$postrot) = (0,0,0,0,0);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   598
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   599
sub rot($)
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   600
{
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   601
	my($e) = @_;
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   602
	return 0
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   603
		unless defined($dta{ENSEMBLE}[$e]->{HEADING}) && defined($dta{ENSEMBLE}[$e-1]->{HEADING});
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   604
	my($rot) = $dta{ENSEMBLE}[$e]->{HEADING} -
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   605
			   $dta{ENSEMBLE}[$e-1]->{HEADING};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   606
	$rot -= 360 if ($rot >  180);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   607
	$rot += 360 if ($rot < -180);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   608
	return $rot;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   609
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   610
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   611
for ($e=1; $e<$firstgood; $e++) {				# pre-deployment
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   612
	$prerot += rot($e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   613
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   614
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   615
for (; $e<= $atbottom; $e++) {					# downcast
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   616
	$dta{ENSEMBLE}[$e]->{TILT} =
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   617
		&angle_from_vertical($dta{ENSEMBLE}[$e]->{PITCH},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   618
						  	 $dta{ENSEMBLE}[$e]->{ROLL});
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   619
	$prrms += $dta{ENSEMBLE}[$e]->{TILT}**2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   620
		if numberp($dta{ENSEMBLE}[$e]->{TILT});
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   621
				 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   622
	$dta{ENSEMBLE}[$e]->{ROTATION} = rot($e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   623
	$dnrot += $dta{ENSEMBLE}[$e]->{ROTATION};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   624
	$rotrms += $dta{ENSEMBLE}[$e]->{ROTATION}**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   625
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   626
$dnprrms = $prrms;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   627
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   628
for (; $e<=$lastgood; $e++) {					# upcast
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   629
	$dta{ENSEMBLE}[$e]->{TILT} =
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   630
		&angle_from_vertical($dta{ENSEMBLE}[$e]->{PITCH},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   631
						  	 $dta{ENSEMBLE}[$e]->{ROLL});
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   632
	$prrms += $dta{ENSEMBLE}[$e]->{TILT}**2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   633
		if numberp($dta{ENSEMBLE}[$e]->{TILT});
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   634
				 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   635
	$dta{ENSEMBLE}[$e]->{ROTATION} = rot($e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   636
	$uprot += $dta{ENSEMBLE}[$e]->{ROTATION};
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   637
	$rotrms += $dta{ENSEMBLE}[$e]->{ROTATION}**2;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   638
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   639
$upprrms = $prrms - $dnprrms;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   640
7
e06925788055 post IWISE_2011
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 5
diff changeset
   641
for (; $e<=$#{$dta{ENSEMBLE}}; $e++) {			# post-recovery
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   642
	$postrot += rot($e);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   643
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   644
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   645
$prerot  /= 360;								# rotations, not degrees
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   646
$dnrot   /= 360;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   647
$uprot   /= 360;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   648
$postrot /= 360;
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   649
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   650
$prrms 	 = sqrt($prrms/($lastgood-$firstgood));
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   651
$dnprrms = sqrt($dnprrms/($atbottom-$firstgood));
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   652
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   653
if ($lastgood == $atbottom) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   654
	print(STDERR "WARNING: $0 NO UPCAST DATA\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   655
	$upprrms = nan;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   656
} else {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   657
	$upprrms = sqrt($upprrms/($lastgood-$atbottom));
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   658
}
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   659
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   660
$rotrms = sqrt($rotrms/($lastgood-$firstgood));
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   661
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   662
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   663
# PRODUCE OUTPUT
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   664
#======================================================================
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   665
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   666
printf(STDERR "Start of cast         : %s (#%5d) at %6.1fm\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   667
					$dta{ENSEMBLE}[$firstgood]->{TIME},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   668
					$dta{ENSEMBLE}[$firstgood]->{NUMBER},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   669
					$dta{ENSEMBLE}[$firstgood]->{DEPTH});
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   670
printf(STDERR "Bottom of cast (zmax) : %s (#%5d) at %6.1fm\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   671
					$dta{ENSEMBLE}[$atbottom]->{TIME},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   672
					$dta{ENSEMBLE}[$atbottom]->{NUMBER},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   673
					$dta{ENSEMBLE}[$atbottom]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   674
if (defined($water_depth)) {
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   675
	printf(STDERR "Seabed                :                      at %6.1fm (+-%dm)\n",$water_depth,$sig_wd);
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   676
} else {
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   677
	print(STDERR "Seabed                : not found\n");
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   678
}
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   679
printf(STDERR "End of cast (zend)    : %s (#%5d) at %6.1fm\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   680
					$dta{ENSEMBLE}[$lastgood]->{TIME},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   681
					$dta{ENSEMBLE}[$lastgood]->{NUMBER},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   682
					$dta{ENSEMBLE}[$lastgood]->{DEPTH});
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   683
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   684
printf(STDERR "Rel. Displacement     : x = %d(%d)m / y = %d(%d)m\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   685
					$dta{ENSEMBLE}[$lastgood]->{X}, $x_err, 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   686
					$dta{ENSEMBLE}[$lastgood]->{Y}, $y_err, 
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   687
				) if defined($opt_M);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   688
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   689
printf(STDERR "Cast Duration         : %.1f hours (pinging for %.1f hours)\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   690
					$dta{ENSEMBLE}[$lastgood]->{ELAPSED_TIME} / 3600,
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   691
					($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{UNIX_TIME} -
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   692
						$dta{ENSEMBLE}[0]->{UNIX_TIME}) / 3600);
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   693
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   694
printf(STDERR "Minimum range         : %dm at ensemble %d, beam %d\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   695
				$dta{DISTANCE_TO_BIN1_CENTER} +
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   696
					$min_good_bins*$dta{BIN_LENGTH},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   697
				$dta{ENSEMBLE}[$min_good_ens]->{NUMBER},
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   698
				$worst_beam);
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   699
printf(STDERR "80%%-valid bins        : %.1f\n",$gb+1);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   700
printf(STDERR "80%%-valid range       : %dm\n",
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   701
				$dta{DISTANCE_TO_BIN1_CENTER} + $gb*$dta{BIN_LENGTH});
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   702
printf(STDERR "3-beam solutions      : $RDI_Coords::threeBeam_1 " .
3
ladcp@ladcp-mac.local
parents: 0
diff changeset
   703
								 	 "$RDI_Coords::threeBeam_2 " .
ladcp@ladcp-mac.local
parents: 0
diff changeset
   704
								 	 "$RDI_Coords::threeBeam_3 " .
ladcp@ladcp-mac.local
parents: 0
diff changeset
   705
                                 	 "$RDI_Coords::threeBeam_4\n")
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   706
	unless ($opt_4);
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   707
printf(STDERR "net rotations         : [%d]/%d/%d/[%d]\n",$prerot,$dnrot,$uprot,$postrot);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   708
printf(STDERR "rms pitch/roll        : %.1fdeg/%.1fdeg\n",$dnprrms,$upprrms);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   709
printf(STDERR "rms heave acceleration: %.2fm/s^2\n",$rms_heave_accel);
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   710
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   711
exit(0) if ($opt_Q);
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   712
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   713
#----------------------------------------------------------------------
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   714
# output profile in active ANTS format
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   715
#----------------------------------------------------------------------
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   716
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   717
print("#!/usr/bin/perl -S list\n");		
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   718
chmod(0777&~umask,*STDOUT);
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   719
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   720
print("#ANTS# [] $USAGE\n");
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   721
$uFields = "{u} {u_err} {v} {v_err} {x} {x_err} {y} {y_err}"
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   722
	if defined($opt_M);
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   723
print("#ANTS#FIELDS# {ens} {time} {elapsed} {secno} {downcast} " .
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   724
					"{w} {w_err} {err_vel} {depth} {depth_err} {seabed} " .
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   725
					"{pitch} {roll} {tilt} {hdg} {rotation} " .
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   726
					"$uFields $addFields\n");
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   727
47
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   728
printf(     "#ANTS#PARAMS# date{$dta{ENSEMBLE}[$firstgood]->{DATE}} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   729
			        "start_time{$dta{ENSEMBLE}[$firstgood]->{TIME}} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   730
			       "bottom_time{$dta{ENSEMBLE}[$atbottom]->{TIME}} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   731
		   		      "end_time{$dta{ENSEMBLE}[$lastgood]->{TIME}} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   732
	       "bottom_xmit_voltage{$dta{ENSEMBLE}[$atbottom]->{ADC_XMIT_VOLTAGE}} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   733
	       "bottom_xmit_current{$dta{ENSEMBLE}[$atbottom]->{ADC_XMIT_CURRENT}} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   734
	    			  "PD0_file{$ARGV[0]} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   735
      "RDI_Coords::minValidVels{$RDI_Coords::minValidVels} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   736
        "RDI_Coords::binMapping{$RDI_Coords::binMapping} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   737
"RDI_Coords::beamTransformation{$RDI_Coords::beamTransformation} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   738
			  "pinging_duration{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   739
				 "cast_duration{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   740
				"0.8_valid_bins{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   741
			   "0.8_valid_range{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   742
					 "max_depth{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   743
				   "depth_error{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   744
				     "min_range{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   745
				   "n_ensembles{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   746
				    "w_gap_time{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   747
					  "stderr_w{%.4f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   748
					  "rms_tilt{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   749
			 "downcast_rms_tilt{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   750
			   "upcast_rms_tilt{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   751
				  "rms_rotation{%.2f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   752
   		  "deployment_rotations{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   753
		    "downcast_rotations{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   754
		   	  "upcast_rotations{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   755
			"recovery_rotations{%d} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   756
		"rms_heave_acceleration{%.2f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   757
					 "bin1_dist{%.1f} " .
494a76548e94 before adapting to read RTI PD0 files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 43
diff changeset
   758
                    "bin_length{%.1f} " .
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   759
					 "\n",
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   760
			($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{UNIX_TIME} -
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   761
					$dta{ENSEMBLE}[0]->{UNIX_TIME}),
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   762
			$dta{ENSEMBLE}[$lastgood]->{ELAPSED_TIME},
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   763
			$gb+1,
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   764
			$dta{DISTANCE_TO_BIN1_CENTER} + $gb*$dta{BIN_LENGTH},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   765
			$dta{ENSEMBLE}[$atbottom]->{DEPTH},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   766
			$dta{ENSEMBLE}[$lastgood]->{DEPTH} -
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   767
				$dta{ENSEMBLE}[$firstgood]->{DEPTH},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   768
			$dta{DISTANCE_TO_BIN1_CENTER} +
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   769
				$min_good_bins*$dta{BIN_LENGTH},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   770
			scalar(@{$dta{ENSEMBLE}}),
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   771
			$w_gap_time,$wErr,$prrms,$dnprrms,$upprrms,$rotrms,
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   772
			$prerot,$dnrot,$uprot,$postrot,$rms_heave_accel,
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   773
			$dta{DISTANCE_TO_BIN1_CENTER},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   774
			$dta{BIN_LENGTH},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   775
	  );
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   776
printf("#ANTS#PARAMS# magnetic_declination{$opt_M} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   777
							  "uv_gap_time{%d} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   778
								   "mean_u{%.4f} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   779
								 "stderr_u{%.4f} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   780
									   "dx{%d} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   781
								   "dx_err{%d} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   782
								   "mean_v{%.4f} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   783
								 "stderr_v{%.4f} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   784
									   "dy{%d} " .
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   785
								   "dy_err{%d}\n",
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   786
	$uv_gap_time,
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   787
	$dta{ENSEMBLE}[$lastgood]->{X} /
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   788
		$dta{ENSEMBLE}[$lastgood]->{ELAPSED_TIME},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   789
	$uErr, $dta{ENSEMBLE}[$lastgood]->{X}, $x_err,
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   790
	$dta{ENSEMBLE}[$lastgood]->{Y} /
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   791
		$dta{ENSEMBLE}[$lastgood]->{ELAPSED_TIME},
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   792
	$vErr, $dta{ENSEMBLE}[$lastgood]->{Y}, $y_err,
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   793
) if defined ($opt_M);
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   794
if ($dta{TIME_BETWEEN_PINGS} == 0) {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   795
	 print("#ANTS#PARAMS# pinging_rate{staggered}\n");
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   796
} else {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   797
	 printf("#ANTS#PARAMS# pinging_rate{%.2f}\n",
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   798
		1/$dta{TIME_BETWEEN_PINGS});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   799
}	    
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   800
if (defined($water_depth)) {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   801
	printf("#ANTS#PARAMS# water_depth{%d} sig-water_depth{%d}\n",
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   802
				$water_depth,$sig_wd);
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   803
} else {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   804
	print("#ANTS#PARAMS# water_depth{nan} sig-water_depth{nan}\n");
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   805
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   806
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   807
sub p($) { print(defined($_[0])?"$_[0] ":"nan "); }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   808
sub pb($) { print($_[0]?"1 ":"0 "); }
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   809
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   810
for ($e=$firstgood; $e<=$lastgood; $e++) {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   811
	p($dta{ENSEMBLE}[$e]->{NUMBER});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   812
	p($dta{ENSEMBLE}[$e]->{UNIX_TIME});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   813
	p($dta{ENSEMBLE}[$e]->{ELAPSED_TIME});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   814
	p($dta{ENSEMBLE}[$e]->{SECNO});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   815
	pb($dta{ENSEMBLE}[$e]->{UNIX_TIME} < $dta{ENSEMBLE}[$atbottom]->{UNIX_TIME});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   816
	p($dta{ENSEMBLE}[$e]->{W});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   817
	p($dta{ENSEMBLE}[$e]->{W_ERR});
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   818
	p($dta{ENSEMBLE}[$e]->{ERR_VEL});
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   819
	p($dta{ENSEMBLE}[$e]->{DEPTH});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   820
	p($dta{ENSEMBLE}[$e]->{DEPTH_ERR});
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   821
	p($dta{ENSEMBLE}[$e]->{seabed});
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   822
	p(&gimbal_pitch($dta{ENSEMBLE}[$e]->{PITCH},$dta{ENSEMBLE}[$e]->{ROLL}));
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   823
	p($dta{ENSEMBLE}[$e]->{ROLL});
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   824
	p($dta{ENSEMBLE}[$e]->{TILT});
12
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   825
	p($dta{ENSEMBLE}[$e]->{HEADING});
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   826
	p($dta{ENSEMBLE}[$e]->{ROTATION});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   827
	if (defined($opt_M)) {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   828
		p($dta{ENSEMBLE}[$e]->{U}); p($dta{ENSEMBLE}[$e]->{U_ERR});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   829
		p($dta{ENSEMBLE}[$e]->{V}); p($dta{ENSEMBLE}[$e]->{V_ERR});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   830
		p($dta{ENSEMBLE}[$e]->{X}); p($dta{ENSEMBLE}[$e]->{X_ERR});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   831
		p($dta{ENSEMBLE}[$e]->{Y}); p($dta{ENSEMBLE}[$e]->{Y_ERR});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   832
	}
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 23
diff changeset
   833
	if (@f) {
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   834
		foreach $f (@f) {
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   835
			my($fn,$fi) = ($f =~ m{([^[]*)(\[.*)});
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   836
			$fn = $f unless defined($fn);
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   837
			p(eval("\$dta{ENSEMBLE}[$e]->{$fn}$fi"));
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   838
		}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   839
	}
5
29faa9e6226c after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 4
diff changeset
   840
	print("\n");
0
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   841
}
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   842
229a0d72d2ab first hg version
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   843
exit(0);