author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Sun, 05 Apr 2015 19:15:41 -0400 | |
changeset 19 | 1d49806c9f75 |
parent 13 | 2788bf1bf1de |
child 49 | 5006e9158207 |
permissions | -rw-r--r-- |
0 | 1 |
#====================================================================== |
2 | 2 |
# T I M E _ S E R I E S . P L |
0 | 3 |
# doc: Sun May 23 16:40:53 2010 |
13 | 4 |
# dlm: Wed Apr 17 17:05:16 2013 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
13 | 6 |
# uE-Info: 20 63 NIL 0 0 72 2 2 4 NIL ofnI |
0 | 7 |
#====================================================================== |
8 |
||
9 |
# HISTORY: |
|
10 |
# May 23, 2010: - created from [perl-tools/RDI_Utils.pl] |
|
11 |
# Oct 20, 2010: - disabled max_gap profile-restarting code |
|
12 |
# Dec 17, 2010: - re-added {DEPTH} field to ensembles |
|
13 |
# Dec 18, 2010: - max gap re-enabled |
|
14 |
# Dec 20, 2010: - cosmetics |
|
2 | 15 |
# Jul 2, 2011: - tightened gap-detection code |
16 |
# Jul 4, 2011: - added support for $skip_ens |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
17 |
# Oct 11, 2011: - BUG: {DEPTH} had not been set at start of profile |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
18 |
# Oct 12, 2011: - re-worked ref_lr_w() |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
19 |
# - stopped depth integration across gaps >= 5s |
13 | 20 |
# Apr 17, 2013: - improved gap message (added ensemble range) |
0 | 21 |
|
22 |
# NOTES: |
|
23 |
# - resulting DEPTH field based on integrated w without any sound speed correction |
|
24 |
# - single-ping ensembles assumed, i.e. no percent-good tests applied |
|
25 |
# - specified bin numbers are 1-relative |
|
26 |
||
27 |
sub ref_lr_w($$$$) # calc ref-layer vert vels |
|
28 |
{ |
|
29 |
my($dta,$ens,$rl_b0,$rl_b1) = @_; |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
30 |
my(@w); |
0 | 31 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
32 |
for (my($bin)=$rl_b0-1; $bin<=$rl_b1-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
|
33 |
push(@w,$dta->{ENSEMBLE}[$ens]->{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
|
34 |
if defined($dta->{ENSEMBLE}[$ens]->{W}[$bin]); |
0 | 35 |
} |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
36 |
return unless (@w); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
37 |
$dta->{ENSEMBLE}[$ens]->{REFLR_W} = avg(@w); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
38 |
$dta->{ENSEMBLE}[$ens]->{REFLR_W_STDDEV} = stddev2($dta->{ENSEMBLE}[$ens]->{REFLR_W},@w); |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
39 |
$dta->{ENSEMBLE}[$ens]->{REFLR_W_NSAMP} = @w; |
0 | 40 |
} |
41 |
||
42 |
#====================================================================== |
|
43 |
# ($firstgood,$lastgood,$atbottom,$w_gap_time) = |
|
2 | 44 |
# calcLADCPts($dta,$skip_ens,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap); |
0 | 45 |
#====================================================================== |
46 |
||
47 |
sub calcLADCPts($$$$) |
|
48 |
{ |
|
2 | 49 |
my($dta,$skip_ens,$rl_b0,$rl_b1,$max_gap) = @_; |
0 | 50 |
my($firstgood,$lastgood,$atbottom,$w_gap_time,$max_depth); |
51 |
||
2 | 52 |
for (my($depth)=0,my($e)=$skip_ens; $e<=$#{$dta->{ENSEMBLE}}; $e++) { |
0 | 53 |
|
54 |
ref_lr_w($dta,$e,$rl_b0,$rl_b1); |
|
55 |
||
56 |
if (defined($firstgood)) { |
|
57 |
$dta->{ENSEMBLE}[$e]->{ELAPSED} = # time since start |
|
58 |
$dta->{ENSEMBLE}[$e]->{UNIX_TIME} - |
|
59 |
$dta->{ENSEMBLE}[$firstgood]->{UNIX_TIME}; |
|
60 |
} else { |
|
61 |
if (defined($dta->{ENSEMBLE}[$e]->{REFLR_W})) { # start of prof. |
|
62 |
$firstgood = $lastgood = $e; |
|
63 |
$dta->{ENSEMBLE}[$e]->{ELAPSED} = 0; |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
64 |
$dta->{ENSEMBLE}[$e]->{DEPTH} = $depth; |
0 | 65 |
} |
66 |
next; |
|
67 |
} |
|
68 |
||
69 |
unless (defined($dta->{ENSEMBLE}[$e]->{REFLR_W})) { # gap |
|
70 |
$w_gap_time += $dta->{ENSEMBLE}[$e]->{UNIX_TIME} - |
|
71 |
$dta->{ENSEMBLE}[$e-1]->{UNIX_TIME}; |
|
72 |
next; |
|
73 |
} |
|
74 |
||
75 |
my($dt) = $dta->{ENSEMBLE}[$e]->{UNIX_TIME} - # time step since |
|
76 |
$dta->{ENSEMBLE}[$lastgood]->{UNIX_TIME}; # ... last good ens |
|
77 |
||
78 |
if ($dt > $max_gap) { |
|
2 | 79 |
if ($max_depth>50 && $depth<0.1*$max_depth) { |
80 |
warning(1,"long gap (%ds) near end of profile --- terminated at ensemble #$dta->{ENSEMBLE}[$e]->{NUMBER}\n",$dt); |
|
0 | 81 |
last; |
82 |
} |
|
2 | 83 |
if ($depth < 10) { |
84 |
warning(1,"long gap (%ds) near beginning of profile --- restarted at ensemble #$dta->{ENSEMBLE}[$e]->{NUMBER}\n",$dt); |
|
85 |
$firstgood = $lastgood = $e; |
|
86 |
undef($atbottom); undef($max_depth); |
|
87 |
$depth = 0; |
|
88 |
$dta->{ENSEMBLE}[$e]->{ELAPSED} = 0; |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
2
diff
changeset
|
89 |
$dta->{ENSEMBLE}[$e]->{DEPTH} = $depth; |
2 | 90 |
$w_gap_time = 0; |
91 |
next; |
|
92 |
} |
|
93 |
if ($dta->{ENSEMBLE}[$e]->{ELAPSED} < 200) { |
|
13 | 94 |
warning(1,"long gap (%ds) at ensembles #$dta->{ENSEMBLE}[$lastgood]->{NUMBER}-$dta->{ENSEMBLE}[$e]->{NUMBER}, %ds into the profile\n", |
2 | 95 |
$dt,$dta->{ENSEMBLE}[$e]->{ELAPSED}); |
96 |
} else { |
|
13 | 97 |
warning(1,"long gap (%ds) at ensembles #$dta->{ENSEMBLE}[$lastgood]->{NUMBER}-$dta->{ENSEMBLE}[$e]->{NUMBER}, %.1fmin into the profile\n", |
2 | 98 |
$dt,$dta->{ENSEMBLE}[$e]->{ELAPSED}/60); |
99 |
} |
|
0 | 100 |
} |
101 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
102 |
$depth += $dta->{ENSEMBLE}[$lastgood]->{REFLR_W} * $dt # integrate |
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
103 |
if ($dt < 5); |
0 | 104 |
$dta->{ENSEMBLE}[$e]->{DEPTH} = $depth; |
105 |
||
106 |
$atbottom = $e, $max_depth = $depth if ($depth > $max_depth); |
|
107 |
$lastgood = $e; |
|
108 |
} |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
109 |
|
0 | 110 |
return ($firstgood,$lastgood,$atbottom,$w_gap_time); |
111 |
} |
|
112 |
||
113 |
1; |