LADCPproc
author A.M. Thurnherr <athurnherr@yahoo.com>
Sat, 06 Apr 2013 13:10:52 +0000
changeset 19 12aaf0962ee6
parent 18 ef28756fa320
child 20 7caeef8595b0
permissions -rwxr-xr-x
before EGU 2013
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
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
     5
#                    dlm: Fri Mar 29 15:24:15 2013
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
     6
#                    (c) 2010 A.M. Thurnherr
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
     7
#                    uE-Info: 97 66 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
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    14
#   - comments starting with ## are taken verbatim from the original implementations
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    15
#   - 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
    16
#     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
    17
#   - for SeaBird files:
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    18
#       - 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
    19
#       - first elapsed time is added on output
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    20
#   - output elapsed time is from CTD to allow yoyo processing without loss of
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    21
#     time information
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    22
#   - 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
    23
#   - ITS-90 temp field in degC required
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    24
#   - salin field prequired
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    25
#   - pressure field in dbar required
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    26
#   - -i should be set to the number that's added to LADCP_elapsed to make the two
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    27
#     time series overplot nicely
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    28
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    29
# HISTORY:
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    30
#   Sep 16, 2010: - incepted
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    31
#   Oct 13, 2010: - first working version
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    32
#   Oct 14, 2010: - renamed from LADCPshear
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    33
#   Oct 19, 2010: - added -a)coustic backscatter profiles
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    34
#   Oct 20, 2010: - added -2)dary CTD sensors
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    35
#   Oct 23, 2010: - added magnetic-declination correction
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    36
#   Oct 26, 2010: - added tilt calculation
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    37
#   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
    38
#   Dec 10, 2010: - change -w) default to 120s
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    39
#                 - 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
    40
#   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
    41
#   Jan 10, 2011: - -o => -k added new -o
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    42
#                 - added code to fill CTD sound vel gaps
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    43
#   Jan 22, 2011: - added -g) lat,lon
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    44
#                 - added -c)ompass corr
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    45
#   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
    46
#   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
    47
#                 - 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
    48
#                   acoustic backscatter depth-time-series
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    49
#                 - 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
    50
#                 - made non-diagnostic output terser
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    51
#   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
    52
#   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
    53
#   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
    54
#                 - added T[hurnherr11] -u)se option
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    55
#                 - added $CTD{first_elapsed}
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    56
#   Jul 27, 2011: - replaced ndata by nsamp
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    57
#   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
    58
#   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
    59
#                 - replaced "nshear" output field by "nsamp"
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    60
#                 - 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
    61
#                 - 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
    62
#   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
    63
#                 - improved and relaxed depth consistency check
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    64
#   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
    65
#                 - 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
    66
#   Apr 13, 2012: - removed -s argument from dependencies
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
    67
#	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
    68
#	Apr 18, 2012: - replaced Sv.n by Sv.nsamp
11
d0af7f7aa23b V1.0beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
    69
#	May 16, 2012: - adapted to ANTSlib V5.0
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    70
#				  - added support for -r)DI BT data
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    71
#				  - added $LADCP{MEAN_DT} from vertical-velocity code
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    72
#	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
    73
#					which is required for Dan Torres' shallow casts
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    74
#				  - added version info
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    75
#	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
    76
#	Jun 13, 2012: - added CTD_depth to tds output
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
    77
#	Oct 28, 2012: - added -z
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    78
#	Mar 16, 2013: - BUG: usage message had a -p)PI flag
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    79
11
d0af7f7aa23b V1.0beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
    80
($ANTS)    = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    81
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    82
($LADCPPROC)  = ($0 =~ m{^(.*)/[^/]*$});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    83
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    84
require "$ANTS/ants.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    85
require "$ANTS/libEOS83.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    86
require "$ANTS/libstats.pl";
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    87
require "$LADCPPROC/LADCPproc.version";
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    88
require "$LADCPPROC/LADCPproc.loadCTD";
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    89
require "$LADCPPROC/LADCPproc.bestLag";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    90
require "$LADCPPROC/LADCPproc.BT";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    91
require "$LADCPPROC/LADCPproc.backscatter";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    92
require "$LADCPPROC/LADCPproc.UHcode";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    93
require "$PERL_TOOLS/RDI_BB_Read.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    94
require "$PERL_TOOLS/RDI_Coords.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    95
require "$PERL_TOOLS/RDI_Utils.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    96
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    97
$ANTSLIBS = $LADCPPROC;							# for -L libraries
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    98
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    99
$antsSummary = "$version -- process LADCP data to get shear, time series";
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   100
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   101
$antsParseHeader = 0;
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   102
&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
   103
    '[use -2)dary CTD sensor pair]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   104
    '[require -4)-beam LADCP solutions]',
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   105
    '[use -r)DI bottom-track data]',
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   106
    '[-s)etup <file>] [-g)ps <lat,lon>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   107
    '[-c)ompass-corr <offset,cos-fac,sin-fac>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   108
    '[-o)utput grid <resolution[5m]>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   109
    '[-i)nitial LADCP time lag <guestimate>]',
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   110
    '[-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
   111
    '[correct echo amplitude -u)sing D[eines99]|V[isbeck04]|T[hurnherr11]|n[ocorr]',
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   112
    '[-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
   113
    '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
   114
    '        [-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
   115
    '<RDI file> <SeaBird file>');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   116
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   117
$RDI_Coords::minValidVels = 4 if ($opt_4);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   118
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   119
&antsFloatOpt($opt_l);
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   120
&antsCardOpt(\$opt_w,120);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   121
    # 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
   122
    # 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
   123
    # 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
   124
    # related to ambiguity velocity
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   125
&antsCardOpt(\$opt_n,20);
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   126
#&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
   127
&antsFloatOpt($opt_i);
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   128
&antsCardOpt(\$opt_o,5);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   129
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   130
if (defined($opt_u)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   131
    croak("$0: cannot decode -u $opt_u\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   132
        unless ($opt_u =~ /^[dDvVtTn]/);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   133
} else {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   134
    $opt_u = 'Deines99';
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   135
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   136
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   137
if (defined($opt_g)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   138
    ($CTD{lat},$CTD{lon}) = split(',',$opt_g);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   139
    croak("$0: cannot decode -g $opt_g\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   140
        unless numberp($CTD{lat}) && numberp($CTD{lon});
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   141
}
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   142
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   143
if (defined($opt_c)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   144
    ($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
   145
    croak("$0: cannot decode -c $opt_c\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   146
        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
   147
}
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   148
    
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   149
$LADCP_file = &antsFileArg();
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   150
$CTD_file   = &antsFileArg();
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   151
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   152
&antsAddParams('LADCP_file',$LADCP_file,'CTD_file',$CTD_file);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   153
&antsActivateOut();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   154
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   155
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   156
# Step 1: Read LADCP Data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   157
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   158
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   159
print(STDERR "Reading LADCP data ($LADCP_file)...");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   160
readData($LADCP_file,\%LADCP);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   161
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
   162
print(STDERR "\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   163
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   164
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   165
# Step 2: Set Processing Parameters
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   166
#----------------------------------------------------------------------
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
print(STDERR "Setting processing parameters...\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   169
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   170
printf(STDERR "\tloading $LADCPPROC/LADCPproc.defaults...\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   171
require "$LADCPPROC/LADCPproc.defaults";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   172
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   173
if (defined($opt_s)) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   174
    print(STDERR "\tloading $opt_s...\n");
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   175
    require $opt_s;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   176
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   177
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   178
if ($LADCP{BLANKING_DISTANCE} == 0) {
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   179
    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
   180
        if ($opt_d);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   181
    $wbin_start = 2 unless ($wbin_start > 2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   182
    $ubin_start = 2 unless ($ubin_start > 2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   183
    $shbin_start = 2 unless ($shbin_start > 2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   184
    $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
   185
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   186
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   187
&antsAddParams('ADCP_orientation',
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   188
        $LADCP{ENSEMBLE}[0]->{XDUCER_FACING_UP} ? 'uplooker' : 'downlooker');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   189
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   190
$SHEAR_PREGRID_DZ = 20;
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   191
$GRID_DZ = $opt_o;
0
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
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   194
# Step 3: Read CTD data
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   195
#----------------------------------------------------------------------
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   196
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   197
print(STDERR "Reading CTD data ($CTD_file)...");
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   198
readCTD($CTD_file,\%CTD);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   199
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
   200
print(STDERR "\n");
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   201
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   202
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
   203
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
   204
my($day  ) = substr($LADCP{ENSEMBLE}[0]->{DATE},3,2);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   205
my($magdec,$maginc,$h_strength,$v_strength) = split('\s+',`magdec $CTD{lon} $CTD{lat} $year $month $day`);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   206
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   207
croak("$0: unknown magnetic declination\n")
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   208
	unless defined($magdec);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   209
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   210
&antsAddParams('magnetic_declination',$magdec);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   211
1
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
# Step 4: Pre-Process CTD & LADCP Data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   214
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   215
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   216
printf(STDERR "Pre-processing data...");
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   217
printf(STDERR "\n\tCTD...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   218
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   219
#------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   220
# clean CTD pressure data
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   221
#------------------------
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   222
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   223
my($pSpikes) = 0;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   224
for (my($r)=1; $r<@{$CTD{press}}; $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   225
	$pSpikes++,$CTD{press}[$r]=nan
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   226
		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
   227
}
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   228
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
   229
	if ($pSpikes>0 && $opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   230
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   231
#-----------------------------------
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   232
# trim "preamble" without valid data
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   233
#-----------------------------------
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   234
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   235
my($r) = 0;
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   236
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
   237
splice(@{$CTD{press}},0,$r);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   238
splice(@{$CTD{temp}},0,$r);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   239
splice(@{$CTD{salin}},0,$r);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   240
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
   241
	if ($r>0 && $opt_d);
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   242
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   243
#--------------------------------------------------
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   244
# calculate w and find deepest & shallowest records
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   245
#--------------------------------------------------
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   246
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   247
$CTD{maxpress} = -9e99;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   248
$CTD{minpress} =  9e99;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   249
for (my($r)=1; $r<@{$CTD{press}}-1; $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   250
	$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
   251
	if ($CTD{press}[$r] > $CTD{maxpress}) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   252
		$CTD{maxpress} = $CTD{press}[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   253
		$CTD{atbottom} = $r;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   254
    }										
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   255
	if ($CTD{press}[$r] < $CTD{minpress}) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   256
		$CTD{minpress} = $CTD{press}[$r];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   257
		$CTD{attop} = $r;
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   258
    }										
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   259
}
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   260
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
   261
					$CTD{minpress},$CTD{maxpress},$CTD{attop},$CTD{atbottom})
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   262
	if $opt_d;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   263
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   264
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   265
# Step 4b: Pre-Process LADCP Data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   266
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   267
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   268
print(STDERR "\n\tLADCP...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   269
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   270
#-------------------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   271
# transform to earth coordinates if required
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   272
#	- save beam_vels for later (e.g. wake) editing
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   273
#-------------------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   274
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   275
$U = 0;		# velocity indices
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   276
$V = 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   277
$W = 2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   278
$E = 3;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   279
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   280
$LADCP{HEADING_BIAS} = -$magdec;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   281
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   282
if ($LADCP{BEAM_COORDINATES}) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   283
	print(STDERR "\n\t\ttransforming beam to Earth coordinates...")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   284
		if ($opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   285
	for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   286
		$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
   287
		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   288
			@{$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
   289
			@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   290
				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
   291
			@{$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
   292
				(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
   293
		}
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   294
		@{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}} =
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   295
			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
   296
	}
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   297
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   298
	$LADCP{BEAM_COORDINATES} = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   299
	$LADCP{EARTH_COORDINATES} = 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   300
	unless ($opt_4) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   301
		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
   302
			if ($opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   303
		&antsAddParams('3_beam_solutions',"$RDI_Coords::threeBeam_1 $RDI_Coords::threeBeam_2 $RDI_Coords::threeBeam_3 $RDI_Coords::threeBeam_4");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   304
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   305
} elsif ($LADCP{EARTH_COORDINATES}) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   306
	if ($opt_d) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   307
		if ($opt_c) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   308
			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
   309
		} else {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   310
			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
   311
		}
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   312
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   313
	for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   314
		$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
   315
		my($hdg) = rad($LADCP{ENSEMBLE}[$ens]->{HEADING});
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   316
		$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
   317
			if ($opt_c);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   318
		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
   319
			@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} =
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   320
				velApplyHdgBias(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   321
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   322
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   323
} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   324
	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
   325
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   326
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   327
#------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   328
# 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
   329
#------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   330
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   331
print(STDERR "\t\tconstructing profile time series...")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   332
	if ($opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   333
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   334
($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
   335
    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
   336
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
   337
    unless defined($LADCP_start);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   338
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   339
my($cast_duration) = $LADCP{ENSEMBLE}[$LADCP_end]->{UNIX_TIME} -
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   340
                     $LADCP{ENSEMBLE}[$LADCP_start]->{UNIX_TIME};
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   341
croak("$0: implausibly short cast ($cast_duration seconds)\n")
14
e22f4b440407 V1.0beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   342
	unless ($cast_duration > 300);
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   343
$LADCP{MEAN_DT} = $cast_duration / ($LADCP_end-$LADCP_start-1);
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   344
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   345
if ($opt_d) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   346
	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
   347
	                    $LADCP{ENSEMBLE}[$LADCP_start]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   348
	                    $LADCP{ENSEMBLE}[$LADCP_start]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   349
	                    $LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   350
	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
   351
	                    $LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   352
	                    $LADCP{ENSEMBLE}[$LADCP_bottom]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   353
	                    $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH});
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   354
	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
   355
	                    $LADCP{ENSEMBLE}[$LADCP_end]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   356
	                    $LADCP{ENSEMBLE}[$LADCP_end]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   357
	                    $LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH});
13
b2a581b79645 V1.0beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   358
	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
   359
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   360
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   361
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   362
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   363
my($LADCP_prof_range) = $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} -
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
   364
							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
   365
my($CTD_prof_range) = $CTD{maxpress} - $CTD{minpress};
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   366
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
   367
		$LADCP_prof_range,$CTD_prof_range))
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   368
	if (!$opt_z && abs($LADCP_prof_range-0.99*$CTD_prof_range) >
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   369
						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
   370
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   371
#----------------------------------------------------------------
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   372
# call edit function
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   373
#	- e.g. for wake editing
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   374
#	- 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
   375
#	  sound-speed corrected, i.e. 
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   376
#----------------------------------------------------------------
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   377
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   378
&edit_LADCP_vels()
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   379
	if (exists(&edit_LADCP_vels));
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   380
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   381
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   382
# 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
   383
#	- {DEPTH} field is overwritten!
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 "Matching CTD to LADCP time series...");
17
343ba18738cf V1.0beta8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 16
diff changeset
   387
print(STDERR "\n") if defined($opt_l);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   388
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   389
$opt_l = defined($opt_l) ? -$opt_l : &lagLADCP2CTD();
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   390
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   391
print(STDERR "Associating CTD data with LADCP ensembles...");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   392
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   393
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
   394
	my($lastSvel); 
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   395
	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
   396
	if ($r < 0 && $ens == $LADCP_start) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   397
		$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
   398
			while ($r < 0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   399
		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
   400
			$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
   401
		$LADCP_start = $ens;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   402
	}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   403
	if ($r > $#{$CTD{press}}) {
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   404
		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
   405
			$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
   406
				if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   407
		$LADCP_end = $ens - 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   408
		last;
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
	my($dr);
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   411
	for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   412
	$LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{lat});
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   413
	if ($LADCP{ENSEMBLE}[$ens]->{DEPTH} < $min_depth) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   414
		$min_depth = $LADCP{ENSEMBLE}[$ens]->{DEPTH};
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   415
		$LADCP_top = $ens;
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   416
	}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   417
	$LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   418
	$LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   419
	$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
   420
	if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   421
		$lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL};
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   422
	} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   423
		$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = $lastSvel;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   424
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   425
	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
   426
	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
   427
		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
   428
		$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U] *= $sscorr;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   429
		$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   430
		$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   431
    }
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   432
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   433
9
48b2d27aaebf after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 8
diff changeset
   434
&antsAddParams('top_depth',round($LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}),
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   435
			   'bottom_depth',round($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}),
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   436
			   'start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   437
			   'start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   438
			   'bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   439
			   'bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   440
			   'end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   441
			   'end_time',$LADCP{ENSEMBLE}[$LADCP_end]->{TIME});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   442
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   443
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   444
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   445
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   446
# Step 6: Calculate Acoustic Backscatter Profile
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   447
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   448
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   449
print(STDERR "Calculating acoustic backscatter profiles...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   450
mk_backscatter_profs($LADCP_start,$LADCP_end);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   451
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   452
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   453
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   454
# Step 7: Find Seabed
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   455
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   456
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   457
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   458
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   459
	print(STDERR "Finding seabed...");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   460
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   461
	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
   462
	($water_depth,$sig_water_depth) =
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   463
		find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH});
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   464
	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
   465
		if ($opt_d);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   466
	
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   467
	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
   468
	($BT_water_depth,$sig_BT_water_depth) = 
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   469
		find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES});
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   470
	if (defined($BT_water_depth)) {
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   471
		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
   472
			if ($opt_d);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   473
	} else {
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   474
		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
   475
	}
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   476
	
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   477
	if ($opt_r) {													# use RDI BT data
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   478
		$water_depth = $BT_water_depth;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   479
		$sig_water_depth = $sig_BT_water_depth;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   480
    }
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   481
    $min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH};
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   482
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   483
	if (defined($water_depth)) {
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   484
		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
   485
		printf(STDERR "\n\tclosest approach = %dmab",$min_hab);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   486
    } else {	
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   487
		print(STDERR "\n\tno seabed found\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   488
		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
   489
			if ($opt_d);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   490
		$clip_margin = 0;
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   491
	}
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 "\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   494
	
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   495
} else { # UPLOOKER
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   496
	$water_depth = $sig_water_depth = $min_hab = nan;
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   497
	print(STDERR "Uplooker data => PPI editing disabled\n")
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   498
		if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   499
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   500
19
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   501
#-----------------------------------------------------------------------
12aaf0962ee6 before EGU 2013
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   502
# 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
   503
#-----------------------------------------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   504
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   505
print(STDERR "Calculating shear profiles & producing time-depth-series (.tds) output...");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   506
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   507
@antsNewLayout = ('ens','elapsed','CTD_depth','downcast','depth','u_z','v_z','w_z');
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   508
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   509
	#--------------------------------------------------------------------------------
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   510
	# callback routine to output .tds data, called once each for down-/upcasts after
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   511
	# 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
   512
	# for each sample at this stage of processing.
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   513
	#-------------------------------------------------------------------------------
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   514
	
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   515
	sub outTDseries($)
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   516
	{
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   517
		my($downcast) = @_; # also use local [uvw]sh_vals[][]
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   518
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   519
		if ($downcast) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   520
			my($mingi);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   521
			for ($mingi=0; $mingi<@ush_vals; $mingi++) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   522
				last if @{$ush_vals[$mingi]};
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   523
	        }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   524
			&antsAddParams('min_ens',$LADCP_start,'min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   525
						   'max_ens',$LADCP_end,'max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   526
						   'min_depth',depthOfGI($mingi),'max_depth',depthOfGI($#ens_vals));
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   527
			for (my($gi)=0; $gi<@ush_vals; $gi++) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   528
				for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++){
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   529
					&antsOut($ens_vals[$gi][$i],
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   530
							 $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
   531
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{DEPTH},$downcast,
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   532
							 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
   533
				}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   534
	        }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   535
		} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   536
			for (my($gi)=$#ush_vals; $gi>=0; $gi--) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   537
				for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++) {
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   538
					&antsOut($ens_vals[$gi][$i],
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   539
							 $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
   540
							 $LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{DEPTH},$downcast,
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   541
							 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
   542
				}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   543
	        }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   544
	    }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   545
	} # sub outDSseries
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   546
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   547
	#--------------------------------------------------------------------------------
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   548
	# end of callback routine
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   549
	#--------------------------------------------------------------------------------
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   550
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   551
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   552
$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
   553
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   554
&antsAddParams('ubin_start',$ubin_start,'ubin_end',$ubin_end,		# record processing params
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   555
			   'wbin_start',$wbin_start,'wbin_end',$wbin_end,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   556
			   'shbin_start',$shbin_start,'shbin_end',$shbin_end,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   557
			   'w_ref_bin',$w_ref_bin,'w_dif',$w_dif,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   558
			   'wake_hd_dif',$wake_hd_dif,'wake_ang_min',$wake_ang_min,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   559
			   'min_wake_w',$min_wake_w,'n_wake_bins',$n_wake_bins,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   560
			   'e_max',$e_max,'min_cor',$min_cor,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   561
			   'max_shdev',$max_shdev,'max_shdev_sum',$max_shdev_sum,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   562
			   'water_depth',round($water_depth),'water_depth.sig',round($sig_water_depth),
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   563
			   'min_hab',round($min_hab),'PPI_editing_enabled',$PPI_editing_enabled,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   564
			   'clip_margin',$clip_margin,'first_clip_bin',$first_clip_bin,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   565
			   'Svbin_start',$Svbin_start,'Svbin_end',$Svbin_end,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   566
			   'BT_bin_start',$BT_bin_start,'BT_bin_search_above',$BT_bin_search_above,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   567
			   'BT_max_bin_spread',$BT_max_bin_spread,'BT_max_w_difference',$BT_max_w_difference,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   568
);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   569
if (defined($BT_min_depth)) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   570
	&antsAddParams('BT_min_depth',$BT_min_depth,'BT_max_depth',$BT_max_depth);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   571
} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   572
	&antsAddParams('BT_max_depth_error',$BT_max_depth_error);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   573
}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   574
$fullParams = $antsCurParams;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   575
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   576
$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
   577
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   578
print(STDERR "\n\tdowncast...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   579
edit_velocity($LADCP_start,$LADCP_bottom);							# downcast
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   580
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
   581
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
   582
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   583
@dc_sh_n = @sh_n;													# save downcast results
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   584
@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
   585
@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
   586
@dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   587
@dc_esh_mu = @esh_mu;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   588
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   589
print(STDERR "\n\tupcast...") if ($opt_d);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   590
edit_velocity($LADCP_end,$LADCP_bottom);							# upcast
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   591
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
   592
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
   593
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   594
@uc_sh_n = @sh_n;													# save upcast results
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   595
@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
   596
@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
   597
@uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   598
@uc_esh_mu = @esh_mu;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   599
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   600
print(STDERR "\n\tcombined...") if ($opt_d);
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   601
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
   602
for (my($gi)=0; $gi<$nsh; $gi++) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   603
	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
   604
		$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
   605
		$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
   606
		$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
   607
		$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
   608
		$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
   609
		$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
   610
		$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
   611
		$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
   612
	} 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
   613
		$sh_n[$gi] = $dc_sh_n[$gi];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   614
		$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
   615
		$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
   616
	} 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
   617
		$sh_n[$gi] = $uc_sh_n[$gi];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   618
		$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
   619
		$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
   620
	} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   621
		$sh_n[$gi] = 0;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   622
		$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
   623
		$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
   624
	}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   625
}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   626
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   627
print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   628
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   629
#----------------------------------------------------------------------
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   630
# Step 9: Get bottom track profile
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   631
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   632
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   633
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   634
	print(STDERR "Getting BT profile...");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   635
	getBTprof($LADCP_start,$LADCP_end);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   636
	print(STDERR "\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   637
}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   638
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   639
#----------------------------------------------------------------------
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   640
# Step 10: Write Output Profiles if requested
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   641
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   642
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   643
if (defined($opt_p)) {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   644
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   645
	print(STDERR "Writing shear profiles...");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   646
	
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   647
	@antsNewLayout = ('depth','dc_elapsed','dc_nsamp','dc_u_z','dc_u_z.sig','dc_v_z','dc_v_z.sig','dc_w_z','dc_w_z.sig',
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   648
							  'uc_elapsed','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
   649
							  '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
   650
							  
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   651
	&antsOut('EOF');
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   652
    close(STDOUT);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   653
	open(STDOUT,">$opt_p") || croak("$opt_p: $!\n");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   654
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   655
	$antsCurParams = $fullParams;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   656
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   657
	for (my($gi)=0; $gi<$nsh; $gi++) {
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   658
		&antsOut(depthOfGI($gi),										# depth in center of bin
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   659
				 $dc_esh_mu[$gi],										# downcast
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   660
				 numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0,
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   661
				 $dc_ush_mu[$gi],$dc_ush_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   662
				 $dc_vsh_mu[$gi],$dc_vsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   663
				 $dc_wsh_mu[$gi],$dc_wsh_sig[$gi],
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   664
				 $uc_esh_mu[$gi],										# upcast
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   665
				 numberp($uc_sh_n[$gi])?$uc_sh_n[$gi]:0,
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   666
				 $uc_ush_mu[$gi],$uc_ush_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   667
				 $uc_vsh_mu[$gi],$uc_vsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   668
				 $uc_wsh_mu[$gi],$uc_wsh_sig[$gi],
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   669
				 $esh_mu[$gi],$sh_n[$gi],								# combined
4
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   670
				 $ush_mu[$gi],$ush_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   671
				 $vsh_mu[$gi],$vsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   672
				 $wsh_mu[$gi],$wsh_sig[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   673
				 $nSv_prof[$gi]?$sSv_prof[$gi]/$nSv_prof[$gi]:nan,
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   674
				 $nSv_prof[$gi],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   675
		);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   676
	}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   677
	
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   678
	print(STDERR "\n");
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   679
} # if -p
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   680
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   681
#---------------------------------------
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   682
# Acoustic backscatter depth-time-series
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   683
#---------------------------------------
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   684
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   685
if (defined($opt_a)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   686
	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
   687
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   688
	
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   689
	@antsNewLayout = ('ens','elapsed','CTD_depth','depth','bin','downcast',
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   690
					  '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
   691
	&antsOut('EOF');
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   692
    close(STDOUT);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   693
	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
   694
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   695
	$antsCurParams = $commonParams;
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   696
	&antsAddParams('min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   697
				   'max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l,
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   698
				   'min_depth',$LADCP{ENSEMBLE}[$LADCP_top]->{XDUCER_FACING_UP} ?
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   699
	   					&depthOfBin($LADCP_top,$LADCP{N_BINS}-1) : $LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH},
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   700
				   'max_depth',$LADCP{ENSEMBLE}[$LADCP_bottom]->{XDUCER_FACING_UP} ?
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   701
	   					$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
   702
	);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   703
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   704
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   705
		for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   706
			&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   707
					 $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
   708
					 $LADCP{ENSEMBLE}[$ens]->{DEPTH},
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   709
					 &depthOfBin($ens,$bin),$bin+1,
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   710
					 ($ens <= $LADCP_bottom) ? 1 : 0,
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   711
					 @{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]},
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   712
					 median(@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]})
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   713
			);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   714
		}	 
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   715
	}
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   716
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   717
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   718
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   719
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   720
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   721
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   722
if (defined($opt_t)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   723
	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
   724
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   725
	@antsNewLayout = ('ens','elapsed','depth','CTD_w','LADCP_w');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   726
	&antsOut('EOF');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   727
	$antsCurParams = $commonParams;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   728
	close(STDOUT);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   729
	open(STDOUT,">$opt_t") || croak("$opt_t: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   730
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   731
	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
   732
		&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   733
				 $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
   734
				 $LADCP{ENSEMBLE}[$ens]->{DEPTH},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   735
				 $LADCP{ENSEMBLE}[$ens]->{CTD_W},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   736
				 $LADCP{ENSEMBLE}[$ens]->{W});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   737
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   738
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   739
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   740
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   741
#----------------------------------------------------------------------
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   742
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   743
if (defined($opt_b)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   744
	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
   745
	
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   746
	@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
   747
	&antsOut('EOF');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   748
	$antsCurParams = $commonParams;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   749
	close(STDOUT);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   750
	open(STDOUT,">$opt_b") || croak("$opt_b: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   751
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   752
	my($skipped);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   753
	for (my($gi)=0; $gi<@BT_nsamp; $gi++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   754
		$skipped = 1 if ($BT_nsamp[$gi] > 0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   755
		next unless ($skipped);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   756
		&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
   757
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   758
	print(STDERR "\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   759
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   760
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
if (defined($opt_f)) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   764
	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
   765
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   766
	@antsNewLayout = ('ens');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   767
	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
   768
		$antsNewLayout[$i] = "bin$i";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   769
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   770
	&antsOut('EOF');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   771
	$antsCurParams = $commonParams;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   772
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   773
	close(STDOUT);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   774
	open(STDOUT,">$opt_f") || croak("$opt_f: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   775
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   776
	&antsPrintHeaders(STDOUT,@antsNewLayout);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   777
	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
   778
		printf('%4d  ',$LADCP{ENSEMBLE}[$ens]->{NUMBER});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   779
		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
   780
			printf("%02x ",$edit_flags[$ens][$bin]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   781
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   782
		print($opt_R);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   783
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   784
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   785
	print(STDERR "\n");
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
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   788
&antsExit();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   789