1 #====================================================================== |
1 #====================================================================== |
2 # R D I _ U T I L S . P L |
2 # R D I _ U T I L S . P L |
3 # doc: Wed Feb 12 10:21:32 2003 |
3 # doc: Wed Feb 12 10:21:32 2003 |
4 # dlm: Thu May 12 11:02:26 2011 |
4 # dlm: Wed Sep 21 18:48:23 2011 |
5 # (c) 2003 A.M. Thurnherr |
5 # (c) 2003 A.M. Thurnherr |
6 # uE-Info: 304 3 NIL 0 0 72 2 2 4 NIL ofnI |
6 # uE-Info: 378 0 NIL 0 0 72 2 2 4 NIL ofnI |
7 #====================================================================== |
7 #====================================================================== |
8 |
8 |
9 # miscellaneous RDI-specific utilities |
9 # miscellaneous RDI-specific utilities |
10 |
10 |
11 # History: |
11 # History: |
36 # Dec 8, 2010: - changed missing w warning to happen only if gap is longer than 15s |
36 # Dec 8, 2010: - changed missing w warning to happen only if gap is longer than 15s |
37 # Dec 10, 2010: - beautified gap warning |
37 # Dec 10, 2010: - beautified gap warning |
38 # Dec 16, 2010: - BUG: gaps at end caused mk_prof to throw away profile |
38 # Dec 16, 2010: - BUG: gaps at end caused mk_prof to throw away profile |
39 # May 12, 2011: - added code to skip ensembles with built-in-test errors in mk_prof() |
39 # May 12, 2011: - added code to skip ensembles with built-in-test errors in mk_prof() |
40 # - immediately disabled this code becasue it does appear to make matters worse |
40 # - immediately disabled this code becasue it does appear to make matters worse |
|
41 # Sep 21, 2011: - added calculation of RMS heave acceleration |
41 |
42 |
42 use strict; |
43 use strict; |
43 |
44 |
44 #====================================================================== |
45 #====================================================================== |
45 # fake_BT_RANGE(dta ptr) |
46 # fake_BT_RANGE(dta ptr) |
293 |
294 |
294 sub mk_prof($$$$$$$$) # make profile |
295 sub mk_prof($$$$$$$$) # make profile |
295 { |
296 { |
296 my($dta,$check,$filter,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap) = @_; |
297 my($dta,$check,$filter,$lr_b0,$lr_b1,$min_corr,$max_e,$max_gap) = @_; |
297 my($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz); |
298 my($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz); |
|
299 my($rms_heave_accel_ssq,$rms_heave_accel_nsamp); |
298 |
300 |
299 for (my($z)=0,my($e)=0; $e<=$#{$dta->{ENSEMBLE}}; $e++) { |
301 for (my($z)=0,my($e)=0; $e<=$#{$dta->{ENSEMBLE}}; $e++) { |
300 checkEnsemble($dta,$e) if ($check); |
302 checkEnsemble($dta,$e) if ($check); |
301 ### The following line of code, which can only have an effect if check is disabled, |
303 ### The following line of code, which can only have an effect if check is disabled, |
302 ### seems reasonable but has been found to make matters worse with one particular |
304 ### seems reasonable but has been found to make matters worse with one particular |
344 $firstgood = $lastgood = $e; |
346 $firstgood = $lastgood = $e; |
345 $dta->{ENSEMBLE}[$e]->{ELAPSED_TIME} = 0; |
347 $dta->{ENSEMBLE}[$e]->{ELAPSED_TIME} = 0; |
346 $z = $zErr = $maxz = 0; |
348 $z = $zErr = $maxz = 0; |
347 $dta->{ENSEMBLE}[$e]->{DEPTH} = $dta->{ENSEMBLE}[$e]->{DEPTH_ERR} = 0; |
349 $dta->{ENSEMBLE}[$e]->{DEPTH} = $dta->{ENSEMBLE}[$e]->{DEPTH_ERR} = 0; |
348 $w_gap_time = 0; |
350 $w_gap_time = 0; |
|
351 $rms_heave_accel_ssq = $rms_heave_accel_nsamp = 0; |
349 next; |
352 next; |
350 } |
353 } |
351 |
354 |
352 #----------------------------------- |
355 #----------------------------------- |
353 # The current ensemble has a valid w |
356 # The current ensemble has a valid w |
354 #----------------------------------- |
357 #----------------------------------- |
355 |
358 |
356 if ($dt < 5) { |
359 if ($dt < 5) { # no or short gap |
357 $z += $dta->{ENSEMBLE}[$lastgood]->{W} * $dt; # integrate |
360 $z += $dta->{ENSEMBLE}[$lastgood]->{W} * $dt; # integrate w to get depth |
358 $zErr += ($dta->{ENSEMBLE}[$lastgood]->{W_ERR} * $dt)**2; |
361 $zErr += ($dta->{ENSEMBLE}[$lastgood]->{W_ERR} * $dt)**2; |
|
362 $rms_heave_accel_ssq += (($dta->{ENSEMBLE}[$e]->{W}-$dta->{ENSEMBLE}[$lastgood]->{W})/$dt)**2; |
|
363 $rms_heave_accel_nsamp++; |
359 } elsif ($dt > 15) { |
364 } elsif ($dt > 15) { |
360 printf(STDERR "WARNING: long-ish w gap (dt=%.1fs)\n",$dt); |
365 printf(STDERR "WARNING: long-ish w gap (dt=%.1fs)\n",$dt); |
361 } |
366 } |
362 |
367 |
363 $dta->{ENSEMBLE}[$e]->{DEPTH} = $z; |
368 $dta->{ENSEMBLE}[$e]->{DEPTH} = $z; |
368 $lastgood = $e; |
373 $lastgood = $e; |
369 } |
374 } |
370 |
375 |
371 filterEnsembleStats() if defined($filter); |
376 filterEnsembleStats() if defined($filter); |
372 |
377 |
373 return ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz); |
378 return ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz,sqrt($rms_heave_accel_ssq/$rms_heave_accel_nsamp)); |
374 } |
379 } |
375 |
380 |
376 #---------------------------------------------------------------------- |
381 #---------------------------------------------------------------------- |
377 # (true|false) = numberp(var) |
382 # (true|false) = numberp(var) |
378 #---------------------------------------------------------------------- |
383 #---------------------------------------------------------------------- |