LADCP_w_ocean
author A.M. Thurnherr <athurnherr@yahoo.com>
Tue, 29 Mar 2016 15:03:23 -0400
changeset 42 f7690c7b92e0
parent 41 6bddb82924e3
child 43 567b03b9ce8d
permissions -rwxr-xr-x
V1.2beta6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     1
#!/usr/bin/perl
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     2
#======================================================================
31
d0ae3cb99021 DoMORE-2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 30
diff changeset
     3
#                    L A D C P _ W _ O C E A N 
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     4
#                    doc: Fri Dec 17 18:11:13 2010
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
     5
#                    dlm: Tue Mar 29 07:28:54 2016
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     6
#                    (c) 2010 A.M. Thurnherr
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
     7
#                    uE-Info: 371 0 NIL 0 0 72 2 2 4 NIL ofnI
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     8
#======================================================================
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     9
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    10
# TODO:
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    11
#   ! plots:
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    12
#       - avoid over-plotting axis labels
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    13
#       - allow for different nsamp magnitudes
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    14
#       - add "dc" "uc" labels
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    15
#       - add software version
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    16
#       - add seabed to eps.VKE profile
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    17
#       - add seabed to LADCP_w_postproc .wprof output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    18
#   ! use instrument tilt in sidelobe editing
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    19
#   ! change w_tt output to w_t output; change -a to use w_t or remove -a? 
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    20
#   - worry about water-depth differences (disabled warning) 
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    21
#   - make upcast-flag valid for yoyo casts
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    22
#   - make diagnostic output 3-beam field work for Earth coordinates
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    23
#   ? remove water-depth from BT code, which is not really used and a bit of an outlier
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    24
#     because mean and stddev are used instead of median/mad
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    25
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    26
$antsSummary = 'calculate vertical velocities from LADCP & CTD time series';
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    27
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    28
# HISTORY:
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    29
#   Dec 17, 2010: - created from [mergeCTD+LADCP]
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    30
#   Dec 18, 2010: - made to work
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    31
#   Dec 19, 2010: - improved considerably
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    32
#   Dec 20, 2010: - onward
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    33
#                 - BUG: depth-binning was off by 1 bin?!
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    34
#                 - added binning correction for instrument tilt
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    35
#   Dec 21, 2010: - added -h (seafloor depth)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    36
#   Dec 22, 2010: - BUG: had not applied soundspeed-correction to w
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    37
#                 - debugged opt_d
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    38
#   Dec 23, 2010: - continued implementation of soundspeed corrections
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    39
#   Dec 24, 2010: - added winch_w, wave_w
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    40
#                 - removed beampair velocities from code
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    41
#   Dec 25, 2010: - adapted for surface-wave correction in terms of acceleration (CTD_w_t)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    42
#                 - removed elapsed_mismatch
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    43
#                 - removed winch_w, wave_w
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    44
#   Dec 26, 2010: - made -p output layout independent of -x to avoid Makefile problems
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    45
#   Dec 30, 2010: - cleaned up some
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    46
#                 - folded-in backscatter calculation from shear method
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    47
#                 - folded-in BT calculation from shear method
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    48
#   Dec 31, 2010: - added weighted mean w profile to output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    49
#   Jan  2, 2010: - BUG: BT_w.mad could bomb with division by 0
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    50
#                 - BUG: division by zero if no valid data
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    51
#   Jan  5, 2010: - adapted to allow for gaps in CTD time series
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    52
#   Feb 16, 2011: - cosmetics
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    53
#   Jun 22, 2011: - cosmetics
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    54
#   Jun 23, 2011: - disabled error on large rms reflr w
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    55
#                 - added -l
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    56
#                 - removed CTD headers from output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    57
#   Jun 26, 2011: - added -u
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    58
#                 - changed package correction from acceleration to velocity, because of
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    59
#                   Stan's Antarctic data set where accelerations are zero but package effects are
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    60
#                   there
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    61
#   Jul  2, 2011: - increased tilt default to 15 degrees
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    62
#   Jul  3, 2011: - replaced old package-velocity correction -x code by new beamvel correction
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    63
#                 - removed -p
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    64
#                 - replaced -d by residual (diagnostics) output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    65
#   Jul  4, 2011: - saved a snapshot in [Jul_04_2011]
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    66
#                 - removed output of binned profile (but not calculation code, which is required for residual)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    67
#                 - BUG: firstGoodEns or lastGoodEns could end up in a reflr_w gap when valid LADCP data begin
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    68
#                        or end with CTD in water
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    69
#                 - moved rarely used option -s to -k
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    70
#                 - added -s)kip <ens> option
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    71
#                 - had to very very slightly relax an assertion (by 1e-10 seconds...)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    72
#   Aug  3, 2011: - added -z)ap to truncate range, based on Stan's 2009 data set (017-019 most clearly)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    73
#                   obs that final 2 velocities are outliers; could be due to color bar, should check with
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    74
#                   residuals
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    75
#   Sep 22, 2011: - removed (commented out) CTD acceleration
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    76
#                 - added basename to Parameter File Matching
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    77
#   Sep 23, 2011: - cosmetics (lots)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    78
#                 - added -d)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    79
#   Oct  6, 2011: - removed old commented-out code (CTD acceleration & old -x)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    80
#                 - renamed time-series field names
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    81
#                 - added uncorrected reflr w to time-series output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    82
#   Oct 10, 2011: - BUG: LADCP_w in .tds output had not been soundspeed corrected
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    83
#                 - removed -x
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    84
#                 - added "false-positives" editing filter
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    85
#   Oct 11, 2011: - adapted to the new parameter file, removing a few options
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    86
#   Oct 12, 2011: - added surface-layer editing
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    87
#                 - made %min/max_depth/elapsed more accurate
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    88
#   Oct 13, 2011: - fiddled
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    89
#   Oct 14, 2011: - renamed .prof fields from .N to .nsamp
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    90
#                 - added %output_basename
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    91
#                 - removed all ">" from open to allow use in pipelines
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    92
#                 - made <run-label> argument optional
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    93
#                 - replaced stdout output by $w_out
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    94
#                 - renamed _out to out_; output_basename to out_basename
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    95
#   Oct 15, 2011: - added editWOutliers()
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    96
#                 - added step to remove single-ping noise
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    97
#   Oct 16, 2011: - BUG: ensemble and bin numbers in output files were off by 1
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    98
#   Oct 17, 2011: - added default run label
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    99
#                 - added out_BR
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   100
#                 - BUG: closed STDOUT caused problems with tee in plotting scripts
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   101
#                 - added %run_label
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   102
#                 - added PostProcess.sh
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   103
#   Oct 18, 2011: - BUG: %{min,max}_ens used ensemble indices, rather than numbers
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   104
#                 - disabled false-positives editing (removes too much good data on 2011_IWISE)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   105
#   Oct 19, 2011: - BUG: time-series output included ensembles without valid w
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   106
#                 - increased post-process sleep time to 30s
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   107
#                 - added corr, Sv and echo_amplitude as new fields to w output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   108
#   Oct 20, 2011: - added editFarBins()
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   109
#                 - added downcast flag to time-series output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   110
#                 - added ensemble number to LADCP-time-series output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   111
#   Oct 21, 2011: - BUG: Sv code was not enabled for uplooker data
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   112
#   Oct 24, 2011: - added code to copy %lat/%lon from CTD data
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   113
#                 - added %ADCP_freuquency, %ADCP_blanking_distance
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   114
#                 - %LADCP_bin_length => %ADCP_bin_length
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   115
#   Oct 26, 2011: - added $first_guess_timelag
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   116
#   Oct 27, 2011: - added w12, w34, ww (pitch/roll-weighted average) to full output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   117
#                 - removed ww because it apparently does not improve the solutions
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   118
#                 - moved editTilt() to after time-series calculation to allow
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   119
#                   time matching to work even with strict tilt limit
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   120
#                 - added correctAttitude()
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   121
#   May 22, 2012: - adapted to ANTS V5
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   122
#   Oct 15, 2012: - added $edit_data_hook
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   123
#                 - HG COMMIT
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   124
#                 - separated dc/uc time lagging
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   125
#                 - removed support for TLhist
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   126
#   Oct 16, 2012: - added support for dc/uc only solutions
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   127
#   Oct 17, 2012: - renamed $edit_data_hook to $post_merge_hook
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   128
#                 - HG COMMIT
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   129
#   Feb 13, 2013: - BUG: CTD_neg_press_offset did not work for CTD time series with -ve starting depth
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   130
#   Mar 23, 2013: - cosmetics
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   131
#                 - HG COMMIT
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   132
#   Apr 22, 2013: - removed opt_? variable aliases
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   133
#   May  8, 2013: - replaced default run label (default to profiles) to make more readable directory structure
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   134
#   May 14, 2013: - opt_m => w_max_lim
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   135
#                 - BUG: time-series output had two messed-up fields
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   136
#   May 15, 2013: - added w12 and w34 (2-beam solutions) to profile output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   137
#   May 16, 2013: - added CTD_w_tt to time-series & all-sample outputs
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   138
#                 - -a => -d (CTD depth offset)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   139
#                 - implemented pressure-sensor acceleration correction (-a)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   140
#                 - added re-gridding of full profile after ping-coherent error removal
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   141
#   Jun  5, 2013: - renamed $discard_velocities_from_beam to $bad_beam
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   142
#                 - BUG: $bad_beam did not discard BT_VELOCITY data
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   143
#   Jun  6, 2013: - BUG: error message had -a instead of -d
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   144
#   Sep  5, 2013: - BUG: w12/w34 do not work for earth-coordinate data, of course
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   145
#   Apr 17, 2014: - BUG: edit_tilt was never called when all recorded bins are valid
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   146
#   Apr 21, 2014: - updated comments
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   147
#   May 19, 2014: - began adding support for PPI filtering
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   148
#   May 20, 2014: - changed volume_scattering_coeff to Sv in output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   149
#                 - added editPPI()
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   150
#   Jul  6, 2014: - BUG: nan water depth had been interpreted as known
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   151
#                 - BUG: sVelProf[] was not allowed to have any gaps
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   152
#   Jul  9, 2014: - BUG: Jul 6 bug fixes had been applied to older
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   153
#                        version
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   154
#                 - BUG: code meant to ensure gap-free svel profiles did not work correctly
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   155
#   Jul 12, 2014: - finally made output files executable
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   156
#   Apr  5, 2015: - added check for required software
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   157
#                 - BUG: removed dc/uc mean w fields from .prof again
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   158
#   Apr  7, 2015: - made LADCP_w callable from installation directory
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   159
#                 - BUG: -v default was wrong in usage message
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   160
#                 - replaced 'ens' in output files by 'ensemble'
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   161
#   Apr 16, 2015: - turned output specifies into lists (re-design of
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   162
#                   plotting sub-system)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   163
#                 - removed 30s sleep from PostProcess.sh call
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   164
#                 - disabled active output when ANTS are not available
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   165
#                 - removed /bin/ksh requirement
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   166
#                 - BUG: error messages were not reported in the log file
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   167
#                 - made seabed detection code more flexible
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   168
#                 - made reference-layer w_ocean warning more severe
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   169
#                 - BUG: info() did not write anything into logfile when format string was used
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   170
#                 - BUG: LADCP_lastBin was set 1 too low
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   171
#   Apr 20, 2015: - improved comments
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   172
#                 - improved diagnostic messages (warning on missing CTD temp)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   173
#                 - added support for empirical backscatter correction
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   174
#   Apr 21, 2015: - improved screen log output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   175
#   Apr 22, 2015: - BUG: $realLastGoodEns could be undefined, breaking plotting routines
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   176
#   Apr 24, 2015: - removed @ARGS
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   177
#                 - added %profile_id
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   178
#   May 13, 2015: - loosened "insufficient valid velocities" test for short casts
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   179
#   May 15, 2015: - added $min_valid_vels
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   180
#                 - BUG: LADCP_atbottom could be less than firstGoodEns
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   181
#   May 18, 2015: - added %LADCP_pulse_length, %dnXX
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   182
#   May 20, 2015: - added $PROF as newer alternative to $STN
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   183
#                 - replaced "require ProcessingParams" by "do ProcessingParams"
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   184
#   Jun 15, 2015: - clarified warning message
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   185
#   Jul 26, 2015: - added %output_grid_dz %output_grid_minsamp for use by [LADCP_w_regrid]
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   186
#                 - began work on support for [libGMT.pl]
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   187
#                 - -v usage message had wrong default
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   188
#                 - added $outGrid_firstBin & $outGrid_lastBin
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   189
#   Jul 28, 2015: - added GMT plot support for all @out_ lists
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   190
#   Jul 29, 2015: - continue adaptation of code for new plotting system
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   191
#   Jul 30, 2015: - cosmetics
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   192
#   Sep  3, 2015: - changed out_w to out_wsamp
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   193
#   Sep 26, 2015: - replaced numberp($water_depth) by defined($water_depth) for consistency
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   194
#                 - implemented secondary sidelobe editing
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   195
#                 - allow for -h <filename>
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   196
#                 - allow $ID as alias for $PROF and $STN
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   197
#   Sep 27, 2015: - BUG: -h filename was broken when water_depth is not known
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   198
#   Oct 12, 2015: - upgraded missing water-depth warnings to L2
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   199
#                 - added -V)ersion
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   200
#                 - require ANTSlibs V6.2 for release
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   201
#   Oct 13, 2015: - adapted to [version.pl]
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   202
#   Nov 25, 2015: - made warning disappear on setting $ANTS_TOOLS_AVAILABLE
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   203
#   Nov 27, 2015: - changed RDI_BB_READ.pl to RDI_PD0_IO.pl
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   204
#   Jan  4, 2016: - decreased default vertical resolution to 20m
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   205
#   Jan  5, 2016: - adapted to [ADCP_tools_lib.pl]
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   206
#   Jan 22, 2016: - updated for improved mean_residuals plot
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   207
#                 - added per-bin residual quality check
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   208
#   Jan 25, 2016: - added antsAddParams() with version number
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   209
#   Jan 26, 2016: - added %processing_params, many others
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   210
#                 - expunged -d
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   211
#                 - implemented outGrid_firstBin eq '*' (also lastBin)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   212
#   Jan 27, 2016: - BUG: outGrid_lastBin eq '*' did not work
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   213
#                 - removed large ref-lr w warning
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   214
#   Feb 14, 2016: - fiddled with ping-coherent residuals code, fixing
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   215
#                   0-2 potential (minor?) bugs related to outGrid_{first,last}Bin;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   216
#                   output of new code checked against old code => identical
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   217
#   Feb 16, 2016: - BUG: per-bin-residual QC could cause division by zero
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   218
#   Feb 19, 2016: - added -l (disable time-lag filtering)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   219
#   Mar  7, 2016: - added error message when -h is neither number nor file
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   220
#                 - BUG: -ve depth error message referred to obsolete -d
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   221
#                 - BUG: dn field name did not use zero filling for year number
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   222
#   Mar  8, 2016: - removed L0 water-depth-difference warning
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   223
#                 - added test for 1500m/s sound speed
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   224
#   Mar  9, 2016: - added hab field to .wprof output
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   225
#   Mar 13, 2016: - cleaned up warnings created before LADCP_file is defined
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   226
#                 - added sanity checks and warnings
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   227
#   Mar 17, 2016: - added {dc,uc}_rms_{tilt,w_pkg}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   228
#                 - replaced a couple of **2 by &SQR()
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   229
#                 - replaced %ADCP_orientation values by DL & UL
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   230
#                 - {dc,uc}_rms_w_pkg => {dc,uc}_rms_accel_pkg for V1.2beta6
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   231
#   Mar 18, 2016: - added -l to %processing_options
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   232
#   Mar 24, 2016: - generalized plotting system (renamed variables)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   233
#                 - made plotting system search current dir before LADCP_w dir
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   234
#                 - BUG: ProcessingParams syntax errors were not flagged
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   235
#                 - BUG: progress message in rarely used filter
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   236
#   Mar 25, 2016: - added -r)esidual rms filter
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   237
#                 - added -q -r to processing_options
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   238
#   Mar 26, 2016: - BUG: water_depth < CTD_maxdepth was allowed
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   239
#                 - round(CTD_depth)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   240
#   Mar 29, 2016: - split [default_paths.pl] from [defaults.pl] to allow defaults
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   241
#                   to be read before usage
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   242
#				  - renamed _subdir to _dir variables
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   243
#				  - renamed post-process hook script to LADCP_w.PostProcess
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   244
#				  - added -r default (0.04m/s)
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
   245
# HISTORY END
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   246
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   247
# CTD REQUIREMENTS
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   248
#	- elapsed		elapsed seconds; see note below
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   249
#	- depth
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   250
#	- ss			sound speed
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   251
#	- w				ddepth/dt
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   252
#	- temp			OPTIONAL; used for backscatter calculation
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   253
#	- %lat/%lon		OPTIONAL
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   254
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   255
# 2-BEAM SOLUTIONS
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   256
#	- for beam-coordinate data, two separate two-beam solutions (w12 & w34) are calculated
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   257
#	- discrepancies can be indicative of package wake effects (e.g. MIXET data)
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   258
#	- for earth-coordinate data, w12 and w34 are simply copies of w
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   259
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   260
# NUMERICAL OPTIONS
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   261
#	- the first option in the list cannot be numerical!
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   262
#	- if need be, use -v 1 as a dummy option
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   263
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   264
# ELAPSED TIMES
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   265
#	- there are 2 different elapsed times used in this program:
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   266
#		1) elapsed based on firstgoodens in the LADCP time series
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   267
#		2) CTD elapsed time
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   268
#	- CTD elapsed time does not have to start with zero!
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   269
#	- do not use the Seabird elapsed field, which is only reported to
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   270
#	  3 significant digits, causing significant jitter in dt; however,
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   271
#	  at least up to 2010 Seabird simply calculates elapsed time by 
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   272
#	  assuming a 24Hz sampling rate and no record drop; therefore,
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   273
#	  it is best to calculate elapsed time as %RECNO/24
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   274
#	- the elapsed field of the output is the elapsed time from the CTD
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   275
#	  file; this is required in order to be able to compare the times
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   276
#	  from the uplooker and downlooker-derived vertical velocity
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   277
#	  profiles
11
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
   278
#	- the .TL files use the LADCP elapsed time in output; as a result,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
   279
#	  the DL/UL .TL files have different time axes!
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   280
#	- as a result, a profile only starts with elapsed==0 if the CTD
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   281
#	  is turned on when the LADCP is already in the water
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   282
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   283
# BINNED-PROFILE OUTPUT NOTES
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   284
#	- residuals are calculated with respect to down-/upcast medians
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   285
#	- w12 and w34 2-beam solutions are reported without considering
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   286
#	  -k (min samples)
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   287
#	- equivalence, assuming -o 10:
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   288
#		1) 004DL.prof dc_w depth
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   289
#		2) bindata -Sdowncast:1 -Fw.median,depth -n 20 depth 10 004DL.w
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   290
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   291
# VELOCITY AMBIGUITY ERRORS
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   292
#	- quite extensive tests with DIMES US2 station 146, which has a lot of
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   293
#	  ambiguity velocity errors, reveal that -m 1 catches those errors
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   294
#	  quite nicely
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   295
#	- even when the errors are not filtered with -m 1, they do not
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   296
#	  affect the w profiles, as long as the median bin values are used
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   297
23
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   298
($ANTS) 	  = (`which ANTSlib`   =~ m{^(.*)/[^/]*$});
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   299
($ADCP_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$});
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   300
($WCALC) 	  = ($0                =~ m{^(.*)/[^/]*$});
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   301
$WCALC = '.' if ($WCALC eq '');
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   302
$ANTS_TOOLS_AVAILABLE = (`which list 2>/dev/null` ne '');
23
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   303
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   304
die("$0: Generic Mapping Tools (GMT) required but not found (bad \$PATH?)\n")
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   305
	unless (`which psxy` ne '');
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   306
die("$0: ANTSlib required but not found (bad \$PATH?)\n")
23
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   307
	unless ($ANTS ne '');
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   308
die("$0: ADCP Tools required but not found (bad \$PATH?)\n")
23
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   309
	unless ($ADCP_TOOLS ne '');
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   310
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   311
require "$WCALC/version.pl";
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   312
require "$WCALC/edit_data.pl";
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   313
require "$WCALC/time_series.pl";
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   314
require "$WCALC/time_lag.pl";
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   315
require "$WCALC/find_seabed.pl";
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   316
require "$WCALC/svel_corrections.pl";
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   317
require "$WCALC/acoustic_backscatter.pl";
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   318
require "$WCALC/bottom_tracking.pl";
33
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   319
require "$ANTS/ants.pl";
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   320
require "$ANTS/libstats.pl";
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   321
require "$ADCP_TOOLS/ADCP_tools_lib.pl";
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   322
&antsAddParams('LADCP_w_ocean',"Version $VERSION");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   323
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   324
use IO::Handle;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   325
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   326
my($TINY) = 1e-16;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   327
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   328
#------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   329
# Usage
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   330
#------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   331
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   332
require "$WCALC/defaults.pl";												# load default/option parameters
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   333
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   334
$antsParseHeader = 0;
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   335
&antsUsage('3:4a:b:c:e:g:h:i:k:lm:n:o:p:qr:s:t:uv:Vw:x:',0,
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   336
	"[print software -V)ersion] [-v)erbosity <level[$opt_v]>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   337
	"[-q)uick (no single-ping denoising)]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   338
    "[require -4)-beam solutions] [apply beamvel-m)ask <file> if it exists]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   339
	"[valid LADCP -b)ins <bin,bin[$opt_b]>",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   340
	"[-c)orrelation <min[$opt_c counts]>] [-t)ilt <max[$opt_t deg]> [-e)rr-vel <max[$opt_e m/s]>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   341
	"[-r)esidual <rms.max[$opt_r m/s]>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   342
	"[-h water <depth|filename>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   343
	"[max LADCP time-series -g)ap <length[$opt_g s]>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   344
	"[-i)nitial CTD time offset <guestimate> [-u)se as final]]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   345
	"[calculate -n) <lags,lags[$opt_n]>] [lag -w)indow <sz,sz[$opt_w s]>] [lag-p)iece <CTD_elapsed_min|+[,...]>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   346
	"[require top-3) lags to account for <frac[$opt_3]> of all]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   347
	"[disable time-l)ag filtering]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   348
	"[pressure-sensor -a)cceleration correction <residual/CTD_w_tt>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   349
	"[-o)utput bin <resolution[$opt_o m]>] [-k) require <min[$opt_k]> samples]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   350
	"[e-x)ecute <perl-expr>]",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   351
	"<profile-id> [run-label]");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   352
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   353
if ($opt_V) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   354
	printf(STDERR "+-------------------------+\n");
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   355
	printf(STDERR "| LADCP_w Software V%s	|\n",$VERSION);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   356
	printf(STDERR "|(c) 2015- A.M. Thurnherr |\n");
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   357
	printf(STDERR "+-------------------------+\n");
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   358
	exit(0);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   359
}
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   360
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   361
&antsUsageError() if ($opt_u && !defined($opt_i));
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   362
&antsUsageError() unless (@ARGV==1 || @ARGV==2);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   363
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   364
&antsCardOpt(\$opt_s,0);												# skip # initial ensembles
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   365
$opt_p = '+' unless defined($opt_p);									# separate uc/dc time lagging
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   366
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   367
&antsFloatOpt(\$opt_a,1);												# pressure acceleration correction
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   368
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   369
$ID = $PROF = $STN = &antsCardArg();									# station id ($STN for compatibility)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   370
if (@ARGV) {															# run label
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   371
	$RUN = $ARGV[0];
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   372
	shift;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   373
} else {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   374
	$RUN = 'profiles';
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   375
}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   376
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   377
#-----------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   378
# Handle Processing Parameters
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   379
#-----------------------------
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   380
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   381
require "$WCALC/default_paths.pl";										# load default input/output paths
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   382
croak("$processing_param_file: $@")
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   383
	unless ($err = do "$processing_param_file");						# load processing parameters
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   384
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   385
$processing_options = "-k $opt_k -o $opt_o -c $opt_c -t $opt_t -e $opt_e -g $opt_g -3 $opt_3";
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   386
$processing_options .= " -i $opt_i" if defined($opt_i);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   387
$processing_options .= " -r $opt_r" if defined($opt_r);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   388
$processing_options .= ' -l' if defined($opt_l);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   389
$processing_options .= ' -q' if defined($opt_q);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   390
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   391
if (defined($opt_x)) {													# eval cmd-line expression to override anything
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   392
	$processing_options .= " -x $opt_x";
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   393
	eval($opt_x);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   394
}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   395
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   396
if ($opt_4) {															# disallow 3-beam solutions
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   397
	$processing_options .= " -4";
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   398
	$RDI_Coords::minValidVels = 4;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   399
}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   400
	
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   401
($LADCP_firstBin,$LADCP_lastBin) = split(',',$opt_b);					# select valid bins
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   402
	croak("$0: cannot decode -b $opt_b\n")
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   403
    	unless (numberp($LADCP_firstBin) &&
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   404
        	    ($LADCP_lastBin eq '*' || numberp($LADCP_lastBin)));
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   405
$processing_options .= " -b $opt_b";
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   406
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   407
$outGrid_firstBin = $LADCP_firstBin if ($outGrid_firstBin eq '*');		# default bins to use in gridded output
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   408
$outGrid_lastBin  = $LADCP_lastBin  if ($outGrid_lastBin  eq '*');		# NB: can still be '*'!!!
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   409
        	    
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   410
@number_of_timelag_windows = split(',',$opt_n);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   411
	croak("$0: cannot decode -n $opt_n\n")
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   412
		unless numberp($number_of_timelag_windows[0]) && numberp($number_of_timelag_windows[1]);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   413
$processing_options .= " -n $opt_n";
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   414
@length_of_timelag_windows = split(',',$opt_w);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   415
	croak("$0: cannot decode -w $opt_w\n")
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   416
		unless numberp($length_of_timelag_windows[0]) && numberp($length_of_timelag_windows[1]);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   417
$processing_options .= " -w $opt_w";
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   418
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   419
croak("$0: \$out_basename undefined\n")									# plotting routines use this to label the plots
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   420
	unless defined($out_basename);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   421
&antsAddParams('processing_options',$processing_options);
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   422
&antsAddParams('out_basename',$out_basename);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   423
&antsAddParams('profile_id',$PROF,'run_label',$RUN);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   424
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   425
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   426
# Screen Logging
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   427
#	- warning levels:
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   428
#		0 probably unimportant, e.g. nonsensical parameters that probably won't affect solution
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   429
#		1 may be somewhat important
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   430
#		2 important
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   431
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   432
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   433
open(LOGF,">$out_log") || croak("$out_log: $!\n")
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   434
	if defined($out_log);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   435
LOGF->autoflush(1);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   436
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   437
sub progress(@)
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   438
{
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   439
	printf(LOGF @_) if defined($out_log);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   440
	printf(STDERR @_) if ($opt_v > 1);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   441
}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   442
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   443
sub info(@)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   444
{
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   445
	print(LOGF "\t"),printf(LOGF @_) if defined($out_log);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   446
	printf(STDERR @_)  if ($opt_v > 1);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   447
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   448
	
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   449
sub warning(@)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   450
{
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   451
	my($lvl,@msg) = @_;
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   452
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   453
	if (defined($out_log)) {
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   454
		print(LOGF "\nWARNING (L$lvl): ");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   455
		printf(LOGF @msg);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   456
		print(LOGF "\n");
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   457
	}
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   458
	return if ($opt_v == 0);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   459
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   460
	if ($opt_v == 1) {
39
91458506d56f V1.2beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 37
diff changeset
   461
		print(STDERR "$LADCP_file: ") if defined($LADCP_file);
91458506d56f V1.2beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 37
diff changeset
   462
		print(STDERR "WARNING (L$lvl): ");
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   463
		printf(STDERR @msg);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   464
	} else {
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   465
		print(STDERR "\n-------------\nWARNING (L$lvl): ");
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   466
		printf(STDERR @msg);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   467
		print(STDERR "-------------\n\n")
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   468
	}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   469
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   470
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   471
sub error($)
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   472
{
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   473
	print(LOGF "ABORT: @_") if defined($out_log);
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   474
	croak("ABORT: @_");
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   475
}
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   476
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   477
sub debugmsg(@)
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   478
{ printf(STDERR @_) if ($opt_v > 2); }
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   479
40
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   480
#---------------------------
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   481
# Read LADCP data
40
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   482
#
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   483
# sanity checks:
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   484
#	- 1500m/s sound speed
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   485
#	- single-ping ensembles
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   486
#
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   487
# warnings:
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   488
#	- high bandwidth
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   489
#	- low transmit power
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   490
#---------------------------
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   491
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   492
progress("Reading LADCP data from <$LADCP_file>...\n");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   493
readData($LADCP_file,\%LADCP);
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   494
progress("\t%d ensembles\n",scalar(@{$LADCP{ENSEMBLE}}));
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   495
40
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   496
error("$LADCP_file: cannot process multi-ping ensembles\n")
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   497
	unless ($LADCP{PINGS_PER_ENSEMBLE} == 1);
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   498
error(sprintf("$LADCP_file: unsupported soundspeed setting (%d m/s != 1500 m/s)\n",$LADCP{ENSEMBLE}[0]->{SPEED_OF_SOUND}))
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   499
	unless ($LADCP{ENSEMBLE}[0]->{SPEED_OF_SOUND} == 1500);
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   500
warning(2,"$LADCP_file: wide-bandwidth setting\n")
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   501
	if ($LADCP{WIDE_BANDWIDTH});
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   502
warning(2,"$LADCP_file: low transmit-power setting\n")
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   503
	unless ($LADCP{TRANSMIT_POWER_HIGH});
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
   504
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   505
error("$LADCP_file: not enough LADCP bins ($LADCP{N_BINS}) for choice of -r\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   506
	unless ($LADCP{N_BINS} >= $refLr_lastBin);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   507
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   508
error("$0: first reference-layer bin outside valid range\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   509
	unless ($refLr_firstBin>=1 && $refLr_firstBin<=$LADCP{N_BINS});
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   510
error("$0: last reference-layer bin outside valid range\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   511
	unless ($refLr_lastBin>=1 && $refLr_lastBin<=$LADCP{N_BINS});
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   512
error("$0: first reference-layer bin > last reference-layer bin\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   513
	unless ($refLr_firstBin <= $refLr_lastBin);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   514
&antsAddParams('refLr_firstBin',$refLr_firstBin,'refLr_lastBin',$refLr_lastBin);	
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   515
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   516
$LADCP_lastBin 	 = $LADCP{N_BINS} if ($LADCP_lastBin eq '*');
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   517
$outGrid_lastBin = $LADCP{N_BINS} if ($outGrid_lastBin eq '*');
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   518
error("$0: first valid LADCP bin outside valid range\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   519
	unless ($LADCP_firstBin>=1 && $LADCP_firstBin<=$LADCP{N_BINS});
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   520
error("$0: last valid LADCP bin outside valid range\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   521
	unless ($LADCP_lastBin>=1 && $LADCP_lastBin<=$LADCP{N_BINS});
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   522
error("$0: first valid LADCP bin > last valid LADCP bin\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   523
	unless ($LADCP_firstBin <= $LADCP_lastBin);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   524
&antsAddParams('LADCP_firstBin',$LADCP_firstBin,'LADCP_lastBin',$LADCP_lastBin);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   525
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   526
warning(0,"first reference-layer bin < first valid LADCP bin\n")
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   527
	unless ($refLr_firstBin >= $LADCP_firstBin);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   528
warning(0,"last reference-layer bin > last valid LADCP bin\n")
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   529
	unless ($refLr_lastBin <= $LADCP_lastBin);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   530
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   531
warning(1,"if at all, bin 1 should not be used for short blank-after-transmit values\n")
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   532
	if ($LADCP{BLANKING_DISTANCE}<$LADCP{BIN_LENGTH} && $refLr_firstBin==1);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   533
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   534
&antsAddParams('ADCP_bin_length',$LADCP{BIN_LENGTH},
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   535
			   'ADCP_pulse_length',$LADCP{TRANSMITTED_PULSE_LENGTH},
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   536
			   'ADCP_frequency',$LADCP{BEAM_FREQUENCY},
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   537
			   'ADCP_blanking_distance',$LADCP{BLANKING_DISTANCE});
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   538
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   539
#------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   540
# Edit beam-velocity data
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   541
#	0) beam-vel mask on -m
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   542
#	1) correlation threshold
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   543
#------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   544
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   545
if ($LADCP{BEAM_COORDINATES}) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   546
	progress("Editing beam-velocity data...\n");
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   547
	
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   548
	if (defined($opt_m) && -r $opt_m) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   549
		progress("\tmasking beam velocities according to $opt_m:");
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   550
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   551
		my($nee) = 0;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   552
		open(BVM,$opt_m) || die("$opt_m: $!\n");
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   553
		while (<BVM>) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   554
			s/#.*//;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   555
			s/^\s*$//;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   556
			next if ($_ eq '');
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   557
			my($fe,$te,$db) = split;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   558
			die("$opt_m: cannot decode $_\n")
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   559
				unless (numberp($fe) && numberp($te) && $te>=$fe && $db>=1 && $db<=4);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   560
			die("$0: assertion failed")
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   561
				unless ($LADCP{ENSEMBLE}[$fe-1]->{NUMBER} == $fe &&
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   562
						$LADCP{ENSEMBLE}[$te-1]->{NUMBER} == $te);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   563
			for (my($ens)=$fe-1; $ens<=$te-1; $ens++) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   564
				$nee++;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   565
				for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   566
					undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$db-1]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   567
				}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   568
			}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   569
		}
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   570
		progress(" $nee ensembles edited\n");
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   571
		close(BVM);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   572
	}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   573
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   574
	$nvv = $cte = 0;
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   575
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   576
	if ($pitch_bias || $roll_bias || $heading_bias) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   577
		&antsAddParams('pitch_bias',$pitch_bias,
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   578
					   'roll_bias',$roll_bias,
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   579
					   'heading_bias',$heading_bias);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   580
		for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   581
			correctAttitude($ens,$pitch_bias,$roll_bias,$heading_bias);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   582
		}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   583
	}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   584
	for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   585
		$nvv += countValidBeamVels($ens);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   586
		$cte += editCorr($ens,$opt_c);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   587
	}
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   588
	error("$LADCP_file: no valid data\n") unless ($nvv > 0);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   589
	progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv));
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   590
#	progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv));
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   591
} else {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   592
	progress("Editing velocity data...\n");
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   593
	error("$LADCP_file: cannot apply beamvel-mask $opt_m to earth-coordinate data\n")
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   594
		if defined($opt_m);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   595
	$nvv = $cte = 0;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   596
	for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   597
		$nvv += countValidBeamVels($ens);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   598
		$cte += editCorr_Earthcoords($ens,$opt_c);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   599
	}
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   600
	error("$LADCP_file: no valid data\n") unless ($nvv > 0);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   601
	progress("\tcorrelation threshold (-c %d counts): %d velocites removed (%d%% of total)\n",$opt_c,$cte,round(100*$cte/$nvv));
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   602
#	progress("\tattitude threshold (-t %d deg): %d velocites removed (%d%% of total)\n",$opt_t,$pte,round(100*$pte/$nvv));
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   603
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   604
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   605
#-------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   606
# Calculate earth velocities
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   607
#	- this is done for all bins (not just valid ones), to allow
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   608
#	  useless possibility that invalid bins are used for reflr calcs
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   609
#	- also calculate separate beam-pair velocities
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   610
#	- the UNEDITED velocities are saved for the BT calculations
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   611
#	  (W is required, U & V are only used for stats that have not
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   612
#	  been very useful so far)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   613
#-------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   614
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   615
if ($LADCP{BEAM_COORDINATES}) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   616
	my($dummy);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   617
	progress("Calculating earth-coordinate velocities...\n");
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   618
	if ($bad_beam) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   619
		progress("\tdiscarding velocities from beam $bad_beam\n");
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   620
		&antsAddParams('bad_beam_discarded',$bad_beam);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   621
	}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   622
	$nvw = 0;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   623
	for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   624
		for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   625
			if ($bad_beam) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   626
				undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$bad_beam-1]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   627
				undef($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$bin][$bad_beam-1]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   628
			}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   629
			($LADCP{ENSEMBLE}[$ens]->{U}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   630
			 $LADCP{ENSEMBLE}[$ens]->{V}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   631
			 $LADCP{ENSEMBLE}[$ens]->{W}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   632
			 $LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) =
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   633
				velInstrumentToEarth(\%LADCP,$ens,
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   634
					velBeamToInstrument(\%LADCP,
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   635
										@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}));
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   636
			if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) {
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   637
				$per_bin_nsamp[$bin]++;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   638
				$nvw++;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   639
			}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   640
			$LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH} =
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   641
			 	gimbal_pitch($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   642
			$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin];
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   643
			$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin];
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   644
			$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin];
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   645
			
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   646
			($dummy,$LADCP{ENSEMBLE}[$ens]->{W12}[$bin],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   647
			 $dummy,$LADCP{ENSEMBLE}[$ens]->{W34}[$bin]) =
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   648
			 	velBeamToBPEarth(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   649
		}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   650
	}
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   651
	progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   652
	progress("\t3-beam solutions : $RDI_Coords::threeBeam_1 " .
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   653
								  "$RDI_Coords::threeBeam_2 " .
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   654
								  "$RDI_Coords::threeBeam_3 " .
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   655
								  "$RDI_Coords::threeBeam_4\n")
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   656
	    unless ($opt_4);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   657
} else { # Earth Coordinates
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   658
	progress("Counting valid vertical velocities...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   659
	$nvw = 0;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   660
	for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   661
		for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   662
			($LADCP{ENSEMBLE}[$ens]->{U}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   663
			 $LADCP{ENSEMBLE}[$ens]->{V}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   664
			 $LADCP{ENSEMBLE}[$ens]->{W}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   665
			 $LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin]) = @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]};
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   666
			if (defined($LADCP{ENSEMBLE}[$ens]->{W}[$bin])) {
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   667
				$per_bin_nsamp[$bin]++;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   668
				$nvw++;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   669
			}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   670
			$LADCP{ENSEMBLE}[$ens]->{U_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{U}[$bin];
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   671
			$LADCP{ENSEMBLE}[$ens]->{V_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{V}[$bin];
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   672
			$LADCP{ENSEMBLE}[$ens]->{W_UNEDITED}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin];
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   673
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   674
			$LADCP{ENSEMBLE}[$ens]->{W12}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W34}[$bin] = $LADCP{ENSEMBLE}[$ens]->{W}[$bin];
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   675
		}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   676
	}
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   677
	progress("\t$nvw valid velocities in bins $LADCP_firstBin-$LADCP_lastBin\n");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   678
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   679
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   680
error("$LADCP_file: insufficient valid velocities\n") unless ($nvw >= $min_valid_vels);
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   681
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   682
#----------------------------------------------
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   683
# STEP: Edit earth-coordinate -velocity data
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   684
#	1) error-velocity threshold
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   685
#	2) vertical-velocity outliers
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   686
#	3) truncate range by deleting farthest valid velocities (disbled by default)
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   687
#----------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   688
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   689
progress("Editing earth-coordinate velocity data...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   690
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   691
&antsAddParams('per_ens_outliers_mad_limit',$per_ens_outliers_mad_limit)
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   692
&antsAddParams('farthest_valid_bins_truncated',$truncate_farthest_valid_bins)
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   693
	if ($truncate_farthest_valid_bins);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   694
$evrm = $trrm = $worm = 0;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   695
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   696
	$evrm += editErrVel($ens,$opt_e);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   697
	$worm += editWOutliers($ens,$per_ens_outliers_mad_limit);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   698
	$trrm += editTruncRange($ens,$truncate_farthest_valid_bins) if ($truncate_farthest_valid_bins);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   699
}
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   700
progress("\terror-velocity threshold (-e %.2f m/s): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n",
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   701
	$opt_e,$evrm,round(100*$evrm/$nvw));
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   702
progress("\tvertical-velocity outliers ($per_ens_outliers_mad_limit x mad): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n",
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   703
	$worm,round(100*$worm/$nvw));
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   704
progress("\trange truncation (-z %d bins): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n",
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   705
	$truncate_farthest_valid_bins,$trrm,round(100*$trrm/$nvw))
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   706
		if ($truncate_farthest_valid_bins > 0);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   707
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   708
#----------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   709
# Calculate LADCP time series
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   710
#----------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   711
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   712
progress("Calculating LADCP time-series...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   713
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   714
($firstGoodEns,$lastGoodEns,$LADCP_atbottom,$LADCP_w_gap_time) =
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   715
	calcLADCPts(\%LADCP,$opt_s,$refLr_firstBin,$refLr_lastBin,$opt_g);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   716
error("$LADCP_file: insufficient valid data\n")
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   717
	unless defined($firstGoodEns) && ($lastGoodEns>$firstGoodEns) && ($LADCP_atbottom>=$firstGoodEns);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   718
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   719
my($cast_duration) = $LADCP{ENSEMBLE}[$lastGoodEns]->{ELAPSED} -
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   720
				     $LADCP{ENSEMBLE}[$firstGoodEns]->{ELAPSED};
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   721
error("$0: implausibly short cast ($cast_duration seconds)\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   722
	unless ($cast_duration > 600);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   723
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   724
my($year) = $LADCP{ENSEMBLE}[$firstGoodEns]->{YEAR} % 100;
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   725
&antsAddParams(sprintf('dn%02d',$year),$LADCP{ENSEMBLE}[$firstGoodEns]->{DAYNO});
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   726
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   727
$LADCP{MEAN_DT} = $cast_duration / ($lastGoodEns-$firstGoodEns-1);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   728
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   729
progress("\tStart of cast     : %s (#%5d)\n",
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   730
					$LADCP{ENSEMBLE}[$firstGoodEns]->{TIME},
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   731
					$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER});
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   732
progress("\tBottom of cast    : %s (#%5d) @ dz=%6dm\n",
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   733
					$LADCP{ENSEMBLE}[$LADCP_atbottom]->{TIME},
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   734
					$LADCP{ENSEMBLE}[$LADCP_atbottom]->{NUMBER},
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   735
					$LADCP{ENSEMBLE}[$LADCP_atbottom]->{DEPTH});
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   736
progress("\tEnd of cast       : %s (#%5d) @ dz=%6dm\n",
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   737
					$LADCP{ENSEMBLE}[$lastGoodEns]->{TIME},
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   738
					$LADCP{ENSEMBLE}[$lastGoodEns]->{NUMBER},
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   739
					$LADCP{ENSEMBLE}[$lastGoodEns]->{DEPTH});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   740
progress("\tCast duration     : %.1f hours (pinging for %.1f hours)\n",
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   741
					$cast_duration / 3600,
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   742
					($LADCP{ENSEMBLE}[$#{$LADCP{ENSEMBLE}}]->{UNIX_TIME} -
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   743
						$LADCP{ENSEMBLE}[0]->{UNIX_TIME}) / 3600);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   744
progress("\tMean ping interval: %.1f seconds\n",$LADCP{MEAN_DT});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   745
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   746
if (@out_LADCPtis) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   747
	progress("Writing LADCP-timeseries to ");
23
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
   748
	@antsNewLayout = ('ensemble','elapsed','reflr_w','reflr_w.stddev','reflr_w.nsamp','depth');
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   749
	
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   750
	foreach my $of (@out_LADCP) {
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
   751
	    progress("<$of> ");
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   752
		my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);						# sub(arg), e.g. plot_wprof(DL/003_wprof.ps)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   753
		if (defined($arg)) {													# 	NB: exactly one arg
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   754
			if (-f "./${sub}.pl") {											#	#	NB: don't quote arg
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   755
				require "./${sub}.pl";
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   756
			} else {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   757
				require "$WCALC/${sub}.pl";
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   758
			}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   759
			&{$sub}($arg);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
   760
			next;
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
   761
		}
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
   762
	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   763
		open(STDOUT,$of) || error("$of: $!\n");
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
   764
		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   765
		for (my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   766
			&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   767
					 $LADCP{ENSEMBLE}[$ens]->{ELAPSED},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   768
					 $LADCP{ENSEMBLE}[$ens]->{REFLR_W},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   769
					 $LADCP{ENSEMBLE}[$ens]->{REFLR_W_STDDEV},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   770
					 $LADCP{ENSEMBLE}[$ens]->{REFLR_W_NSAMP},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   771
					 $LADCP{ENSEMBLE}[$ens]->{DEPTH});
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   772
		}
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   773
	    &antsOut('EOF'); open(STDOUT,'>&2');
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   774
	}
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
   775
	progress("\n");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   776
}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   777
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   778
error("deepest depth is at end of cast (no upcast data)\n")
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   779
	if ($lastGoodEns-$LADCP_atbottom < 100);
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   780
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   781
#----------------------------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   782
# More editing
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   783
#	- this requires ${first,last}GoodEns to be known
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   784
#	- TILT field is set as a side-effect
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   785
#----------------------------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   786
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   787
progress("Editing additional earth-coordinate velocity data...\n");
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
   788
&antsAddParams('per_bin_valid_frac_lim',$per_bin_valid_frac_lim);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   789
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   790
my($first_bad_bin);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   791
for (my($bin)=$LADCP_firstBin-1; $bin<$LADCP_lastBin-1; $bin++) {
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   792
	next unless ($per_bin_nsamp[$bin]/($lastGoodEns-$firstGoodEns) < $per_bin_valid_frac_lim);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   793
	$first_bad_bin = $bin;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   794
	last;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   795
}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   796
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   797
my($dc_sumsq,$dc_n,$uc_sumsq,$uc_n) = (0,0,0,0);
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   798
$fprm = $pte = 0;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   799
for ($ens=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) {
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   800
	my($ne) = editTilt($ens,$opt_t);
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   801
	if ($ne == 0) {
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   802
		if ($ens <= $LADCP_atbottom) {
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   803
			$dc_sumsq += &SQR($LADCP{ENSEMBLE}[$ens]->{TILT});
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   804
			$dc_n++;
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   805
        } else {
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   806
			$uc_sumsq += &SQR($LADCP{ENSEMBLE}[$ens]->{TILT});
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   807
			$uc_n++;
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   808
        }
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   809
    } else {
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   810
		$pte += $ne;
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   811
    }
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   812
	$fprm += editFarBins($ens,$first_bad_bin) if defined($first_bad_bin);
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   813
}
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   814
my($dc_rms_tilt) = ($dc_n > 0) ? sqrt($dc_sumsq/$dc_n) : nan;
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   815
my($uc_rms_tilt) = ($uc_n > 0) ? sqrt($uc_sumsq/$uc_n) : nan;
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   816
&antsAddParams('dc_rms_tilt',$dc_rms_tilt,'uc_rms_tilt',$uc_rms_tilt);
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   817
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   818
progress("\tattitude threshold (max_tilt = %d deg): %d velocites removed (%d%% of total)\n",
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   819
	$opt_t,$pte,round(100*$pte/$nvv));
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   820
progress("\tvelocities beyond bin $first_bad_bin (<%d%% valid values): %d velocites removed (%d%% of total in bins $LADCP_firstBin-$LADCP_lastBin)\n",
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   821
	round(100*$per_bin_valid_frac_lim),$fprm,round(100*$fprm/$nvw));
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   822
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   823
#--------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   824
# Read CTD data
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   825
#--------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   826
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   827
progress("Reading CTD data from <$CTD_file>...\n");
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   828
open(STDIN,$CTD_file) || error("$CTD_file: $!\n");
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   829
error("$CTD_file: no data\n") unless (&antsIn());
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   830
undef($antsOldHeaders);
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   831
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   832
&antsAddParams('lat',$P{lat}) if defined($P{lat});
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   833
&antsAddParams('lon',$P{lon}) if defined($P{lon});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   834
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   835
($CTD_elapsed,$CTD_depth,$CTD_svel,$CTD_w) = &fnr('elapsed','depth','ss','w');
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   836
$CTD_temp = &fnrNoErr('temp');
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   837
warning(0,"no CTD temperature --- using ADCP temperature instead => Sv degraded!\n",$s)
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   838
   unless defined($CTD_temp);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   839
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   840
$CTD_maxdepth = -1;
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   841
do {																		# read data
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   842
	error("$0: cannot deal with non-numeric CTD elapsed time\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   843
		unless &antsNumbers($CTD_elapsed);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   844
	push(@{$CTD{ELAPSED}},$ants_[0][$CTD_elapsed]);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   845
	push(@{$CTD{DEPTH}},  $ants_[0][$CTD_depth]);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   846
	push(@{$CTD{SVEL}},   $ants_[0][$CTD_svel]);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   847
	push(@{$CTD{W}},      $ants_[0][$CTD_w]);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   848
	push(@{$CTD{TEMP}},	  $ants_[0][$CTD_temp]) if defined($CTD_temp);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   849
	if ($ants_[0][$CTD_depth] > $CTD_maxdepth) {
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   850
		$CTD_maxdepth = $ants_[0][$CTD_depth];
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   851
		$CTD_atbottom = $#{$CTD{DEPTH}};
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   852
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   853
} while (&antsIn());
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   854
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   855
$CTD{DT} = ($CTD{ELAPSED}[$#{$CTD{ELAPSED}}] - $CTD{ELAPSED}[0]) / $#{$CTD{ELAPSED}};
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   856
progress("\t%d scans at %.1fHz\n",scalar(@{$CTD{DEPTH}}),1/$CTD{DT});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   857
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   858
$CTD{W_t}[0]  = $CTD{W_t} [@{$CTD{ELAPSED}}] = nan;							# calculate w-derivatives
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   859
$CTD{W_tt}[0] = $CTD{W_tt}[@{$CTD{ELAPSED}}] = nan;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   860
for (my($s)=1; $s<@{$CTD{ELAPSED}}-1; $s++) {								# centered differences for both
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   861
	$CTD{W_t} [$s] = ($CTD{W}[$s+1] - $CTD{W}[$s-1]) / (2*$CTD{DT});
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
   862
	$CTD{W_tt}[$s] = ($CTD{W}[$s+1] + $CTD{W}[$s-1] - 2*$CTD{W}[$s]) / &SQR($CTD{DT});
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   863
}
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
   864
$CTD_maxdepth = round($CTD_maxdepth);
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   865
error("$0: CTD start depth must be numeric\n")
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   866
	unless numberp($CTD{DEPTH}[0]);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   867
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   868
progress("\tstart depth = %.1fm\n",$CTD{DEPTH}[0]);
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   869
progress("\tmax depth   = %dm (# $CTD_atbottom)\n",$CTD_maxdepth);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   870
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   871
#--------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   872
# Construct sound-speed correction profile from CTD 1Hz downcast data
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   873
#	very simple algorithm that stores the last value found
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   874
#	in each 1m bin
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
   875
# For PPI filtering, a sound speed profile without gaps is required.
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   876
#--------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   877
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   878
progress("Constructing sound-speed correction profile\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   879
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   880
my($scans_per_sec) = int(1/$CTD{DT}+0.5);
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   881
my($min_depth) = 9e99;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   882
for (my($s)=0; $s<=$CTD_atbottom; $s+=$scans_per_sec) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   883
	next unless ($CTD{DEPTH}[$s] >= 0 && numberp($CTD{SVEL}[$s]));
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   884
	my($d) = int($CTD{DEPTH}[$s]);
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   885
	$min_depth = $d if ($d < $min_depth);
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   886
	$sVelProf[$d] = $CTD{SVEL}[$s];
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   887
}
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
   888
while ($min_depth > 0) {													# fill surface gap
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   889
	$sVelProf[$min_depth-1] = $sVelProf[$min_depth];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   890
	$min_depth--;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
   891
}
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
   892
for (my($d)=$min_depth+1; $d<=$#sVelProf; $d++) {							# fill interior gaps
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
   893
	$sVelProf[$d] = $sVelProf[$d-1]
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
   894
		unless defined($sVelProf[$d]);
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
   895
}
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
   896
	
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 17
diff changeset
   897
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   898
#-------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   899
# Determine time lag
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   900
#-------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   901
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   902
if (defined($opt_i)) {
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   903
	progress("Setting initial time lag...\n");
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   904
	$CTD{TIME_LAG} = $opt_i;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   905
	progress("\t-i => elapsed(CTD) ~ elapsed(LADCP) + %.1fs\n",$CTD{TIME_LAG});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   906
} else {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   907
	progress("Guestimating time lag...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   908
	
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   909
	my($CTD_10pct_down) = 0;
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   910
	my($LADCP_10pct_down) = $firstGoodEns;
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   911
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   912
	$CTD_10pct_down++
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   913
		until ($CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0] >= 0.1*($CTD_maxdepth-$CTD{DEPTH}[0]));
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   914
	$LADCP_10pct_down++
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   915
		until ($LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH} >= 0.1*$LADCP{ENSEMBLE}[$LADCP_atbottom]->{DEPTH});
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   916
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   917
	$CTD{TIME_LAG} =
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   918
		$CTD{ELAPSED}[$CTD_10pct_down] - $LADCP{ENSEMBLE}[$LADCP_10pct_down]->{ELAPSED};
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   919
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   920
	progress("\telapsed(dz(CTD)=%.1fm) ~ elapsed(dz(LADCP)=%.1fm) + %.1fs\n",
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   921
	    $CTD{DEPTH}[$CTD_10pct_down]-$CTD{DEPTH}[0],$LADCP{ENSEMBLE}[$LADCP_10pct_down]->{DEPTH},$CTD{TIME_LAG});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   922
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   923
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   924
if ($opt_u) {
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
   925
	progress("\tskipping time lagging (-u)\n");
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   926
} else {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   927
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   928
	#------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   929
	# stage 1: 1Hz; full cast
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   930
	#------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   931
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   932
	$CTD{TIME_LAG} =														
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   933
		calc_lag($number_of_timelag_windows[0],$length_of_timelag_windows[0],
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   934
				 int(1/$CTD{DT}+0.5),$firstGoodEns,$lastGoodEns);
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   935
	error("$0: Cannot proceed without valid lag!\n") unless defined($CTD{TIME_LAG});
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   936
	progress("\telapsed(CTD) ~ elapsed(LADCP) + %.2fs\n",$CTD{TIME_LAG});
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   937
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   938
	#---------------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   939
	# stage 2: piece-wise time lagging
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   940
	#---------------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   941
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   942
	my(@splits);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   943
	push(@splits,$firstGoodEns);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   944
	foreach my $s (split(/,/,$opt_p)) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   945
		if ($s eq '+') {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   946
			push(@splits,$LADCP_atbottom);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   947
		} elsif (numberp($s)) {												# find ens for given LADCP elapsed time in min
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   948
			my($ela) = $s*60;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   949
			my($ens) = $firstGoodEns + round($ela / $LADCP{MEAN_DT});		# first, guess
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   950
			while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} > $ela) { $ens--; }	# then, correct
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   951
			while ($LADCP{ENSEMBLE}[$ens]->{ELAPSED} < $ela) { $ens++; }
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   952
			push(@splits,$ens);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   953
		} else {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   954
			warning(2,"ignoring non-numeric -p argument %s",$s);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   955
		}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   956
    }
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   957
	push(@splits,$lastGoodEns);
11
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
   958
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   959
	my($valid_lag);															# determine piece-wise lags
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   960
	while (@splits > 1) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   961
		push(@CTD_tl_fromEns,$splits[0]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   962
		push(@CTD_tl_toEns,$splits[1]);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   963
		debugmsg("lag($splits[0],$splits[1]) = ");
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   964
		my($lag) = calc_lag($number_of_timelag_windows[1],$length_of_timelag_windows[1],
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   965
							1,$splits[0],$splits[1]);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   966
		debugmsg("$lag\n");									
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   967
		if (defined($lag)) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   968
			progress("\tcast-piece: elapsed(CTD) = elapsed(LADCP) + %.2fs\n",$lag);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   969
			push(@CTD_time_lag,$lag);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   970
			$valid_lag = $#CTD_time_lag;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   971
		} else {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   972
			progress("\tcast-piece: time-lagging failed\n");
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   973
			push(@CTD_time_lag,nan);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   974
		}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   975
		shift(@splits);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   976
	}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   977
			
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   978
	error("$0: Cannot proceed without at least one lag!\n")					# fill failed lag with surrounding data
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   979
		unless defined($valid_lag);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   980
	while ($valid_lag < $#CTD_time_lag) {									# forward
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   981
		$CTD_time_lag[$valid_lag+1] = $CTD_time_lag[$valid_lag];
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   982
		$valid_lag++;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   983
	}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   984
	while ($valid_lag > 0) {												# backward
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   985
		$CTD_time_lag[$valid_lag-1] = $CTD_time_lag[$valid_lag]
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   986
			unless (numberp($CTD_time_lag[$valid_lag-1]));
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   987
		$valid_lag--;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   988
	}
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   989
}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   990
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   991
&antsAddParams('CTD_time_lags',"@CTD_time_lag");
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
   992
undef($CTD{TIME_LAG}); 														# to avoid confusion, clear old 1Hz-based lag
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   993
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   994
#------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   995
# Merge CTD with LADCP data
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   996
#	- after this step, reflr w is sound-speed corrected!!!
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   997
#------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   998
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   999
progress("Merging CTD with LADCP data...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1000
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1001
&antsAddParams('w_max_lim',$w_max_lim);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1002
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1003
my($cli) = 0;																	# current-lag index
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1004
my($lag) = $CTD_time_lag[$cli];													# current lag
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1005
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1006
my($dc_sumsq,$dc_n,$uc_sumsq,$uc_n) = (0,0,0,0);								# for a_pkg calcs
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1007
for (my($skipped)=0,my($ens)=$firstGoodEns; $ens<=$lastGoodEns; $ens++) {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1008
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1009
	if ($ens > $CTD_tl_toEns[$cli]) {											# use correct lag piece
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1010
		$cli++;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1011
		die("assertion failed!\n\ttest: \$cli(=$cli) <= \$#CTD_time_lag\n")
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1012
			unless ($cli <= $#CTD_time_lag);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1013
		$lag = $CTD_time_lag[$cli];
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1014
	}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1015
	
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1016
	my($scan) = 
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1017
		int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED} + $lag - $CTD{ELAPSED}[0]) / $CTD{DT} + 0.5);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1018
	if ($scan <= 0) {	# NB: must be <=, rather than <, or assertion below sometimes fails
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1019
		$skipped++;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1020
		$firstGoodEns = $ens+1;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1021
		next;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1022
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1023
	if ($skipped > 0) {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1024
		$firstGoodEns++,$skipped++,next											# in gap
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1025
			unless defined($LADCP{ENSEMBLE}[$firstGoodEns]->{REFLR_W});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1026
		info("$skipped initial LADCP ensembles skipped because CTD data begin with LADCP in water\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1027
		$skipped = 0;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1028
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1029
	if ($scan > $#{$CTD{ELAPSED}}) {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1030
		while (!defined($LADCP{ENSEMBLE}[$ens-1]->{REFLR_W})) { $ens--; }		# in gap
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1031
		info(sprintf("%d final LADCP ensembles skipped because CTD data end with LADCP in water\n",
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1032
			$lastGoodEns-$ens+1));
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1033
		$lastGoodEns = $ens-1;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1034
		last;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1035
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1036
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1037
	$LADCP{ENSEMBLE}[$ens]->{CTD_ELAPSED} = $CTD{ELAPSED}[$scan];		# elapsed field for output
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1038
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1039
	if (defined($LADCP{ENSEMBLE}[$ens]->{REFLR_W})						# not a gap
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1040
			&& numberp($CTD{DEPTH}[$scan])) {
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1041
		$LADCP{ENSEMBLE}[$ens]->{REFLR_W_NOSSCORR} = $LADCP{ENSEMBLE}[$ens]->{REFLR_W};				
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1042
	    $LADCP{ENSEMBLE}[$ens]->{REFLR_W} *= $CTD{SVEL}[$scan]/1500; 	# correct for sound-speed variations at source
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1043
		error(sprintf("\n$0: negative depth (%.1fm) in CTD file at elapsed(CTD) = %.1fs\n",
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1044
			$CTD{DEPTH}[$scan],$CTD{ELAPSED}[$scan]))
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1045
				unless ($CTD{DEPTH}[$scan] >= 0);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1046
		$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} = $CTD{DEPTH}[$scan];
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1047
		$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN} = $scan;						# calc rms package acceleration
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1048
		if (numberp($CTD{W_t}[$scan])) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1049
			if ($ens <= $LADCP_atbottom) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1050
				$dc_sumsq += &SQR($CTD{W_t}[$scan]); $dc_n++;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1051
    	    } else {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1052
				$uc_sumsq += &SQR($CTD{W_t}[$scan]); $uc_n++;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1053
			}
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
  1054
		}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1055
		my($reflr_ocean_w) = $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$scan];
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1056
		if (abs($reflr_ocean_w) <= $w_max_lim) {
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1057
			$sumWsq += &SQR($reflr_ocean_w);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1058
			$nWsq++;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1059
			if ($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} > 100 &&
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1060
				$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} < $LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH}-100) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1061
					$sumWsqI += &SQR($reflr_ocean_w);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1062
					$nWsqI++;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1063
	        }
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1064
	    } else {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1065
	    	undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});					# DON'T USE THIS ENSEMBLE LATER
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1066
	    }
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1067
	} else{
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1068
	    undef($LADCP{ENSEMBLE}[$ens]->{REFLR_W});						# don't output in time-series file
10
7e76fdef8953 version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
  1069
	    undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});						# old DEPTH from calcLADCPts() must be removed
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1070
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1071
}
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
  1072
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1073
my($dc_rms_apkg) = ($dc_n > 0) ? sqrt($dc_sumsq / $dc_n) : nan;			# rms package acceleration
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1074
my($uc_rms_apkg) = ($uc_n > 0) ? sqrt($uc_sumsq / $uc_n) : nan;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1075
&antsAddParams('dc_rms_accel_pkg',$dc_rms_apkg,'uc_rms_accel_pkg',$uc_rms_apkg);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1076
	
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1077
if ($nWsq > 0 && $nWsqI > 0) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1078
	&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',sqrt($sumWsqI/$nWsqI));
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1079
	progress("\t%.2f cm/s rms reference-layer w_ocean, %.2f cm/s away from boundaries\n",
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1080
						100*sqrt($sumWsq/$nWsq),100*sqrt($sumWsqI/$nWsqI));
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1081
#	if (sqrt($sumWsqI/$nWsqI) > 0.05) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1082
#		warning(0,"%.2f cm/s (large) reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI));
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1083
#	} els
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1084
	if (sqrt($sumWsqI/$nWsqI) > 0.15) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1085
		warning(2,"%.2f cm/s (implausibly large) reference-layer w_ocean away from boundaries\n",100*sqrt($sumWsqI/$nWsqI));
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
  1086
	}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1087
} elsif ($nWsq > 0) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1088
	&antsAddParams('rms_w_reflr_err',sqrt($sumWsq/$nWsq),'rms_w_reflr_err_interior',nan);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1089
	progress("\t%.2f cm/s rms reference-layer w_ocean\n",100*sqrt($sumWsq/$nWsq));
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1090
} else {
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
  1091
	error("$0: no valid vertical velocities\n");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1092
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1093
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1094
#----------------------------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1095
# Calculate Volume Scattering Coefficients
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1096
#----------------------------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1097
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
  1098
progress("Calculating volume-scattering coefficients (Sv)...\n");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1099
calc_backscatter_profs($firstGoodEns,$lastGoodEns);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1100
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1101
if (@nSv) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1102
	progress("\tapplying empirical Sv correction\n");
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1103
	correct_backscatter($firstGoodEns,$lastGoodEns);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1104
}
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
  1105
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1106
#----------------------------------------------------------------------------
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
  1107
# Find Seabed & Edit data
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
  1108
#	1) contaminated by sidelobe reflection from seabed and sea surface
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
  1109
#	2) PPI 
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1110
#----------------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1111
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1112
error("$0: conflicting water-depth information provided by user\n")					# this can only happen if
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1113
	if defined($opt_h) && defined($water_depth);									# the user is setting $water_depth
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1114
																					# explicitly?!
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1115
if (defined($opt_h)) {																# deal with user-provided water-depth info
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1116
	if (numberp($opt_h)) {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1117
		$water_depth = $opt_h;
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1118
	} elsif (-f $opt_h) {
40
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
  1119
		open(WDF,$opt_h) || error("$opt_h: $_\n");
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1120
		$water_depth = &antsFileScanParam(WDF,'water_depth');
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1121
		close(WDF);
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1122
		undef($water_depth) unless numberp($water_depth);
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1123
	} else {
40
408fc95bcff8 V1.2beta4
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 39
diff changeset
  1124
		error("$0: -h $opt_h defines neither number nor existing file\n");
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1125
    }
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1126
}
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1127
	
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1128
#die("assertion failed (water_depth = $water_depth)")
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1129
#	unless (!defined($water_depth) || numberp($water_depth));
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1130
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1131
if (!defined($water_depth) &&														# find seabed in data
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1132
		$LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) {
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1133
	progress("Finding seabed...\n");
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1134
	($water_depth,$sig_water_depth) =
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1135
		find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_atbottom]->{CTD_DEPTH});
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1136
	($water_depth_BT,$sig_water_depth_BT) =
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1137
		find_seabed(\%LADCP,$LADCP_atbottom,$LADCP{BEAM_COORDINATES});
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1138
	if (defined($water_depth) && defined($water_depth_BT)) {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1139
		my($dd) = abs($water_depth_BT - $water_depth);
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1140
#		warning(0,sprintf("Large instrument vs. backscatter-derived water-depth difference (%.1fm)\n",$dd))
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1141
#			if ($dd > 10);
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1142
	}
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1143
	if (!$SS_use_BT && !defined($water_depth) && defined($water_depth_BT)) {		# warn if use of BT was not
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1144
		warning(1,"using water_depth from ADCP BT data\n");							# explicitly requested
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1145
		$SS_use_BT = 1;
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1146
	}
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1147
	if ($SS_use_BT) {																# water depth from BT data
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1148
		&antsAddParams('water_depth_from','BT_data');
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1149
		$water_depth = $water_depth_BT;
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1150
		$sig_water_depth = $sig_water_depth_BT;
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1151
    } else {																		# water depth from WT data
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1152
		&antsAddParams('water_depth_from','echo_amplitudes');
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1153
	}
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1154
}
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1155
	
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1156
if (defined($water_depth)) {														# 1 or 2 water depths available
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1157
	if (defined($water_depth_BT)) {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1158
		progress("\t%.1f(%.1f) m water depth (%.1f(%.1f)m from ADCP BT data)\n",
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1159
			$water_depth,$sig_water_depth,$water_depth_BT,$sig_water_depth_BT);
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1160
	} else {
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1161
		progress("\t%.1f(%.1f) m water depth (no seabed found in BT data)\n",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1162
			$water_depth,$sig_water_depth);
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1163
	}
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1164
	warning(1,sprintf("large uncertainty in water-depth estimation (%.1fm)\n",
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1165
		$sig_water_depth))
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1166
			if ($sig_water_depth > $LADCP{BIN_LENGTH});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1167
	if ($water_depth < $CTD_maxdepth) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1168
		warning(2,"water depth ($water_depth m) < max CTD depth ($CTD_maxdepth m) ignored\n");
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1169
		undef($water_depth);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1170
	}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1171
}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1172
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1173
if (defined($water_depth)) {														# set %PARAMs
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1174
	&antsAddParams('water_depth',$water_depth,'water_depth.sig',$sig_water_depth);
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1175
} else {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1176
	warning(2,"unknown water depth --- cannot edit sidelobes or PPI near the seabed\n");
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1177
	&antsAddParams('water_depth','unknown','water_depth.sig','nan');
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1178
}
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1179
	
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1180
if ($LADCP{ENSEMBLE}[$LADCP_atbottom]->{XDUCER_FACING_DOWN}) {						# DOWNLOOKER
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
  1181
	&antsAddParams('ADCP_orientation','DL');
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1182
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1183
	if (defined($water_depth)) {
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1184
		progress("Editing data to remove sidelobe interference from seabed...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1185
		($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1186
		progress("\t$nvrm velocities from $nerm ensembles removed\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1187
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1188
		if ($sidelobe_editing_DL_surface) {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1189
			progress("Editing data to remove sidelobe interference from sea surface...\n");
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1190
			($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef);
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1191
	        progress("\t$nvrm velocities from $nerm ensembles removed\n");
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1192
	        &antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1193
	    } else {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1194
	        &antsAddParams('sidelobe_editing','seabed');
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1195
	    }
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1196
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1197
		if ($PPI_editing) {
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1198
			&antsAddParams('PPI_editing','seabed');
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1199
			&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit)
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1200
				if numberp($PPI_extend_upper_limit);
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1201
			progress("Editing data to remove PPI from seabed...\n");
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1202
			  progress("\tConstructing depth-average soundspeed profile...\n");
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1203
			  die("assertion failed") unless defined($water_depth);
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1204
			  my($dz) = $water_depth - $#sVelProf;							# $#sVelProf = max_depth(profile) in meters
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1205
			  my($sum) = $dz * $sVelProf[$#sVelProf];
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1206
			  $DASSprof[$#sVelProf] = $sum/$dz;
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1207
			  for (my($d)=$#sVelProf-1; $d>=0; $d--) {
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1208
			  	die("assertion failed (d=$d, #sVelProf=$#sVelProf)") unless numberp($sVelProf[$d]);
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1209
			  	$sum += $sVelProf[$d];
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1210
			  	$dz++;
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1211
				$DASSprof[$d] = $sum/$dz;
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1212
			  }
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1213
			($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,$water_depth);
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1214
	        progress("\t$nvrm velocities from $nerm ensembles removed\n");
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1215
	    }
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1216
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1217
	
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1218
} else {																	# UPLOOKER
41
6bddb82924e3 V1.2beta5
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
  1219
	&antsAddParams('ADCP_orientation','UL');
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
  1220
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1221
	progress("Editing data to remove sidelobe interference from sea surface...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1222
	($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,undef);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1223
	progress("\t$nvrm velocities from $nerm ensembles removed\n");
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 13
diff changeset
  1224
32
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1225
	if ($sidelobe_editing_UL_seabed) {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1226
		if (defined($water_depth)) {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1227
			progress("Editing data to remove sidelobe interference from seabed...\n");
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1228
			($nvrm,$nerm) = editSideLobes($firstGoodEns,$lastGoodEns,$water_depth);
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1229
        	progress("\t$nvrm velocities from $nerm ensembles removed\n");
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1230
        } else {
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1231
			warning(2,"unknown water depth --- cannot edit UL data for sidelobe interference from seabed\n");
6041a20feb39 V1.0 release candidate
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
  1232
        }
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1233
        &antsAddParams('sidelobe_editing','surface+seabed','vessel_draft',$vessel_draft);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1234
    } else {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1235
        &antsAddParams('sidelobe_editing','surface','vessel_draft',$vessel_draft);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1236
    } 
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1237
	if ($PPI_editing) {
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1238
		&antsAddParams('PPI_editing','surface');
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1239
		&antsAddParams('PPI_extend_upper_limit',$PPI_extend_upper_limit)
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1240
			if numberp($PPI_extend_upper_limit);
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1241
		progress("Editing data to remove PPI from sea surface...\n");
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1242
		  progress("\tConstructing depth-average soundspeed profile...\n");
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1243
		  $DASSprof[0] = my($sum) = 0;
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1244
		  for (my($d)=1; $d<=$#sVelProf; $d++) {
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1245
		  	die("assertion failed") unless numberp($sVelProf[$d]);
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1246
		  	$sum += $sVelProf[$d];
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1247
			$DASSprof[$d] = $sum/$d;
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1248
		  }
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1249
		($nvrm,$nerm) = editPPI($firstGoodEns,$lastGoodEns,undef);
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1250
	    progress("\t$nvrm velocities from $nerm ensembles removed\n");
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1251
	}
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1252
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1253
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1254
#----------------------------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1255
# Data Editing after LADCP and CTD data have been merged
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1256
#	1) surface layer editing
19
1d49806c9f75 laptop copy
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 18
diff changeset
  1257
#	2) user-supplied $edit_data_hook
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1258
#----------------------------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1259
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1260
progress("Removing data from instrument at surface...\n");
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1261
&antsAddParams('surface_layer_depth',$surface_layer_depth);
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1262
$nerm = editSurfLayer($firstGoodEns,$lastGoodEns,$surface_layer_depth);
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1263
progress("\t$nerm ensembles removed\n");
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1264
11
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
  1265
if (defined($post_merge_hook)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
  1266
	progress("Executing user-supplied \$post_merge_hook...\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
  1267
	&{$post_merge_hook}($firstGoodEns,$lastGoodEns);
10
7e76fdef8953 version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
  1268
}
7e76fdef8953 version prior to carrying out separate dc-/uc- time lagging
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
  1269
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1270
#----------------------------------------------------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1271
# apply pressure-sensor acceleration correction (-a)
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1272
#	- valid, but useless except for troubleshooting data sets (e.g. DIMES UK2)
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1273
#	- useless, because ping-coherent error removal below does same job but better
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1274
#	- it does not make sense to to use this with ping-coherent error removal enabled
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1275
#----------------------------------------------------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1276
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1277
if ($opt_a != 1) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1278
	progress("Applying pressure-sensor acceleration correction...\n");
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1279
	for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1280
		next unless numberp($CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1281
		my($acorr) = $opt_a * $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}];
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1282
		if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1283
			for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1284
				next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1285
				$LADCP{ENSEMBLE}[$ens]->{W}[$bin] -= $acorr;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1286
	        }
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1287
	    }
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1288
		if (numberp($LADCP{ENSEMBLE}[$ens]->{REFLR_W})) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1289
			$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -= $acorr;
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1290
		}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1291
	}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1292
}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1293
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1294
#---------------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1295
# Depth-bin LADCP velocity data
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1296
#
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1297
# NOTES:
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1298
#	1) ensemble and bin numbers are saved for maximum flexibility
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1299
#	2) only ensemble/bins with valid vertical velocities are saved
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1300
#	3) applying the full soundspeed correction to w is pointless in
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1301
#	   practice, but hey!, CPU cycles are cheap; [in a cast in the Gulf of Mexico
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1302
#	   which has fairly pronounce soundspeed gradients, the max value of Kn
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1303
#	   is 1.00004160558372, which gives rise to a correction of less than 0.2mm/s
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1304
#	   at a winch+wave speed of 3m/s....]
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1305
#	4) as far as I can tell, the soundspeed correction for bin length also
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1306
#	   has only a minute effect
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1307
#---------------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1308
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1309
progress("Creating binned profiles at ${opt_o}m resolution...\n");
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1310
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1311
&antsAddParams('outgrid_dz',$opt_o,'outgrid_minsamp',$opt_k);					# used by LADCP_w_regrid
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1312
&antsAddParams('outgrid_firstbin',$outGrid_firstBin,'outgrid_lastbin',$outGrid_lastBin);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1313
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1314
my($min_depth) = 9e99;
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1315
my($max_depth) = 0;
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1316
local($realLastGoodEns);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1317
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1318
progress("\tdowncast...\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1319
for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# downcast
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1320
	unless (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) {
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1321
		$firstGoodEns++ if ($ens == $firstGoodEns);								# start has been edited away
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1322
		next;
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1323
	}
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
  1324
	$realLastGoodEns = $ens;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1325
	my(@bindepth) = calc_binDepths($ens);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1326
	for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1327
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1328
		next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1329
		$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth);
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1330
		$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth);
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1331
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] =
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1332
			sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1333
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1334
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1335
					 $bindepth[$bin]);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1336
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] =
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1337
			sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1338
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1339
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1340
					 $bindepth[$bin])
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1341
				if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1342
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] =
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1343
			sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1344
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1345
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1346
					 $bindepth[$bin])
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1347
				if numberp($LADCP{ENSEMBLE}[$ens]->{W34}[$bin]);
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1348
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin] =
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1349
			$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}];
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1350
		my($bi) = $bindepth[$bin]/$opt_o;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1351
		push(@{$DNCAST{ENSEMBLE}[$bi]},$ens);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1352
		push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1353
#		push(@{$DNCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1354
#		push(@{$DNCAST{CTD_W_tt}[$bi]},$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1355
#		push(@{$DNCAST{BIN}[$bi]},$bin);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1356
		push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1357
		push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1358
		push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1359
		push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1360
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1361
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1362
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1363
for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) {							# bin data into profile
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1364
	$DNCAST{MEAN_DEPTH}[$bi]  	= avg(@{$DNCAST{DEPTH}[$bi]});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1365
	$DNCAST{MEAN_ELAPSED}[$bi]	= avg(@{$DNCAST{ELAPSED}[$bi]});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1366
	$DNCAST{MEDIAN_W}[$bi] 	  	= median(@{$DNCAST{W}[$bi]});
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1367
	$DNCAST{MEDIAN_W12}[$bi]  	= median(@{$DNCAST{W12}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1368
	$DNCAST{MEDIAN_W34}[$bi]  	= median(@{$DNCAST{W34}[$bi]});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1369
	$DNCAST{MAD_W}[$bi]		  	= mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1370
	$DNCAST{N_SAMP}[$bi]		= @{$DNCAST{W}[$bi]};
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1371
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1372
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1373
progress("\tupcast...\n");														# upcast
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1374
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1375
for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) {		
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1376
	next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1377
	$realLastGoodEns = $ens;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1378
	my(@bindepth) = calc_binDepths($ens);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1379
	for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1380
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1381
		next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1382
		$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth);
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1383
		$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth);
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1384
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] =
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1385
			sscorr_w($LADCP{ENSEMBLE}[$ens]->{W}[$bin],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1386
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1387
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1388
					 $bindepth[$bin]);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1389
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] =
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1390
			sscorr_w($LADCP{ENSEMBLE}[$ens]->{W12}[$bin],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1391
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1392
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1393
					 $bindepth[$bin])
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1394
				if numberp($LADCP{ENSEMBLE}[$ens]->{W12}[$bin]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1395
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] =
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1396
			sscorr_w($LADCP{ENSEMBLE}[$ens]->{W34}[$bin],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1397
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1398
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1399
					 $bindepth[$bin])
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
  1400
				if numberp($LADCP{ENSEMBLE}[$ens]->{W34}[$bin]);
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1401
		$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin] =
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1402
			$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] + $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}];
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1403
		my($bi) = $bindepth[$bin]/$opt_o;
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1404
		push(@{$UPCAST{ENSEMBLE}[$bi]},$ens);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1405
		push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1406
#		push(@{$UPCAST{CTD_W}[$bi]},$CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1407
#		push(@{$UPCAST{CTD_W_tt}[$bi]},$CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1408
#		push(@{$UPCAST{BIN}[$bi]},$bin);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1409
		push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1410
		push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1411
		push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1412
		push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1413
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1414
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1415
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1416
for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1417
	$UPCAST{MEAN_DEPTH}[$bi]  	= avg(@{$UPCAST{DEPTH}[$bi]});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1418
	$UPCAST{MEAN_ELAPSED}[$bi]	= avg(@{$UPCAST{ELAPSED}[$bi]});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1419
	$UPCAST{MEDIAN_W}[$bi] 	  	= median(@{$UPCAST{W}[$bi]});
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1420
	$UPCAST{MEDIAN_W12}[$bi]  	= median(@{$UPCAST{W12}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1421
	$UPCAST{MEDIAN_W34}[$bi]  	= median(@{$UPCAST{W34}[$bi]});
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1422
	$UPCAST{MAD_W}[$bi]		  	= mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]});
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1423
	$UPCAST{N_SAMP}[$bi]		= @{$UPCAST{W}[$bi]};
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1424
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1425
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1426
#------------------------------------------------------------------------------------------------------
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1427
# remove ping-coherent residuals
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1428
#	- potential error sources:
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1429
#		1) acceleration-dependence of Paroscientific pressure measurements; O(10cm/s) [IWISE 28]
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1430
#		2) residual CTD/LADCP mismatch errors; O(1cm/s) [Thurnherr, CWTMC 2011]
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1431
#		3) ADCP short-term variability; O(1cm/s) for vertical?
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1432
#	- two steps:
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1433
#		- remove ensemble-median residual from all ocean vertical velocities
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1434
#		- re-bin profiles
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1435
#		- calculate new residuals
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1436
#	- improves solution but can introduce errors in ensembles with strong outliers => median instead of
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1437
#	  mean, and outlier filter above
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1438
#------------------------------------------------------------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1439
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1440
unless ($opt_q) {
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1441
	progress("Removing ping-coherent residuals...\n");
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1442
	
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1443
	for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) {
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1444
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
11
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 10
diff changeset
  1445
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1446
		my(@residuals) = ();												# calc median of residuals
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1447
		my(@bindepth) = calc_binDepths($ens);
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1448
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1449
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1450
		    next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1451
			my($bi) = $bindepth[$bin]/$opt_o;
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1452
			push(@residuals,
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1453
				$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] -
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1454
					(($ens < $LADCP_atbottom) ? $DNCAST{MEDIAN_W}[$bi]
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1455
											  : $UPCAST{MEDIAN_W}[$bi]));
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1456
		}
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1457
		$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W} = median(@residuals);	# NB: can be nan!
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1458
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W});
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1459
		
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1460
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {		# remove from ocean velocities
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1461
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1462
			$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] -=
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1463
				$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W};
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1464
			$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] -=
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1465
				$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1466
					if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]);
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1467
			$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] -=
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1468
				$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1469
					if numberp($LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]);
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1470
		}
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1471
		
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1472
		$LADCP{ENSEMBLE}[$ens]->{REFLR_W} -=								# NB: this can be nan here
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1473
			$LADCP{ENSEMBLE}[$ens]->{MEDIAN_RESIDUAL_W}
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1474
				if numberp($LADCP{ENSEMBLE}[$ens]->{REFLR_W});
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1475
    }
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1476
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1477
	#------------------------------------------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1478
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1479
    progress("\tre-binning profile data...\n");
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1480
    
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1481
	for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) {					# bin data
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1482
		for (my($i)=0; $i<@{$DNCAST{W}[$bi]}; $i++) {						# code works if MEDIAN_RESIDUAL_W is nan (possible?) 
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1483
			$DNCAST{W}  [$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W};
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1484
			$DNCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W};
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1485
			$DNCAST{W34}[$bi][$i] -= $LADCP{ENSEMBLE}[$DNCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W};
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1486
		}
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1487
		$DNCAST{MEDIAN_W}  [$bi] = median(@{$DNCAST{W}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1488
		$DNCAST{MEDIAN_W12}[$bi] = median(@{$DNCAST{W12}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1489
		$DNCAST{MEDIAN_W34}[$bi] = median(@{$DNCAST{W34}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1490
		$DNCAST{MAD_W}	   [$bi] = mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]});
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1491
	}
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1492
	for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) {
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1493
		for (my($i)=0; $i<@{$UPCAST{W}[$bi]}; $i++) {
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1494
			$UPCAST{W}  [$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W};
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1495
			$UPCAST{W12}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W};
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1496
			$UPCAST{W34}[$bi][$i] -= $LADCP{ENSEMBLE}[$UPCAST{ENSEMBLE}[$bi][$i]]->{MEDIAN_RESIDUAL_W};
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1497
		}
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1498
		$UPCAST{MEDIAN_W}  [$bi] = median(@{$UPCAST{W}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1499
		$UPCAST{MEDIAN_W12}[$bi] = median(@{$UPCAST{W12}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1500
		$UPCAST{MEDIAN_W34}[$bi] = median(@{$UPCAST{W34}[$bi]});
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1501
		$UPCAST{MAD_W}	   [$bi] = mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]});
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1502
	}
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1503
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1504
} # unless ($opt_q);
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1505
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1506
#----------------------------------------------------------------------
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1507
# remove ensembles with large rms residuals
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1508
#----------------------------------------------------------------------
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1509
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1510
if (defined($opt_r)) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1511
	progress("Removing ensembles with large residuals...\n");	
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1512
	
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1513
	$nerm = 0;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1514
	for ($ens=$firstGoodEns; $ens<=$lastGoodEns; $ens++) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1515
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1516
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1517
		my($sum) = my($n) = 0;														# calculate rms residual
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1518
		my(@bindepth) = calc_binDepths($ens);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1519
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1520
			next unless ($bin+1>=$outGrid_firstBin && $bin+1<=$outGrid_lastBin);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1521
		  	next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1522
		  	my($bi) = $bindepth[$bin]/$opt_o;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1523
			my($res) = ($ens < $LADCP_atbottom) ? 
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1524
						$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi] :
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1525
						$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi];
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1526
			$sum += &SQR($res); $n++;						
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1527
		}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1528
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1529
		if ($n == 0 || sqrt($sum/$n) > $opt_r) {									# ensemble is bad
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1530
			undef($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1531
			$nerm++;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1532
		}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1533
	}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1534
	progress("\t$nerm ensembles removed (%d%% of total)\n",round(100*$nerm/($lastGoodEns-$firstGoodEns+1)));
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1535
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1536
    progress("\tre-binning profile data...\n");
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1537
    undef(%DNCAST); undef(%UPCAST);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1538
	$min_depth = 9e99; my($max_depth) = 0;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1539
	for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# downcast
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1540
		unless (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1541
			$firstGoodEns++ if ($ens == $firstGoodEns); 							# start has been edited away
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1542
			next;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1543
		}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1544
		$realLastGoodEns = $ens;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1545
		my(@bindepth) = calc_binDepths($ens);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1546
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1547
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1548
			next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1549
			$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1550
			$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1551
			my($bi) = $bindepth[$bin]/$opt_o;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1552
			push(@{$DNCAST{ENSEMBLE}[$bi]},$ens);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1553
			push(@{$DNCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1554
			push(@{$DNCAST{DEPTH}[$bi]},$bindepth[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1555
			push(@{$DNCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1556
			push(@{$DNCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1557
			push(@{$DNCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1558
		}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1559
	}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1560
	for (my($bi)=0; $bi<=$#{$DNCAST{ENSEMBLE}}; $bi++) {							# bin data into profile
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1561
		$DNCAST{MEAN_DEPTH}[$bi]	= avg(@{$DNCAST{DEPTH}[$bi]});	
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1562
		$DNCAST{MEAN_ELAPSED}[$bi]	= avg(@{$DNCAST{ELAPSED}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1563
		$DNCAST{MEDIAN_W}[$bi]		= median(@{$DNCAST{W}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1564
		$DNCAST{MEDIAN_W12}[$bi]	= median(@{$DNCAST{W12}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1565
		$DNCAST{MEDIAN_W34}[$bi]	= median(@{$DNCAST{W34}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1566
		$DNCAST{MAD_W}[$bi] 		= mad2($DNCAST{MEDIAN_W}[$bi],@{$DNCAST{W}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1567
		$DNCAST{N_SAMP}[$bi]		= @{$DNCAST{W}[$bi]};
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1568
	}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1569
	for ($ens=$LADCP_atbottom; $ens<=$lastGoodEns; $ens++) {	    
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1570
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1571
		$realLastGoodEns = $ens;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1572
		my(@bindepth) = calc_binDepths($ens);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1573
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1574
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1575
			next if ($bin<$outGrid_firstBin-1 || $bin>$outGrid_lastBin-1);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1576
			$min_depth = $bindepth[$bin] if ($bindepth[$bin] < $min_depth);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1577
			$max_depth = $bindepth[$bin] if ($bindepth[$bin] > $max_depth);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1578
			my($bi) = $bindepth[$bin]/$opt_o;
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1579
			push(@{$UPCAST{ENSEMBLE}[$bi]},$ens);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1580
			push(@{$UPCAST{ELAPSED}[$bi]},$CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1581
			push(@{$UPCAST{DEPTH}[$bi]},$bindepth[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1582
			push(@{$UPCAST{W}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1583
			push(@{$UPCAST{W12}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1584
			push(@{$UPCAST{W34}[$bi]},$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin]);
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1585
		}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1586
	}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1587
	for (my($bi)=0; $bi<=$#{$UPCAST{ENSEMBLE}}; $bi++) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1588
		$UPCAST{MEAN_DEPTH}[$bi]	= avg(@{$UPCAST{DEPTH}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1589
		$UPCAST{MEAN_ELAPSED}[$bi]	= avg(@{$UPCAST{ELAPSED}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1590
		$UPCAST{MEDIAN_W}[$bi]		= median(@{$UPCAST{W}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1591
		$UPCAST{MEDIAN_W12}[$bi]	= median(@{$UPCAST{W12}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1592
		$UPCAST{MEDIAN_W34}[$bi]	= median(@{$UPCAST{W34}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1593
		$UPCAST{MAD_W}[$bi] 		= mad2($UPCAST{MEDIAN_W}[$bi],@{$UPCAST{W}[$bi]});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1594
		$UPCAST{N_SAMP}[$bi]		= @{$UPCAST{W}[$bi]};
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1595
	}
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1596
} # if defined($opt_r)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1597
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1598
#--------------------------------------------
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1599
# Calculate and Output Bin-Averaged Resiudals
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1600
#--------------------------------------------
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1601
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1602
&antsAddParams('min_depth',$min_depth,'max_depth',$max_depth,						# plot range limits
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1603
			   'min_ens',$LADCP{ENSEMBLE}[$firstGoodEns]->{NUMBER},
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1604
			   'max_ens',$LADCP{ENSEMBLE}[$realLastGoodEns]->{NUMBER},
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1605
			   'min_elapsed',$LADCP{ENSEMBLE}[$firstGoodEns]->{CTD_ELAPSED},
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1606
			   'max_elapsed',$LADCP{ENSEMBLE}[$realLastGoodEns]->{CTD_ELAPSED});
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1607
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1608
if (@out_BR) {
31
d0ae3cb99021 DoMORE-2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 30
diff changeset
  1609
	progress("Binning residuals...");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1610
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1611
	local(@dc_bres,@uc_bres);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1612
	for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# downcast
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1613
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1614
		my(@bindepth) = calc_binDepths($ens);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1615
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1616
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1617
			push(@{$dc_bres[$bin]},
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1618
					$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1619
					- $DNCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1620
		}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1621
	}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1622
	for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) {					# upcast 
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1623
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1624
		my(@bindepth) = calc_binDepths($ens);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1625
		for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1626
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1627
			push(@{$uc_bres[$bin]},
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1628
					$LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin]
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1629
					- $UPCAST{MEDIAN_W}[$bindepth[$bin]/$opt_o]);
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1630
		}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1631
	}
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1632
	local(@dc_avg_bres,@uc_avg_bres,@dc_avg_bres_nsamp,@uc_avg_bres_nsamp);			# calc means/stddevs
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1633
	for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {		
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1634
		$dc_bres_nsamp[$bin] = @{$dc_bres[$bin]};
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1635
		if ($dc_bres_nsamp[$bin] > 0) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1636
			$dc_avg_bres[$bin] = avg(@{$dc_bres[$bin]}); 
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1637
			$dc_sig_bres[$bin] = stddev2($dc_avg_bres[$bin],@{$dc_bres[$bin]});
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1638
		} else {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1639
			$dc_avg_bres[$bin] = nan;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1640
			$dc_sig_bres[$bin] = nan;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1641
		}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1642
		$uc_bres_nsamp[$bin] = @{$uc_bres[$bin]};
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1643
		if ($uc_bres_nsamp[$bin] > 0) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1644
			$uc_avg_bres[$bin] = avg(@{$uc_bres[$bin]}); 
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1645
			$uc_sig_bres[$bin] = stddev2($uc_avg_bres[$bin],@{$uc_bres[$bin]});
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1646
		} else {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1647
			$uc_avg_bres[$bin] = nan;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1648
			$uc_sig_bres[$bin] = nan;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1649
		}
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1650
	}
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1651
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1652
	local($uc_bres_max_nsamp,$dc_bres_max_nsamp) = (0,0);							# calc rms in block of well-determined bins
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1653
	for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) {				# SKIP 1ST BIN!!!
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1654
		next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);				# skip bins not included in gridded output
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1655
		$dc_bres_max_nsamp = $dc_bres_nsamp[$bin]									# nsamp in best sampled bin
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1656
			if ($dc_bres_nsamp[$bin] > $dc_bres_max_nsamp);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1657
		$uc_bres_max_nsamp = $uc_bres_nsamp[$bin]
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1658
			if ($uc_bres_nsamp[$bin] > $uc_bres_max_nsamp);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1659
	}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1660
	my($dc_sumsq,$uc_sumsq,$dc_n,$uc_n) = (0,0,0,0);								# calc rms residual
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1661
	for (my($bin)=$LADCP_firstBin; $bin<=$LADCP_lastBin-1; $bin++) {				# SKIP 1ST BIN
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1662
		next if ($bin+1<$outGrid_firstBin || $bin+1>$outGrid_lastBin);				# skip bins not included in gridded output
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1663
		if ($dc_bres_nsamp[$bin] >= $dc_bres_max_nsamp/3) {							# skip bins with < 1/3 max(nsamp)
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1664
			$dc_sumsq += $dc_avg_bres[$bin]**2;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1665
			$dc_n++;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1666
		}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1667
		if ($uc_bres_nsamp[$bin] >= $uc_bres_max_nsamp/3) {
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1668
			$uc_sumsq += $uc_avg_bres[$bin]**2;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1669
			$uc_n++;
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1670
		}
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1671
	}
35
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1672
	local($dc_bres_rms) = ($dc_n > 0) ? sqrt($dc_sumsq/$dc_n) : nan;
54b8bb450e5f Version 1.2 finished. Out for testing to Jay Hooper.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
  1673
	local($uc_bres_rms) = ($uc_n > 0) ? sqrt($uc_sumsq/$uc_n) : nan;
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1674
	
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1675
	progress("\nWriting binned residuals to ");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1676
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1677
	my($saveParams) = $antsCurParams;
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1678
	@antsNewLayout = ('bin','dc_residual','dc_residual.sig','dc_residual.nsamp',
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1679
						   ,'uc_residual','uc_residual.sig','uc_residual.nsamp');
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1680
	&antsAddParams('BR_max_bin',max(scalar(@dc_bres),scalar(@uc_bres)));
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1681
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1682
	foreach my $of (@out_BR) {
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1683
	    progress("<$of> ");
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1684
		my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);						# plot_sub(out_file)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1685
		if (defined($arg)) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1686
			require "$WCALC/${sub}.pl";
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1687
			&{$sub}($arg);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1688
			next;
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1689
		}
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1690
	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
  1691
		open(STDOUT,$of) || error("$of: $!\n");
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1692
		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1693
		for (my($bin)=0; $bin<max(scalar(@dc_bres),scalar(@uc_bres)); $bin++) {
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1694
			&antsOut($bin+1,$dc_avg_bres[$bin],$dc_sig_bres[$bin],$dc_bres_nsamp[$bin],
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
  1695
							$uc_avg_bres[$bin],$uc_sig_bres[$bin],$uc_bres_nsamp[$bin]);
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1696
		}
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1697
	    &antsOut('EOF'); open(STDOUT,">&2");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1698
	}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1699
	$antsCurParams = $saveParams;
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1700
	progress("\n");
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1701
}
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1702
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1703
#--------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1704
# Calculate BT-referenced vertical-velocity profile
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1705
#--------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1706
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1707
if (defined($water_depth)) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1708
	progress("Calculating BT-referenced vertical velocities\n");
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1709
	calc_BTprof($firstGoodEns,$realLastGoodEns,$water_depth,$sig_water_depth);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1710
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1711
	my($sumSq) = my($n) = 0;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1712
	for (my($bi)=0; $bi<=$#{$BT{MEDIAN_W}}; $bi++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1713
		next unless defined($BT{MEDIAN_W}[$bi]);
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1714
		next unless ($BT{N_SAMP}[$bi]>=$opt_k && $DNCAST{N_SAMP}[$bi]>=$opt_k && $UPCAST{N_SAMP}[$bi]>=$opt_k);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1715
		$sumSq += ($BT{MEDIAN_W}[$bi] - $DNCAST{MEDIAN_W}[$bi]/2 - $UPCAST{MEDIAN_W}[$bi]/2)**2;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1716
		$n++;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1717
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1718
	if ($n > 0) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1719
		my($rms) = round(sqrt($sumSq/$n),0.001);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1720
		&antsAddParams('BT_rms_w_discrepancy',$rms);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1721
		progress("\t$rms m/s rms vertical-velocity discrepancy\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1722
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1723
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1724
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1725
#------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1726
# output all samples (-w)
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1727
#------------------------
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1728
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1729
# NB: residual field is calculated with respect to down-/upcast medians in -o-size bins
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1730
31
d0ae3cb99021 DoMORE-2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 30
diff changeset
  1731
if (@out_wsamp) {
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1732
	progress("Writing vertical-velocity data to ");
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1733
	@antsNewLayout = ('ensemble','bin','elapsed','depth','CTD_depth','downcast',
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1734
					  'w','w12','w34','residual','CTD_w','CTD_w_tt','LADCP_w','errvel',
16
29e867b3e070 whoosher version at beginning of FZ1
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 15
diff changeset
  1735
					  'correlation','echo_amplitude','Sv',
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
  1736
					  'pitch','roll','tilt','heading','3_beam','svel');
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1737
31
d0ae3cb99021 DoMORE-2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 30
diff changeset
  1738
	foreach my $of (@out_wsamp) {
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1739
	    progress("<$of> ");
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1740
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1741
		my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);								# plot_sub(out_file)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1742
		if (defined($arg)) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1743
			require "$WCALC/${sub}.pl";
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1744
			&{$sub}($arg);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1745
			next;
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1746
		}
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1747
			
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1748
	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
  1749
		open(STDOUT,$of) || error("$of: $!\n");
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1750
		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1751
	    
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1752
		for ($ens=$firstGoodEns; $ens<$LADCP_atbottom; $ens++) {						# downcast
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1753
		  next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1754
		  my(@bindepth) = calc_binDepths($ens);
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1755
		  for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1756
			  next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1757
			  my($bi) = $bindepth[$bin]/$opt_o;
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1758
			  &antsOut(
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1759
				  $LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1760
				  $CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1761
				  $bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},1,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1762
				  $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1763
				  $LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1764
				  $LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1765
				  $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $DNCAST{MEDIAN_W}[$bi],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1766
				  $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1767
				  $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1768
				  $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1769
				  $LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1770
				  median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}),
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1771
				  median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}),
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1772
				  $LADCP{ENSEMBLE}[$ens]->{SV}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1773
				  $LADCP{ENSEMBLE}[$ens]->{PITCH},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1774
				  $LADCP{ENSEMBLE}[$ens]->{ROLL},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1775
				  $LADCP{ENSEMBLE}[$ens]->{TILT},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1776
				  $LADCP{ENSEMBLE}[$ens]->{HEADING},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1777
				  (defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) +			  # only works for beam coords
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1778
				   defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) +
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1779
				   defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) +
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1780
				   defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1781
				  $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1782
			  );
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1783
		  } # for $bin
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1784
		} # for $ens
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1785
	  
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1786
		for ($ens=$LADCP_atbottom; $ens<=$realLastGoodEns; $ens++) {					  # upcast 
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1787
		  next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1788
		  my(@bindepth) = calc_binDepths($ens);
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1789
		  for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1790
			  next unless numberp($LADCP{ENSEMBLE}[$ens]->{W}[$bin]);
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1791
			  my($bi) = $bindepth[$bin]/$opt_o;
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1792
			  &antsOut(
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1793
				  $LADCP{ENSEMBLE}[$ens]->{NUMBER},$bin+1,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1794
				  $CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1795
				  $bindepth[$bin],$LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},0,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1796
				  $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1797
				  $LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W12}[$bin] : nan,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1798
				  $LADCP{BEAM_COORDINATES} ? $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W34}[$bin] : nan,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1799
				  $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_OCEAN_W}[$bin] - $UPCAST{MEDIAN_W}[$bi],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1800
				  $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1801
				  $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1802
				  $LADCP{ENSEMBLE}[$ens]->{SSCORRECTED_W}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1803
				  $LADCP{ENSEMBLE}[$ens]->{ERRVEL}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1804
				  median(@{$LADCP{ENSEMBLE}[$ens]->{CORRELATION}[$bin]}),
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1805
				  median(@{$LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin]}),
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1806
				  $LADCP{ENSEMBLE}[$ens]->{SV}[$bin],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1807
				  $LADCP{ENSEMBLE}[$ens]->{PITCH},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1808
				  $LADCP{ENSEMBLE}[$ens]->{ROLL},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1809
				  $LADCP{ENSEMBLE}[$ens]->{TILT},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1810
				  $LADCP{ENSEMBLE}[$ens]->{HEADING},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1811
				  (defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][0]) +			  # only works for beam coords
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1812
				   defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][1]) +
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1813
				   defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][2]) +
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1814
				   defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][3])) < 4 ? 1 : 0,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1815
				  $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1816
			  );
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1817
		  } # for $bin
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1818
		} # for $ens
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1819
	
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1820
	    &antsOut('EOF'); open(STDOUT,">&2");
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1821
	}
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1822
	progress("\n");
2
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1823
}
a077ea2a9f36 post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
  1824
	
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1825
#----------------------------
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1826
# Output depth-binned profile
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1827
#----------------------------
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1828
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1829
if (@out_profile) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1830
	progress("Writing vertical-velocity profiles to ");
37
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1831
	@antsNewLayout = ('depth','hab','dc_depth','dc_elapsed','dc_w','dc_w.mad','dc_w.nsamp','dc_w12','dc_w34',
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1832
							  		'uc_depth','uc_elapsed','uc_w','uc_w.mad','uc_w.nsamp','uc_w12','uc_w34',
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1833
	                          		'BT_w','BT_w.mad','BT_w.nsamp');
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1834
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1835
	foreach my $of (@out_profile) {
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1836
	    progress("<$of> ");
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
  1837
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1838
		my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);						# plot_sub(out_file)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1839
		if (defined($arg)) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1840
			require "$WCALC/${sub}.pl";
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1841
			&{$sub}($arg);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
  1842
			next;
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
  1843
		}
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
  1844
			
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
  1845
	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);								# pipe or file output
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
  1846
		open(STDOUT,$of) || error("$of: $!\n");
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1847
		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1848
	    
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1849
		for (my($bi)=0; $bi<=max($#{$DNCAST{ENSEMBLE}},$#{$UPCAST{ENSEMBLE}},$#{$BT{NSAMP}}); $bi++) {
37
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1850
			&antsOut(($bi+0.5)*$opt_o,												# nominal depth
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1851
					 defined($water_depth)?$water_depth-($bi+0.5)*$opt_o:nan,		# nominal hab
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1852
					 $DNCAST{MEAN_DEPTH}[$bi],$DNCAST{MEAN_ELAPSED}[$bi],			# dc data
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1853
					 $DNCAST{N_SAMP}[$bi]>=$opt_k?$DNCAST{MEDIAN_W}[$bi]:nan,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1854
					 $DNCAST{MAD_W}[$bi],$DNCAST{N_SAMP}[$bi],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1855
					 $DNCAST{MEDIAN_W12}[$bi],$DNCAST{MEDIAN_W34}[$bi],
37
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1856
					 $UPCAST{MEAN_DEPTH}[$bi],$UPCAST{MEAN_ELAPSED}[$bi],			# uc data
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1857
					 $UPCAST{N_SAMP}[$bi]>=$opt_k?$UPCAST{MEDIAN_W}[$bi]:nan,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1858
					 $UPCAST{MAD_W}[$bi],$UPCAST{N_SAMP}[$bi],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1859
					 $UPCAST{MEDIAN_W12}[$bi],$UPCAST{MEDIAN_W34}[$bi],
37
2c4479351544 V1.2beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 35
diff changeset
  1860
					 $BT{N_SAMP}[$bi]>=$opt_k?$BT{MEDIAN_W}[$bi]:nan,				# BT data
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1861
					 $BT{MAD_W}[$bi],$BT{N_SAMP}[$bi]
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1862
			);
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1863
		}
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1864
	    &antsOut('EOF'); open(STDOUT,">&2");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1865
	}
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1866
	progress("\n");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1867
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1868
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1869
#--------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1870
# write time-series output if requested
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1871
#--------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1872
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1873
if (@out_timeseries) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1874
	progress("Writing time-series data to ");
23
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 21
diff changeset
  1875
	@antsNewLayout = ('ensemble','elapsed','downcast',
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1876
					  'depth','xducer_sound_speed','pitch','gimbal_pitch','roll','tilt','heading',
13
2788bf1bf1de after DIMES US5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 12
diff changeset
  1877
					  'CTD_w','CTD_w_tt','LADCP_reflr_w','LADCP_reflr_w.sig',
3
9c021fdea1ff Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 2
diff changeset
  1878
					  'reflr_ocean_w');
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1879
					  
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1880
	foreach my $of (@out_timeseries) {
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1881
	    progress("<$of> ");
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1882
		my($sub,$arg) = ($of =~ /^([^\(]+)\(([^\)]+)\)$/);						# plot_sub(out_file)
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1883
		if (defined($arg)) {
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1884
			require "$WCALC/${sub}.pl";
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1885
			&{$sub}($arg);
30
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1886
			next;
7fb67e771d85 LWplots expunged
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
  1887
		}
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1888
	    $of = ">$of" unless ($of =~ /^$|^\s*\|/);
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
  1889
		open(STDOUT,$of) || error("$of: $!\n");
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 25
diff changeset
  1890
		undef($antsActiveHeader) unless ($ANTS_TOOLS_AVAILABLE);
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1891
		 
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1892
		for ($ens=$firstGoodEns; $ens<=$realLastGoodEns; $ens++) {
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1893
			next unless defined($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1894
			my($reflr_oc_w) = defined($LADCP{ENSEMBLE}[$ens]->{REFLR_W})
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1895
							? $LADCP{ENSEMBLE}[$ens]->{REFLR_W} - $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1896
							: undef;
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1897
			&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1898
					 $CTD{ELAPSED}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1899
					 ($ens < $LADCP_atbottom) ? 1 : 0,
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1900
					 $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1901
					 $CTD{SVEL}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1902
					 $LADCP{ENSEMBLE}[$ens]->{PITCH},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1903
					 $LADCP{ENSEMBLE}[$ens]->{GIMBAL_PITCH},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1904
					 $LADCP{ENSEMBLE}[$ens]->{ROLL},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1905
					 $LADCP{ENSEMBLE}[$ens]->{TILT},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1906
					 $LADCP{ENSEMBLE}[$ens]->{HEADING},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1907
					 $CTD{W}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1908
					 $CTD{W_tt}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}],
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1909
					 $LADCP{ENSEMBLE}[$ens]->{REFLR_W},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1910
					 $LADCP{ENSEMBLE}[$ens]->{REFLR_W_STDDEV},
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1911
					 $reflr_oc_w);
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1912
		}
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1913
	
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1914
	    &antsOut('EOF'); open(STDOUT,">&2");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1915
	}
25
bd38f8bfb8e6 first step at re-designing plotting system
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 23
diff changeset
  1916
	progress("\n");
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1917
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
  1918
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1919
system("{ ./LADCP_w.PostProcess $out_basename $RUN $data_dir $plot_dir $log_dir; }&")
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
  1920
	if (-x 'LADCP_w.PostProcess');
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1921
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
  1922
exit(0);