author | A.M. Thurnherr <athurnherr@yahoo.com> |
Thu, 27 Oct 2011 10:29:18 -0400 | |
changeset 5 | 509cc9966b68 |
parent 4 | e681262d0fd7 |
child 13 | 2788bf1bf1de |
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 |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
4 |
# dlm: Wed Oct 12 12:36:46 2011 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
6 |
# uE-Info: 102 23 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 |
0 | 20 |
|
21 |
# NOTES: |
|
22 |
# - resulting DEPTH field based on integrated w without any sound speed correction |
|
23 |
# - single-ping ensembles assumed, i.e. no percent-good tests applied |
|
24 |
# - specified bin numbers are 1-relative |
|
25 |
||
26 |
sub ref_lr_w($$$$) # calc ref-layer vert vels |
|
27 |
{ |
|
28 |
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
|
29 |
my(@w); |
0 | 30 |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
31 |
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
|
32 |
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
|
33 |
if defined($dta->{ENSEMBLE}[$ens]->{W}[$bin]); |
0 | 34 |
} |
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
35 |
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
|
36 |
$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
|
37 |
$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
|
38 |
$dta->{ENSEMBLE}[$ens]->{REFLR_W_NSAMP} = @w; |
0 | 39 |
} |
40 |
||
41 |
#====================================================================== |
|
42 |
# ($firstgood,$lastgood,$atbottom,$w_gap_time) = |
|
2 | 43 |
# calcLADCPts($dta,$skip_ens,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap); |
0 | 44 |
#====================================================================== |
45 |
||
46 |
sub calcLADCPts($$$$) |
|
47 |
{ |
|
2 | 48 |
my($dta,$skip_ens,$rl_b0,$rl_b1,$max_gap) = @_; |
0 | 49 |
my($firstgood,$lastgood,$atbottom,$w_gap_time,$max_depth); |
50 |
||
2 | 51 |
for (my($depth)=0,my($e)=$skip_ens; $e<=$#{$dta->{ENSEMBLE}}; $e++) { |
0 | 52 |
|
53 |
ref_lr_w($dta,$e,$rl_b0,$rl_b1); |
|
54 |
||
55 |
if (defined($firstgood)) { |
|
56 |
$dta->{ENSEMBLE}[$e]->{ELAPSED} = # time since start |
|
57 |
$dta->{ENSEMBLE}[$e]->{UNIX_TIME} - |
|
58 |
$dta->{ENSEMBLE}[$firstgood]->{UNIX_TIME}; |
|
59 |
} else { |
|
60 |
if (defined($dta->{ENSEMBLE}[$e]->{REFLR_W})) { # start of prof. |
|
61 |
$firstgood = $lastgood = $e; |
|
62 |
$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
|
63 |
$dta->{ENSEMBLE}[$e]->{DEPTH} = $depth; |
0 | 64 |
} |
65 |
next; |
|
66 |
} |
|
67 |
||
68 |
unless (defined($dta->{ENSEMBLE}[$e]->{REFLR_W})) { # gap |
|
69 |
$w_gap_time += $dta->{ENSEMBLE}[$e]->{UNIX_TIME} - |
|
70 |
$dta->{ENSEMBLE}[$e-1]->{UNIX_TIME}; |
|
71 |
next; |
|
72 |
} |
|
73 |
||
74 |
my($dt) = $dta->{ENSEMBLE}[$e]->{UNIX_TIME} - # time step since |
|
75 |
$dta->{ENSEMBLE}[$lastgood]->{UNIX_TIME}; # ... last good ens |
|
76 |
||
77 |
if ($dt > $max_gap) { |
|
2 | 78 |
if ($max_depth>50 && $depth<0.1*$max_depth) { |
79 |
warning(1,"long gap (%ds) near end of profile --- terminated at ensemble #$dta->{ENSEMBLE}[$e]->{NUMBER}\n",$dt); |
|
0 | 80 |
last; |
81 |
} |
|
2 | 82 |
if ($depth < 10) { |
83 |
warning(1,"long gap (%ds) near beginning of profile --- restarted at ensemble #$dta->{ENSEMBLE}[$e]->{NUMBER}\n",$dt); |
|
84 |
$firstgood = $lastgood = $e; |
|
85 |
undef($atbottom); undef($max_depth); |
|
86 |
$depth = 0; |
|
87 |
$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
|
88 |
$dta->{ENSEMBLE}[$e]->{DEPTH} = $depth; |
2 | 89 |
$w_gap_time = 0; |
90 |
next; |
|
91 |
} |
|
92 |
if ($dta->{ENSEMBLE}[$e]->{ELAPSED} < 200) { |
|
93 |
warning(1,"long gap (%ds) at ensemble #$dta->{ENSEMBLE}[$e]->{NUMBER}, %ds into the profile\n", |
|
94 |
$dt,$dta->{ENSEMBLE}[$e]->{ELAPSED}); |
|
95 |
} else { |
|
96 |
warning(1,"long gap (%ds) at ensemble #$dta->{ENSEMBLE}[$e]->{NUMBER}, %.1fmin into the profile\n", |
|
97 |
$dt,$dta->{ENSEMBLE}[$e]->{ELAPSED}/60); |
|
98 |
} |
|
0 | 99 |
} |
100 |
||
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
101 |
$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
|
102 |
if ($dt < 5); |
0 | 103 |
$dta->{ENSEMBLE}[$e]->{DEPTH} = $depth; |
104 |
||
105 |
$atbottom = $e, $max_depth = $depth if ($depth > $max_depth); |
|
106 |
$lastgood = $e; |
|
107 |
} |
|
4
e681262d0fd7
yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
108 |
|
0 | 109 |
return ($firstgood,$lastgood,$atbottom,$w_gap_time); |
110 |
} |
|
111 |
||
112 |
1; |