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