1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 #====================================================================== |
2 #====================================================================== |
3 # M K P R O F I L E |
3 # M K P R O F I L E |
4 # doc: Sun Jan 19 18:55:26 2003 |
4 # doc: Sun Jan 19 18:55:26 2003 |
5 # dlm: Wed Jan 5 01:05:50 2011 |
5 # dlm: Wed Jun 22 05:39:48 2011 |
6 # (c) 2003 A.M. Thurnherr |
6 # (c) 2003 A.M. Thurnherr |
7 # uE-Info: 233 47 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 245 0 NIL 0 0 72 2 2 4 NIL ofnI |
8 #====================================================================== |
8 #====================================================================== |
9 |
9 |
10 # Make an LADCP Profile by Integrating W (similar to Firing's scan*). |
10 # Make an LADCP Profile by Integrating W (similar to Firing's scan*). |
11 |
11 |
12 # HISTORY: |
12 # HISTORY: |
70 # - NaN => nan |
70 # - NaN => nan |
71 # Dec 8, 2010: - added zmax/zend labels to output |
71 # Dec 8, 2010: - added zmax/zend labels to output |
72 # Dec 10, 2010: - made mkProfile exit with status 0 if no good ens found but -Q is set |
72 # Dec 10, 2010: - made mkProfile exit with status 0 if no good ens found but -Q is set |
73 # Dec 19, 2010: - finally made -A default and activated output file |
73 # Dec 19, 2010: - finally made -A default and activated output file |
74 # Jan 5, 2011: - made no-good-ensembles found test much more robust |
74 # Jan 5, 2011: - made no-good-ensembles found test much more robust |
|
75 # Jun 22, 2011: - added bandwith/power warnings |
|
76 # - added ping-interval calculation |
|
77 # - BUG: post-recovery rotations were always zero |
75 |
78 |
76 # NOTES: |
79 # NOTES: |
77 # - the battery values are based on transmission voltages (different |
80 # - the battery values are based on transmission voltages (different |
78 # from battery voltages) and reported without units (raw 8-bit a2d |
81 # from battery voltages) and reported without units (raw 8-bit a2d |
79 # values) |
82 # values) |
142 if ($dta{BEAM_COORDINATES}) { # coords used |
145 if ($dta{BEAM_COORDINATES}) { # coords used |
143 $beamCoords = 1; |
146 $beamCoords = 1; |
144 } elsif (!$dta{EARTH_COORDINATES}) { |
147 } elsif (!$dta{EARTH_COORDINATES}) { |
145 die("$ARGV[0]: only beam and earth coordinates implemented so far\n"); |
148 die("$ARGV[0]: only beam and earth coordinates implemented so far\n"); |
146 } |
149 } |
|
150 |
147 if (defined($opt_M)) { # magnetic declination |
151 if (defined($opt_M)) { # magnetic declination |
148 $dta{HEADING_BIAS} = -1*$opt_M; |
152 $dta{HEADING_BIAS} = -1*$opt_M; |
149 } else { |
153 } else { |
150 $dta{HEADING_BIAS} = 0; |
154 $dta{HEADING_BIAS} = 0; |
151 } |
155 } |
215 elsif ($lon =~ m{W$}) { $eo = -deg_to_dec($`); } |
219 elsif ($lon =~ m{W$}) { $eo = -deg_to_dec($`); } |
216 else { $eo = $lon; } |
220 else { $eo = $lon; } |
217 |
221 |
218 return ($sa,$so,$ea,$eo); |
222 return ($sa,$so,$ea,$eo); |
219 } |
223 } |
|
224 |
|
225 #====================================================================== |
|
226 # Step 0: Check data & Calculate Ping Rates |
|
227 #====================================================================== |
|
228 |
|
229 unless ($dta{NARROW_BANDWIDTH}) { |
|
230 print(STDERR "WARNING: $0 WIDE BANDWIDTH!\n"); |
|
231 } |
|
232 |
|
233 unless ($dta{TRANSMIT_POWER_HIGH}) { |
|
234 print(STDERR "WARNING: $0 LOW TRANSMIT POWER!\n"); |
|
235 } |
|
236 |
|
237 printf(STDERR "# of ensembles : %d\n",scalar(@{$dta{ENSEMBLE}})); |
|
238 |
|
239 my($sdt1,$sdt2,$ndt); |
|
240 my($mindt1) = my($mindt2) = 9e99; |
|
241 my($maxdt1) = my($maxdt2) = 0; |
|
242 for (my($e)=2; $e<=$#{$dta{ENSEMBLE}}; $e+=2,$ndt++) { |
|
243 my($dt1) = $dta{ENSEMBLE}[$e-1]->{UNIX_TIME} - $dta{ENSEMBLE}[$e-2]->{UNIX_TIME}; |
|
244 my($dt2) = $dta{ENSEMBLE}[$e-0]->{UNIX_TIME} - $dta{ENSEMBLE}[$e-1]->{UNIX_TIME}; |
|
245 $mindt1 = $dt1 if ($dt1 < $mindt1); |
|
246 $mindt2 = $dt2 if ($dt2 < $mindt2); |
|
247 $maxdt1 = $dt1 if ($dt1 > $maxdt1); |
|
248 $maxdt2 = $dt2 if ($dt2 > $maxdt2); |
|
249 $sdt1 += $dt1; $sdt2 += $dt2; |
|
250 } |
|
251 |
|
252 printf(STDERR "Ping intervals : %.1fs/%.1fs (%.1fs-%.1fs/%.1fs-%.1fs)\n", |
|
253 $sdt1/$ndt,$sdt2/$ndt,$mindt1,$maxdt1,$mindt2,$maxdt2); |
220 |
254 |
221 #====================================================================== |
255 #====================================================================== |
222 # Step 1: Integrate w & determine water depth |
256 # Step 1: Integrate w & determine water depth |
223 #====================================================================== |
257 #====================================================================== |
224 |
258 |
621 $uprot += $dta{ENSEMBLE}[$e]->{ROTATION}; |
655 $uprot += $dta{ENSEMBLE}[$e]->{ROTATION}; |
622 $rotrms += $dta{ENSEMBLE}[$e]->{ROTATION}**2; |
656 $rotrms += $dta{ENSEMBLE}[$e]->{ROTATION}**2; |
623 } |
657 } |
624 $upprrms = $prrms - $dnprrms; |
658 $upprrms = $prrms - $dnprrms; |
625 |
659 |
626 for (; $e<=$#{$dta->{ENSEMBLE}}; $e++) { # post-recovery |
660 for (; $e<=$#{$dta{ENSEMBLE}}; $e++) { # post-recovery |
627 $postrot += rot($e); |
661 $postrot += rot($e); |
628 } |
662 } |
629 |
663 |
630 $prerot /= 360; # rotations, not degrees |
664 $prerot /= 360; # rotations, not degrees |
631 $dnrot /= 360; |
665 $dnrot /= 360; |
640 |
674 |
641 #====================================================================== |
675 #====================================================================== |
642 # PRODUCE OUTPUT |
676 # PRODUCE OUTPUT |
643 #====================================================================== |
677 #====================================================================== |
644 |
678 |
645 printf(STDERR "# of ensembles : %d\n",scalar(@{$dta{ENSEMBLE}})); |
|
646 printf(STDERR "Start of cast : %s (#%5d) at %6.1fm\n", |
679 printf(STDERR "Start of cast : %s (#%5d) at %6.1fm\n", |
647 $dta{ENSEMBLE}[$firstgood]->{TIME}, |
680 $dta{ENSEMBLE}[$firstgood]->{TIME}, |
648 $dta{ENSEMBLE}[$firstgood]->{NUMBER}, |
681 $dta{ENSEMBLE}[$firstgood]->{NUMBER}, |
649 $dta{ENSEMBLE}[$firstgood]->{DEPTH}); |
682 $dta{ENSEMBLE}[$firstgood]->{DEPTH}); |
650 printf(STDERR "Bottom of cast (zmax): %s (#%5d) at %6.1fm\n", |
683 printf(STDERR "Bottom of cast (zmax): %s (#%5d) at %6.1fm\n", |