LADCPproc
author A.M. Thurnherr <athurnherr@yahoo.com>
Thu, 20 Mar 2014 12:04:30 +0000
changeset 25 91bd907db97f
parent 22 f6635c0384b7
child 26 d778b73f2a43
permissions -rwxr-xr-x
before debugging weird nsamp problem
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     1
#!/usr/bin/perl
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     2
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     3
#                    L A D C P P R O C 
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     4
#                    doc: Thu Sep 16 20:36:10 2010
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
     5
#                    dlm: Wed Mar 19 23:41:55 2014
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
     6
#                    (c) 2010 A.M. Thurnherr
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
     7
#                    uE-Info: 91 55 NIL 0 0 72 10 2 4 NIL ofnI
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     8
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     9
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    10
# NOTES:
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    11
#   - the shear-method editing in this code is based on Eric Firing's merge.c
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    12
#   - as described in [LADCPproc.backscatter], there are three different codes 
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    13
#     for correcting echo amplitudes for attenuation loss & beam spreading
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    14
#   - comments starting with ## are taken verbatim from the original
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    15
#	  implementations
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    16
#   - the basic idea of the time lagging implemented in this code is similar
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    17
#     to the one implemented in Martin Visbeck's bestlag.m
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    18
#   - for SeaBird files:
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    19
#       - CTD elapsed time is estimated from recno * CTD{sampint}
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    20
#       - first elapsed time is added on output
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    21
#   - output time:
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    22
#		- is from CTD to allow yoyo processing without loss of time information
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    23
#		- to obtain LADCP time, add %LADCP_time_lag to CTD time
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    24
#		- %LADCP_time_lag can be used for -l
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    25
#		- -i is different: it should be set to the number that is added to
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    26
#						   LADCP_elapsed to get the CTD time, i.e.
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    27
#						   -%LADCP_time_lag
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    28
#   - CTD{elapsed} is undefined for records before instrument is in the water
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    29
#   - ITS-90 temp field in degC required
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    30
#   - salin field prequired
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    31
#   - pressure field in dbar required
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    32
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    33
# HISTORY:
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    34
#   Sep 16, 2010: - incepted
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    35
#   Oct 13, 2010: - first working version
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    36
#   Oct 14, 2010: - renamed from LADCPshear
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    37
#   Oct 19, 2010: - added -a)coustic backscatter profiles
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    38
#   Oct 20, 2010: - added -2)dary CTD sensors
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    39
#   Oct 23, 2010: - added magnetic-declination correction
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    40
#   Oct 26, 2010: - added tilt calculation
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    41
#   Dec  9, 2010: - added support for ASCII CTD files
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    42
#   Dec 10, 2010: - change -w) default to 120s
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    43
#                 - changed nshear output to 0 from nan when there are no samples
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    44
#   Dec 27, 2010: - changed sign of -l to accept lag output from [LADCP_w]
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    45
#   Jan 10, 2011: - -o => -k added new -o
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    46
#                 - added code to fill CTD sound vel gaps
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    47
#   Jan 22, 2011: - added -g) lat,lon
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    48
#                 - added -c)ompass corr
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    49
#   Jun 15, 2011: - added mean backscatter profile to default output
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    50
#   Jul  7, 2011: - added support for $BT_* processing parameters
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    51
#                 - replaced old per-bin acoustic backscatter profile output by
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    52
#                   acoustic backscatter depth-time-series
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    53
#                 - disabled seabed and acoustic backscatter code when not required (e.g. UL)
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    54
#                 - made non-diagnostic output terser
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    55
#   Jul 11, 2011: - changed default output to .tds and added -p)rofile option
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    56
#   Jul 14, 2011: - added -u)se D[eines1999][V[isbeck2004]]
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    57
#   Jul 15, 2011: - changed output bin# to 1-based in -a output
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    58
#                 - added T[hurnherr11] -u)se option
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    59
#                 - added $CTD{first_elapsed}
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    60
#   Jul 27, 2011: - replaced ndata by nsamp
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    61
#   Feb  5, 2012: - added profile max depth consistency check
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    62
#   Feb 19, 2912: - added elapsed time to shear profile output
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    63
#                 - replaced "nshear" output field by "nsamp"
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    64
#                 - BUG: bottom of profiles was incorrect when dc max depth > uc max depth
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    65
#                 - BUG: profile depth consistency check did not work for partial-depth yoyo casts
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    66
#   Apr 10, 2012: - changed default backscatter correction to Deines (1999)
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    67
#                 - improved and relaxed depth consistency check
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    68
#   Apr 11, 2012: - BUG: double comma that did not affect the output
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    69
#                 - BUG: code had assumed, but not ensured, that first CTD scan is valid
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    70
#   Apr 13, 2012: - removed -s argument from dependencies
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    71
#	Apr 17, 2012: - BAD BUG: magdec code call was bad and did not return correct value. ever.
10
196a179304ee 1.0beta
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 9
diff changeset
    72
#	Apr 18, 2012: - replaced Sv.n by Sv.nsamp
11
d0af7f7aa23b V1.0beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
    73
#	May 16, 2012: - adapted to ANTSlib V5.0
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    74
#				  - added support for -r)DI BT data
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    75
#				  - added $LADCP{MEAN_DT} from vertical-velocity code
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    76
#	May 17, 2012: - significantly relaxed profile-range consistency check (from 20% to 50%)
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    77
#					which is required for Dan Torres' shallow casts
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    78
#				  - added version info
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    79
#	May 18, 2012: - reduced "implausibly short cast" threshold to 5 min because of Dan's shallow casts
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    80
#	Jun 13, 2012: - added CTD_depth to tds output
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
    81
#	Oct 28, 2012: - added -z
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    82
#	Mar 16, 2013: - BUG: usage message had a -p)PI flag
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
    83
#	Jun  5, 2013: - added $bad_beam support
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
    84
#	Jun 25, 2013: - added %PARAMS used for spectral correction
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
    85
#				  - adapted to new ::-PARAM convention
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
    86
#	Sep 25, 2013: - BUG: %PARAM magnetic_declination did not have LADCPproc:: prefix
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
    87
#				  - added CTD lat/lon info to most output files (but not BT)
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
    88
#				  - BUG: moved %water_depth to common %PARAMs
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    89
#	Mar 19, 2014: - moved code to set LADCP_time_lag %PARAM into main prog so it is
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    90
#				    set, even when -l is used
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    91
#				  - added pitch, roll, hdg to -t output
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    92
11
d0af7f7aa23b V1.0beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
    93
($ANTS)    = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    94
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    95
($LADCPPROC)  = ($0 =~ m{^(.*)/[^/]*$});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    96
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    97
require "$ANTS/ants.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    98
require "$ANTS/libEOS83.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    99
require "$ANTS/libstats.pl";
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   100
require "$LADCPPROC/LADCPproc.version";
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   101
require "$LADCPPROC/LADCPproc.loadCTD";
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   102
require "$LADCPPROC/LADCPproc.bestLag";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   103
require "$LADCPPROC/LADCPproc.BT";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   104
require "$LADCPPROC/LADCPproc.backscatter";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   105
require "$LADCPPROC/LADCPproc.UHcode";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   106
require "$PERL_TOOLS/RDI_BB_Read.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   107
require "$PERL_TOOLS/RDI_Coords.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   108
require "$PERL_TOOLS/RDI_Utils.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   109
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   110
$ANTSLIBS = $LADCPPROC;							# for -L libraries
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   111
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   112
$antsSummary = "$version -- process LADCP data to get shear, time series";
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   113
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   114
$antsParseHeader = 0;
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   115
&antsUsage('24a:b:c:df:g:i:kl:n:o:p:rs:t:u:w:z',2,
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   116
    '[use -2)dary CTD sensor pair]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   117
    '[require -4)-beam LADCP solutions]',
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   118
    '[use -r)DI bottom-track data]',
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   119
    '[-s)etup <file>] [-g)ps <lat,lon>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   120
    '[-c)ompass-corr <offset,cos-fac,sin-fac>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   121
    '[-o)utput grid <resolution[5m]>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   122
    '[-i)nitial LADCP time lag <guestimate>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   123
    '[-l)ag LADCP <by>] [auto-lag -w)indow <size[120s]>] [-n) <auto-lag windows[20]]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   124
    '[correct echo amplitude -u)sing D[eines99]|V[isbeck04]|T[hurnherr11]|n[ocorr]',
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   125
    '[-d)iagnostic screen output] [-z)oom through problems]',
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   126
    'output: [shear-p)rofile <file>] [-t)ime series <file>] [-f)lag <file>] [-b)ottom-track <file>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   127
    '        [-a)coustic backscatter <dts-file] [bottom-trac-k) profs]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   128
    '<RDI file> <SeaBird file>');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   129
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   130
$RDI_Coords::minValidVels = 4 if ($opt_4);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   131
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   132
&antsFloatOpt($opt_l);
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   133
&antsCardOpt(\$opt_w,120);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   134
    # old default of -w 30 does not work if there are significant ambiguity-velocity
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   135
    # problems, as is the case, e.g., with 2010_DIMES_US2 station 142
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   136
    # old default of -w 60 did not work for DIMES_UK2 station 4 (DL), possibly again
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   137
    # related to ambiguity velocity
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   138
&antsCardOpt(\$opt_n,20);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   139
#&antsFileOpt($opt_s);      # DON'T, AS THIS WILL ADD AN UNWANTED DEPENDCY
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   140
&antsFloatOpt($opt_i);
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   141
&antsCardOpt(\$opt_o,5);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   142
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   143
if (defined($opt_u)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   144
    croak("$0: cannot decode -u $opt_u\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   145
        unless ($opt_u =~ /^[dDvVtTn]/);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   146
} else {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   147
    $opt_u = 'Deines99';
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   148
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   149
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   150
if (defined($opt_g)) {
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   151
    ($CTD{stn_lat},$CTD{stn_lon}) = split(',',$opt_g);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   152
    croak("$0: cannot decode -g $opt_g\n")
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   153
        unless numberp($CTD{stn_lat}) && numberp($CTD{stn_lon});
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   154
}
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   155
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   156
if (defined($opt_c)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   157
    ($CC_offset,$CC_cos_fac,$CC_sin_fac) = split(',',$opt_c);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   158
    croak("$0: cannot decode -c $opt_c\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   159
        unless numberp($CC_offset) && numberp($CC_cos_fac) && numberp($CC_sin_fac);
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   160
}
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   161
    
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   162
$LADCP_file = &antsFileArg();
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   163
$CTD_file   = &antsFileArg();
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   164
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   165
&antsAddParams('LADCPproc::LADCP_file',$LADCP_file,'LADCPproc::CTD_file',$CTD_file);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   166
&antsActivateOut();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   167
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   168
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   169
# Step 1: Read LADCP Data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   170
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   171
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   172
print(STDERR "Reading LADCP data ($LADCP_file)...");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   173
readData($LADCP_file,\%LADCP);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   174
printf(STDERR "\n\t%d ensembles",scalar(@{$LADCP{ENSEMBLE}})) if ($opt_d);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   175
print(STDERR "\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   176
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   177
&antsAddParams('LADCPproc::bin_length',$LADCP{BIN_LENGTH});
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   178
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   179
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   180
# Step 2: Set Processing Parameters
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   181
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   182
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   183
print(STDERR "Setting processing parameters...\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   184
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   185
printf(STDERR "\tloading $LADCPPROC/LADCPproc.defaults...\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   186
require "$LADCPPROC/LADCPproc.defaults";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   187
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   188
if (defined($opt_s)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   189
    print(STDERR "\tloading $opt_s...\n");
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   190
    require $opt_s;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   191
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   192
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   193
if ($LADCP{BLANKING_DISTANCE} == 0) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   194
    print(STDERR "\t\tBLANKING_DISTANCE == 0 => excluding all data from bin 1\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   195
        if ($opt_d);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   196
    $wbin_start = 2 unless ($wbin_start > 2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   197
    $ubin_start = 2 unless ($ubin_start > 2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   198
    $shbin_start = 2 unless ($shbin_start > 2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   199
    $BT_bin_start = 2 unless ($BT_bin_start > 2);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   200
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   201
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   202
&antsAddParams('LADCPproc::instrument_orientation',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   203
        $LADCP{ENSEMBLE}[0]->{XDUCER_FACING_UP} ? 'UL' : 'DL');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   204
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   205
$SHEAR_PREGRID_DZ = 20;
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   206
$GRID_DZ = $opt_o;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   207
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   208
&antsAddParams('LADCPproc::vertical_resolution',$GRID_DZ);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   209
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   210
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   211
# Step 3: Read CTD data
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   212
#----------------------------------------------------------------------
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   213
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   214
print(STDERR "Reading CTD data ($CTD_file)...");
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   215
readCTD($CTD_file,\%CTD);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   216
printf(STDERR "\n\t%d scans",scalar(@{$CTD{press}})) if ($opt_d);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   217
print(STDERR "\n");
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   218
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   219
my($year)  = substr($LADCP{ENSEMBLE}[0]->{DATE},6,4);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   220
my($month) = substr($LADCP{ENSEMBLE}[0]->{DATE},0,2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   221
my($day  ) = substr($LADCP{ENSEMBLE}[0]->{DATE},3,2);
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   222
my($magdec,$maginc,$h_strength,$v_strength) = split('\s+',`magdec $CTD{stn_lon} $CTD{stn_lat} $year $month $day`);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   223
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   224
croak("$0: unknown magnetic declination\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   225
	unless defined($magdec);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   226
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   227
&antsAddParams('LADCPproc::magnetic_declination',$magdec);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   228
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   229
#----------------------------------------------------------------------
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   230
# Step 4: Pre-Process CTD & LADCP Data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   231
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   232
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   233
printf(STDERR "Pre-processing data...");
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   234
printf(STDERR "\n\tCTD...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   235
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   236
#------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   237
# clean CTD pressure data
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   238
#------------------------
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   239
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   240
my($pSpikes) = 0;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   241
for (my($r)=1; $r<@{$CTD{press}}; $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   242
	$pSpikes++,$CTD{press}[$r]=nan
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   243
		if (abs($CTD{press}[$r]-$CTD{press}[$r-1])/$CTD{sampint} > 2);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   244
}
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   245
print(STDERR "\n\t\t$pSpikes CTD pressure spikes removed")
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   246
	if ($pSpikes>0 && $opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   247
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   248
#-----------------------------------
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   249
# trim "preamble" without valid data
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   250
#-----------------------------------
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   251
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   252
my($r) = 0;
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   253
until (numberp($CTD{press}[$r]) && numberp($CTD{temp}[$r]) && numberp($CTD{salin}[$r])) { $r++ }
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   254
splice(@{$CTD{press}},0,$r);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   255
splice(@{$CTD{temp}},0,$r);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   256
splice(@{$CTD{salin}},0,$r);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   257
print(STDERR "\n\t\t$r leading CTD scans without valid data removed")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   258
	if ($r>0 && $opt_d);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   259
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   260
#--------------------------------------------------
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   261
# calculate w and find deepest & shallowest records
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   262
#--------------------------------------------------
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   263
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   264
$CTD{maxpress} = -9e99;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   265
$CTD{minpress} =  9e99;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   266
for (my($r)=1; $r<@{$CTD{press}}-1; $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   267
	$CTD{w}[$r] = 0.99*($CTD{press}[$r+1] - $CTD{press}[$r-1]) / (2*$CTD{sampint});
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   268
	if ($CTD{press}[$r] > $CTD{maxpress}) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   269
		$CTD{maxpress} = $CTD{press}[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   270
		$CTD{atbottom} = $r;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   271
    }										
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   272
	if ($CTD{press}[$r] < $CTD{minpress}) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   273
		$CTD{minpress} = $CTD{press}[$r];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   274
		$CTD{attop} = $r;
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   275
    }										
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   276
}
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   277
printf(STDERR "\n\t\tmin/max pressure [%d/%ddbar] at scans#%d/%d",
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   278
					$CTD{minpress},$CTD{maxpress},$CTD{attop},$CTD{atbottom})
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   279
	if $opt_d;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   280
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   281
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   282
# Step 4b: Pre-Process LADCP Data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   283
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   284
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   285
print(STDERR "\n\tLADCP...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   286
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   287
#-------------------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   288
# transform to earth coordinates if required
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   289
#	- discard data from a particular beam if requested
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   290
#	- save beam_vels for later (e.g. wake) editing
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   291
#-------------------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   292
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   293
$U = 0;		# velocity indices
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   294
$V = 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   295
$W = 2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   296
$E = 3;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   297
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   298
$LADCP{HEADING_BIAS} = -$magdec;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   299
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   300
if ($LADCP{BEAM_COORDINATES}) {
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   301
	if ($opt_d) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   302
		print(STDERR "\n\t\ttransforming beam to Earth coordinates...");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   303
		print(STDERR "\n\t\t\tdiscarding data from beam $bad_beam...")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   304
			if ($bad_beam);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   305
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   306
	for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   307
		$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   308
		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   309
			if ($bad_beam) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   310
				undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$bad_beam-1]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   311
				undef($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$bin][$bad_beam-1]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   312
			}
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   313
			@{$LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin]} =  @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]};
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   314
			@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   315
				velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}));
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   316
			@{$LADCP{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$bin]} =					# fake it to fool ref_lr_w
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   317
				(0,0,0,defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]) ? 100 : 0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   318
		}
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   319
		@{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}} =
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   320
			velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}}));
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   321
	}
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   322
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   323
	$LADCP{BEAM_COORDINATES} = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   324
	$LADCP{EARTH_COORDINATES} = 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   325
	unless ($opt_4) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   326
		print(STDERR "\n\t\t\t3-beam solutions: $RDI_Coords::threeBeam_1 $RDI_Coords::threeBeam_2 $RDI_Coords::threeBeam_3 $RDI_Coords::threeBeam_4\n")
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   327
			if ($opt_d);
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   328
		&antsAddParams('LADCPproc::3_beam_solutions',"$RDI_Coords::threeBeam_1 $RDI_Coords::threeBeam_2 $RDI_Coords::threeBeam_3 $RDI_Coords::threeBeam_4");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   329
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   330
} elsif ($LADCP{EARTH_COORDINATES}) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   331
	if ($opt_d) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   332
		if ($opt_c) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   333
			printf(STDERR "\n\t\tcalculating tilt and correcting for compass error and magnetic declination of %.1f deg...\n",$magdec);
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   334
		} else {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   335
			printf(STDERR "\n\t\tcalculating tilt and correcting for magnetic declination of %.1f deg...\n",$magdec);
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   336
		}
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   337
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   338
	for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   339
		$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL});
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   340
		my($hdg) = rad($LADCP{ENSEMBLE}[$ens]->{HEADING});
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   341
		$LADCP{HEADING_BIAS} = ($CC_offset + $CC_cos_fac*cos($hdg) + $CC_sin_fac*sin($hdg)) - $magdec
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   342
			if ($opt_c);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   343
		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   344
			@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   345
				velApplyHdgBias(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   346
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   347
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   348
} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   349
	croak("$0: can only handle beam or earth coordinates\n")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   350
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   351
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   352
#------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   353
# construct a depth-vs-time "profile" from the raw data
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   354
#------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   355
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   356
print(STDERR "\t\tconstructing profile time series...")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   357
	if ($opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   358
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   359
($LADCP_start,$LADCP_end,$LADCP_bottom,$w_gap_time,$zErr,$maxz) =
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   360
    mk_prof(\%LADCP,0,undef,1,6,70,0.1,9999);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   361
croak("\n$LADCP_file: no good ensembles found\n")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   362
    unless defined($LADCP_start);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   363
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   364
my($cast_duration) = $LADCP{ENSEMBLE}[$LADCP_end]->{UNIX_TIME} -
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   365
                     $LADCP{ENSEMBLE}[$LADCP_start]->{UNIX_TIME};
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   366
croak("$0: implausibly short cast ($cast_duration seconds)\n")
14
e22f4b440407 V1.0beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   367
	unless ($cast_duration > 300);
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   368
$LADCP{MEAN_DT} = $cast_duration / ($LADCP_end-$LADCP_start-1);
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   369
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   370
if ($opt_d) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   371
	printf(STDERR "\n\t\t\tStart of cast    : %s (#%5d) at %6.1fm\n",
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   372
	                    $LADCP{ENSEMBLE}[$LADCP_start]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   373
	                    $LADCP{ENSEMBLE}[$LADCP_start]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   374
	                    $LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   375
	printf(STDERR "\t\t\tBottom of cast   : %s (#%5d) at %6.1fm\n",
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   376
	                    $LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   377
	                    $LADCP{ENSEMBLE}[$LADCP_bottom]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   378
	                    $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH});
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   379
	printf(STDERR "\t\t\tEnd of cast      : %s (#%5d) at %6.1fm\n",
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   380
	                    $LADCP{ENSEMBLE}[$LADCP_end]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   381
	                    $LADCP{ENSEMBLE}[$LADCP_end]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   382
	                    $LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH});
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   383
	printf(STDERR "\t\t\tAvg ping interval: %.1fs",$LADCP{MEAN_DT});
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   384
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   385
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   386
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   387
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   388
my($LADCP_prof_range) = $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} -
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   389
							min($LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH},$LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH});
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   390
my($CTD_prof_range) = $CTD{maxpress} - $CTD{minpress};
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   391
croak(sprintf("$0: LADCP profile depth range (%dm) inconsistent with max CTD pressure range (%ddbar) [-z to disable]\n",
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   392
		$LADCP_prof_range,$CTD_prof_range))
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   393
	if (!$opt_z && abs($LADCP_prof_range-0.99*$CTD_prof_range) >
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   394
						max(0.2*0.99*$CTD_prof_range,abs($LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}),50));
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   395
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   396
#----------------------------------------------------------------
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   397
# call edit function
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   398
#	- e.g. for wake editing
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   399
#	- this is done here, because during step 5 the velocities are
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   400
#	  sound-speed corrected, i.e. 
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   401
#----------------------------------------------------------------
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   402
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   403
&edit_LADCP_vels()
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   404
	if (exists(&edit_LADCP_vels));
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   405
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   406
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   407
# Step 5: Add CTD to LADCP Data & correct velocities for sound speed
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   408
#	- {DEPTH} field is overwritten!
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   409
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   410
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   411
print(STDERR "Matching CTD to LADCP time series...");
17
343ba18738cf V1.0beta8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 16
diff changeset
   412
print(STDERR "\n") if defined($opt_l);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   413
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   414
$opt_l = defined($opt_l) ? -$opt_l : &lagLADCP2CTD();
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   415
&antsAddParams('LADCPproc::LADCP_time_lag',-$opt_l);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   416
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   417
print(STDERR "Associating CTD data with LADCP ensembles...");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   418
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   419
for (my($min_depth)=9e99,my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   420
	my($lastSvel); 
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   421
	my($r) = int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint});
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   422
	if ($r < 0 && $ens == $LADCP_start) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   423
		$r = int(($LADCP{ENSEMBLE}[++$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint})
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   424
			while ($r < 0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   425
		printf(STDERR "\n\tCTD data begin with instrument already in water => skipping %ds of LADCP data",
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   426
			$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   427
		$LADCP_start = $ens;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   428
	}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   429
	if ($r > $#{$CTD{press}}) {
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   430
		printf(STDERR "\n\tCTD data end while instrument is still in water => truncating %ds of LADCP data",
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   431
			$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME})
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   432
				if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   433
		$LADCP_end = $ens - 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   434
		last;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   435
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   436
	my($dr);
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   437
	for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {}
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   438
	$LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{stn_lat});
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   439
	if ($LADCP{ENSEMBLE}[$ens]->{DEPTH} < $min_depth) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   440
		$min_depth = $LADCP{ENSEMBLE}[$ens]->{DEPTH};
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   441
		$LADCP_top = $ens;
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   442
	}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   443
	$LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   444
	$LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   445
	$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = sVel($CTD{salin}[$r],$CTD{temp}[$r],$CTD{press}[$r+$dr]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   446
	if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   447
		$lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL};
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   448
	} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   449
		$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = $lastSvel;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   450
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   451
	my($sscorr) = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} / $LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND};
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   452
	for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   453
		next unless defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   454
		$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U] *= $sscorr;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   455
		$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   456
		$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   457
    }
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   458
    $LADCP{ENSEMBLE}[$ens]->{CTD_LAT} = $CTD{lat}[$r];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   459
    $LADCP{ENSEMBLE}[$ens]->{CTD_LON} = $CTD{lon}[$r];
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   460
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   461
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   462
&antsAddParams('LADCPproc::min_depth',round($LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}),
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   463
			   'LADCPproc::max_depth',round($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}),
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   464
			   'LADCPproc::start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   465
			   'LADCPproc::start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME},
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   466
			   'LADCPproc::start_lat',$LADCP{ENSEMBLE}[$LADCP_start]->{CTD_LAT},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   467
			   'LADCPproc::start_lon',$LADCP{ENSEMBLE}[$LADCP_start]->{CTD_LON},
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   468
			   'LADCPproc::bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   469
			   'LADCPproc::bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME},
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   470
			   'LADCPproc::bottom_lat',$LADCP{ENSEMBLE}[$LADCP_bottom]->{CTD_LAT},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   471
			   'LADCPproc::bottom_lon',$LADCP{ENSEMBLE}[$LADCP_bottom]->{CTD_LON},
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   472
			   'LADCPproc::end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE},
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   473
			   'LADCPproc::end_time',$LADCP{ENSEMBLE}[$LADCP_end]->{TIME},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   474
			   'LADCPproc::end_lat',$LADCP{ENSEMBLE}[$LADCP_end]->{CTD_LAT},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   475
			   'LADCPproc::end_lon',$LADCP{ENSEMBLE}[$LADCP_end]->{CTD_LON});
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   476
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   477
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   478
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   479
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   480
# Step 6: Calculate Acoustic Backscatter Profile
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   481
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   482
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   483
print(STDERR "Calculating acoustic backscatter profiles...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   484
mk_backscatter_profs($LADCP_start,$LADCP_end);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   485
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   486
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   487
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   488
# Step 7: Find Seabed
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   489
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   490
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   491
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   492
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   493
	print(STDERR "Finding seabed...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   494
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   495
	print(STDERR "\n\tin acoustic backscatter profiles...") if ($opt_d);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   496
	($water_depth,$sig_water_depth) =
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   497
		find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH});
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   498
	printf(STDERR "\n\t\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   499
		if ($opt_d);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   500
	
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   501
	print(STDERR "\n\tin RDI BT data...") if ($opt_d);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   502
	($BT_water_depth,$sig_BT_water_depth) = 
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   503
		find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES});
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   504
	if (defined($BT_water_depth)) {
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   505
		printf(STDERR "\n\t\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   506
			if ($opt_d);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   507
	} else {
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   508
		printf(STDERR "\n\t\tno seabed found") if ($opt_d);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   509
	}
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   510
	
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   511
	if ($opt_r) {													# use RDI BT data
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   512
		$water_depth = $BT_water_depth;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   513
		$sig_water_depth = $sig_BT_water_depth;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   514
    }
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   515
    $min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH};
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   516
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   517
	if (defined($water_depth)) {
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   518
		printf(STDERR "\n\twater depth      = %d(+-%.1f)m",$water_depth,$sig_water_depth);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   519
		printf(STDERR "\n\tclosest approach = %dmab",$min_hab);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   520
    } else {	
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   521
		print(STDERR "\n\tno seabed found\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   522
		print(STDERR "\n\tunknown water depth => PPI editing disabled\n")
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   523
			if ($opt_d);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   524
		$clip_margin = 0;
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   525
	}
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   526
	
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   527
	print(STDERR "\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   528
	
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   529
} else { # UPLOOKER
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   530
	$water_depth = $sig_water_depth = $min_hab = nan;
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   531
	print(STDERR "Uplooker data => PPI editing disabled\n")
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   532
		if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   533
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   534
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   535
&antsAddParams('LADCPproc::water_depth',round($water_depth),
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   536
			   'LADCPproc::water_depth.sig',round($sig_water_depth));
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   537
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   538
#-----------------------------------------------------------------------
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   539
# Step 8: Edit Data & also produce depth-time-series output via callback
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   540
#-----------------------------------------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   541
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   542
print(STDERR "Calculating shear profiles & producing time-depth-series (.tds) output...");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   543
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   544
@antsNewLayout = ('ens','elapsed','CTD_depth','downcast','CTD_lat','CTD_lon','depth','u_z','v_z','w_z');
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   545
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   546
	#--------------------------------------------------------------------------------
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   547
	# callback routine to output .tds data, called once each for down-/upcasts after
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   548
	# shear has been gridded. Note that only the nominal (bin center) depth is known
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   549
	# for each sample at this stage of processing.
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   550
	#-------------------------------------------------------------------------------
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   551
	
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   552
	sub outTDseries($)
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   553
	{
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   554
		my($downcast) = @_; # also use local [uvw]sh_vals[][]
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   555
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   556
		if ($downcast) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   557
			my($mingi);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   558
			for ($mingi=0; $mingi<@ush_vals; $mingi++) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   559
				last if @{$ush_vals[$mingi]};
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   560
	        }
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   561
			&antsAddParams('LADCPproc::min_ens',$LADCP_start,'LADCPproc::min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   562
						   'LADCPproc::max_ens',$LADCP_end,'LADCPproc::max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   563
						   'LADCPproc::min_depth',depthOfGI($mingi),'LADCPproc::max_depth',depthOfGI($#ens_vals));
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   564
			for (my($gi)=0; $gi<@ush_vals; $gi++) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   565
				for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++){
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   566
					&antsOut($ens_vals[$gi][$i],
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   567
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   568
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{DEPTH},$downcast,
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   569
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{CTD_LAT},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   570
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{CTD_LON},
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   571
							 depthOfGI($gi),$ush_vals[$gi][$i],$vsh_vals[$gi][$i],$wsh_vals[$gi][$i]);
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   572
				}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   573
	        }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   574
		} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   575
			for (my($gi)=$#ush_vals; $gi>=0; $gi--) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   576
				for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++) {
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   577
					&antsOut($ens_vals[$gi][$i],
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   578
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   579
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{DEPTH},$downcast,
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   580
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{CTD_LAT},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   581
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{CTD_LON},
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   582
							 depthOfGI($gi),$ush_vals[$gi][$i],$vsh_vals[$gi][$i],$wsh_vals[$gi][$i]);
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   583
				}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   584
	        }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   585
	    }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   586
	} # sub outDSseries
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   587
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   588
	#--------------------------------------------------------------------------------
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   589
	# end of callback routine
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   590
	#--------------------------------------------------------------------------------
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   591
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   592
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   593
$commonParams = $antsCurParams;										# PARAMs added up to now are common to all output files
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   594
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   595
&antsAddParams('LADCPproc::ubin_start',$ubin_start,'LADCPproc::ubin_end',$ubin_end,		# record processing params
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   596
			   'LADCPproc::wbin_start',$wbin_start,'LADCPproc::wbin_end',$wbin_end,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   597
			   'LADCPproc::shbin_start',$shbin_start,'LADCPproc::shbin_end',$shbin_end,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   598
			   'LADCPproc::w_ref_bin',$w_ref_bin,'LADCPproc::w_dif',$w_dif,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   599
			   'LADCPproc::wake_hd_dif',$wake_hd_dif,'LADCPproc::wake_ang_min',$wake_ang_min,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   600
			   'LADCPproc::min_wake_w',$min_wake_w,'LADCPproc::n_wake_bins',$n_wake_bins,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   601
			   'LADCPproc::e_max',$e_max,'LADCPproc::min_cor',$min_cor,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   602
			   'LADCPproc::max_shdev',$max_shdev,'LADCPproc::max_shdev_sum',$max_shdev_sum,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   603
			   'LADCPproc::min_hab',round($min_hab),'LADCPproc::PPI_editing_enabled',$PPI_editing_enabled,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   604
			   'LADCPproc::clip_margin',$clip_margin,'LADCPproc::first_clip_bin',$first_clip_bin,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   605
			   'LADCPproc::Svbin_start',$Svbin_start,'LADCPproc::Svbin_end',$Svbin_end,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   606
			   'LADCPproc::BT_bin_start',$BT_bin_start,'LADCPproc::BT_bin_search_above',$BT_bin_search_above,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   607
			   'LADCPproc::BT_max_bin_spread',$BT_max_bin_spread,'LADCPproc::BT_max_w_difference',$BT_max_w_difference,
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   608
);
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   609
if (defined($BT_min_depth)) {										# BT-related params
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   610
	&antsAddParams('LADCPproc::BT_min_depth',$BT_min_depth,'LADCPproc::BT_max_depth',$BT_max_depth);
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   611
} else {
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   612
	&antsAddParams('LADCPproc::BT_max_depth_error',$BT_max_depth_error);
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   613
}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   614
$fullParams = $antsCurParams;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   615
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   616
$LADCP_start = 1 if ($LADCP_start == 0);							# ensure that there is previous ensemble
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   617
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   618
print(STDERR "\n\tdowncast...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   619
edit_velocity($LADCP_start,$LADCP_bottom);							# downcast
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   620
calc_shear($LADCP_start,$LADCP_bottom,$SHEAR_PREGRID_DZ,0);			# pre-grid shear @SHEAR_PREGRID_DZm resolution
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   621
calc_shear($LADCP_start,$LADCP_bottom,$GRID_DZ,1);					# calculate final gridded shear profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   622
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   623
@dc_sh_n = @sh_n;													# save downcast results
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   624
@dc_ush_mu = @ush_mu; @dc_ush_sig = @ush_sig;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   625
@dc_vsh_mu = @vsh_mu; @dc_vsh_sig = @vsh_sig;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   626
@dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   627
@dc_esh_mu = @esh_mu;
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   628
@dc_lash_mu = @lash_mu; @dc_losh_mu = @losh_mu;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   629
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   630
print(STDERR "\n\tupcast...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   631
edit_velocity($LADCP_end,$LADCP_bottom);							# upcast
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   632
calc_shear($LADCP_end,$LADCP_bottom,$SHEAR_PREGRID_DZ,0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   633
calc_shear($LADCP_end,$LADCP_bottom,$GRID_DZ,1);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   634
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   635
@uc_sh_n = @sh_n;													# save upcast results
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   636
@uc_ush_mu = @ush_mu; @uc_ush_sig = @ush_sig;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   637
@uc_vsh_mu = @vsh_mu; @uc_vsh_sig = @vsh_sig;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   638
@uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   639
@uc_esh_mu = @esh_mu;
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   640
@uc_lash_mu = @lash_mu; @uc_losh_mu = @losh_mu;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   641
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   642
print(STDERR "\n\tcombined...") if ($opt_d);
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   643
my($nsh) = (@dc_ush_mu > @uc_ush_mu) ? scalar(@dc_ush_mu) : scalar(@uc_ush_mu);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   644
for (my($gi)=0; $gi<$nsh; $gi++) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   645
	if (($gi<@dc_ush_mu&&$dc_sh_n[$gi]>0) && ($gi<@uc_ush_mu&&$uc_sh_n[$gi]>0)) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   646
		$sh_n[$gi] = $dc_sh_n[$gi] + $uc_sh_n[$gi];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   647
		$ush_mu[$gi] = ($dc_sh_n[$gi]*$dc_ush_mu[$gi] + $uc_sh_n[$gi]*$uc_ush_mu[$gi]) / $sh_n[$gi];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   648
		$vsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_vsh_mu[$gi] + $uc_sh_n[$gi]*$uc_vsh_mu[$gi]) / $sh_n[$gi];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   649
		$wsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_wsh_mu[$gi] + $uc_sh_n[$gi]*$uc_wsh_mu[$gi]) / $sh_n[$gi];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   650
		$esh_mu[$gi] = ($dc_sh_n[$gi]*$dc_esh_mu[$gi] + $uc_sh_n[$gi]*$uc_esh_mu[$gi]) / $sh_n[$gi];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   651
		$ush_sig[$gi] = sqrt(($dc_sh_n[$gi]*$dc_ush_sig[$gi]**2 + $uc_sh_n[$gi]*$uc_ush_sig[$gi]**2) / $sh_n[$gi]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   652
		$vsh_sig[$gi] = sqrt(($dc_sh_n[$gi]*$dc_vsh_sig[$gi]**2 + $uc_sh_n[$gi]*$uc_vsh_sig[$gi]**2) / $sh_n[$gi]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   653
		$wsh_sig[$gi] = sqrt(($dc_sh_n[$gi]*$dc_wsh_sig[$gi]**2 + $uc_sh_n[$gi]*$uc_wsh_sig[$gi]**2) / $sh_n[$gi]);
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   654
	} elsif ($gi < @dc_ush_mu && $dc_sh_n[$gi] > 0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   655
		$sh_n[$gi] = $dc_sh_n[$gi];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   656
		$ush_mu[$gi]  = $dc_ush_mu[$gi];  $vsh_mu[$gi]  = $dc_vsh_mu[$gi];  $wsh_mu[$gi]  = $dc_wsh_mu[$gi];  $esh_mu[$gi]  = $dc_esh_mu[$gi];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   657
		$ush_sig[$gi] = $dc_ush_sig[$gi]; $vsh_sig[$gi] = $dc_vsh_sig[$gi]; $wsh_sig[$gi] = $dc_wsh_sig[$gi]; 
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   658
	} elsif ($gi < @uc_ush_mu && $uc_sh_n[$gi] > 0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   659
		$sh_n[$gi] = $uc_sh_n[$gi];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   660
		$ush_mu[$gi]  = $uc_ush_mu[$gi];  $vsh_mu[$gi]  = $uc_vsh_mu[$gi];  $wsh_mu[$gi]  = $uc_wsh_mu[$gi];  $esh_mu[$gi]  = $uc_esh_mu[$gi];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   661
		$ush_sig[$gi] = $uc_ush_sig[$gi]; $vsh_sig[$gi] = $uc_vsh_sig[$gi]; $wsh_sig[$gi] = $uc_wsh_sig[$gi]; 
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   662
	} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   663
		$sh_n[$gi] = 0;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   664
		$ush_mu[$gi]  = $vsh_mu[$gi]  = $wsh_mu[$gi]  = $esh_mu[$gi]  = nan;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   665
		$ush_sig[$gi] = $vsh_sig[$gi] = $wsh_sig[$gi] = nan;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   666
	}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   667
}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   668
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   669
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   670
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   671
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   672
# Step 9: Get bottom track profile
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   673
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   674
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   675
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   676
	print(STDERR "Getting BT profile...");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   677
	getBTprof($LADCP_start,$LADCP_end);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   678
	print(STDERR "\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   679
}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   680
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   681
#----------------------------------------------------------------------
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   682
# Step 10: Write Output Profiles if requested
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   683
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   684
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   685
if (defined($opt_p)) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   686
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   687
	print(STDERR "Writing shear profiles...");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   688
	
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   689
	@antsNewLayout = ('depth','dc_elapsed','dc_lat','dc_lon','dc_nsamp','dc_u_z','dc_u_z.sig','dc_v_z','dc_v_z.sig','dc_w_z','dc_w_z.sig',
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   690
							  'uc_elapsed','uc_lat','uc_lon','uc_nsamp','uc_u_z','uc_u_z.sig','uc_v_z','uc_v_z.sig','uc_w_z','uc_w_z.sig',
10
196a179304ee 1.0beta
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 9
diff changeset
   691
							  'elapsed','nsamp','u_z','u_z.sig','v_z','v_z.sig','w_z','w_z.sig','Sv','Sv.nsamp');
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   692
							  
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   693
	&antsOut('EOF');
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   694
    close(STDOUT);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   695
	open(STDOUT,">$opt_p") || croak("$opt_p: $!\n");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   696
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   697
	$antsCurParams = $fullParams;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   698
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   699
	for (my($gi)=0; $gi<$nsh; $gi++) {
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   700
		&antsOut(depthOfGI($gi),										# depth in center of bin
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   701
				 $dc_esh_mu[$gi],$dc_lash_mu[$gi],$dc_losh_mu[$gi],		# downcast
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   702
				 numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0,
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   703
				 $dc_ush_mu[$gi],$dc_ush_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   704
				 $dc_vsh_mu[$gi],$dc_vsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   705
				 $dc_wsh_mu[$gi],$dc_wsh_sig[$gi],
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   706
				 $uc_esh_mu[$gi],$uc_lash_mu[$gi],$uc_losh_mu[$gi],		# upcast
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   707
				 numberp($uc_sh_n[$gi])?$uc_sh_n[$gi]:0,
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   708
				 $uc_ush_mu[$gi],$uc_ush_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   709
				 $uc_vsh_mu[$gi],$uc_vsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   710
				 $uc_wsh_mu[$gi],$uc_wsh_sig[$gi],
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   711
				 $esh_mu[$gi],$sh_n[$gi],								# combined
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   712
				 $ush_mu[$gi],$ush_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   713
				 $vsh_mu[$gi],$vsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   714
				 $wsh_mu[$gi],$wsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   715
				 $nSv_prof[$gi]?$sSv_prof[$gi]/$nSv_prof[$gi]:nan,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   716
				 $nSv_prof[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   717
		);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   718
	}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   719
	
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   720
	print(STDERR "\n");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   721
} # if -p
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   722
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   723
#---------------------------------------
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   724
# Acoustic backscatter depth-time-series
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   725
#---------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   726
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   727
if (defined($opt_a)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   728
	print(STDERR "Writing acoustic backscatter depth-time-series to <$opt_a>...");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   729
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   730
	
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   731
	@antsNewLayout = ('ens','elapsed','CTD_depth','CTD_lat','CTD_lon','depth','bin','downcast',
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   732
					  'Sv_beam1','Sv_beam2','Sv_beam3','Sv_beam4','Sv.median');
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   733
	&antsOut('EOF');
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   734
    close(STDOUT);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   735
	open(STDOUT,">$opt_a") || croak("$opt_a: $!\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   736
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   737
	$antsCurParams = $commonParams;
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   738
	&antsAddParams('LADCPproc::min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   739
				   'LADCPproc::max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   740
				   'LADCPproc::min_depth',$LADCP{ENSEMBLE}[$LADCP_top]->{XDUCER_FACING_UP} ?
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   741
	   					&depthOfBin($LADCP_top,$LADCP{N_BINS}-1) : $LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH},
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 19
diff changeset
   742
				   'LADCPproc::max_depth',$LADCP{ENSEMBLE}[$LADCP_bottom]->{XDUCER_FACING_UP} ?
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   743
	   					$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} : &depthOfBin($LADCP_bottom,$LADCP{N_BINS}-1)
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   744
	);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   745
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   746
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   747
		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   748
			&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   749
					 $LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   750
					 $LADCP{ENSEMBLE}[$ens]->{DEPTH},
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   751
					 $LADCP{ENSEMBLE}[$ens]->{CTD_LAT},$LADCP{ENSEMBLE}[$ens]->{CTD_LON},
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   752
					 &depthOfBin($ens,$bin),$bin+1,
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   753
					 ($ens <= $LADCP_bottom) ? 1 : 0,
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   754
					 @{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]},
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   755
					 median(@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]})
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   756
			);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   757
		}	 
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   758
	}
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   759
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   760
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   761
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   762
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   763
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   764
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   765
if (defined($opt_t)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   766
	print(STDERR "Writing time series to <$opt_t>...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   767
	
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   768
	@antsNewLayout = ('ens','elapsed','depth','CTD_lat','CTD_lon','CTD_w','LADCP_w','pitch','roll','hdg');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   769
	&antsOut('EOF');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   770
	$antsCurParams = $commonParams;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   771
	close(STDOUT);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   772
	open(STDOUT,">$opt_t") || croak("$opt_t: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   773
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   774
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   775
		&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   776
				 $LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   777
				 $LADCP{ENSEMBLE}[$ens]->{DEPTH},
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   778
				 $LADCP{ENSEMBLE}[$ens]->{CTD_LAT},
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   779
				 $LADCP{ENSEMBLE}[$ens]->{CTD_LON},
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   780
				 $LADCP{ENSEMBLE}[$ens]->{CTD_W},
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   781
				 $LADCP{ENSEMBLE}[$ens]->{W},
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   782
				 $LADCP{ENSEMBLE}[$ens]->{PITCH},
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   783
				 $LADCP{ENSEMBLE}[$ens]->{ROLL},
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   784
				 $LADCP{ENSEMBLE}[$ens]->{HEADING},
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   785
		);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   786
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   787
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   788
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   789
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   790
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   791
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   792
if (defined($opt_b)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   793
	print(STDERR "Writing bottom-track data to <$opt_b>...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   794
	
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   795
	@antsNewLayout = ('depth','u','v','w','u.sig','v.sig','w.sig','nsamp');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   796
	&antsOut('EOF');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   797
	$antsCurParams = $commonParams;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   798
	close(STDOUT);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   799
	open(STDOUT,">$opt_b") || croak("$opt_b: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   800
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   801
	my($skipped);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   802
	for (my($gi)=0; $gi<@BT_nsamp; $gi++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   803
		$skipped = 1 if ($BT_nsamp[$gi] > 0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   804
		next unless ($skipped);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   805
		&antsOut(depthOfGI($gi),$BTu[$gi],$BTv[$gi],$BTw[$gi],$BTu_sig[$gi],$BTv_sig[$gi],$BTw_sig[$gi],$BT_nsamp[$gi]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   806
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   807
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   808
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   809
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   810
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   811
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   812
if (defined($opt_f)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   813
	print(STDERR "Writing data flags to <$opt_f>...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   814
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   815
	@antsNewLayout = ('ens');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   816
	for (my($i)=1; $i<=$LADCP{N_BINS}; $i++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   817
		$antsNewLayout[$i] = "bin$i";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   818
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   819
	&antsOut('EOF');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   820
	$antsCurParams = $commonParams;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   821
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   822
	close(STDOUT);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   823
	open(STDOUT,">$opt_f") || croak("$opt_f: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   824
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   825
	&antsPrintHeaders(STDOUT,@antsNewLayout);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   826
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   827
		printf('%4d  ',$LADCP{ENSEMBLE}[$ens]->{NUMBER});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   828
		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   829
			printf("%02x ",$edit_flags[$ens][$bin]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   830
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   831
		print($opt_R);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   832
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   833
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   834
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   835
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   836
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   837
&antsExit();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   838