mkProfile
changeset 3 f3c9dcbbdd68
parent 0 229a0d72d2ab
child 4 7e43b24080af
equal deleted inserted replaced
2:065ea9ce12fc 3:f3c9dcbbdd68
     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: Sun May 23 16:34:02 2010
     5 #                    dlm: Fri Dec 10 14:42:49 2010
     6 #                    (c) 2003 A.M. Thurnherr
     6 #                    (c) 2003 A.M. Thurnherr
     7 #                    uE-Info: 788 36 NIL 0 0 72 2 2 4 NIL ofnI
     7 #                    uE-Info: 229 28 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:
    66 #	Mar 18, 2009: - BUG: pitch/roll calculation had typo
    66 #	Mar 18, 2009: - BUG: pitch/roll calculation had typo
    67 #				  - calc pitch/roll separately for down-/upcasts
    67 #				  - calc pitch/roll separately for down-/upcasts
    68 #				  - removed approximations in pitch/roll calcs
    68 #				  - removed approximations in pitch/roll calcs
    69 #	Jul 30, 2009: - typo '<' removed from output
    69 #	Jul 30, 2009: - typo '<' removed from output
    70 #				  - NaN => nan
    70 #				  - NaN => nan
       
    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
    71 
    73 
    72 # NOTES:
    74 # NOTES:
    73 #	- the battery values are based on transmission voltages (different
    75 #	- the battery values are based on transmission voltages (different
    74 #	  from battery voltages) and reported without units (raw 8-bit a2d
    76 #	  from battery voltages) and reported without units (raw 8-bit a2d
    75 #	  values)
    77 #	  values)
   222 #======================================================================
   224 #======================================================================
   223 
   225 
   224 ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz) =
   226 ($firstgood,$lastgood,$atbottom,$w_gap_time,$zErr,$maxz) =
   225 	mk_prof(\%dta,!$opt_s,$opt_F,$minb,$maxb,$opt_c,$opt_e,$opt_m);
   227 	mk_prof(\%dta,!$opt_s,$opt_F,$minb,$maxb,$opt_c,$opt_e,$opt_m);
   226 
   228 
   227 die("$ARGV[0]: no good ensembles found\n")
   229 unless (defined($firstgood)) {
   228 	unless defined($firstgood);
   230 	if ($opt_Q) {
       
   231 		print(STDERR "$ARGV[0]: no good ensembles found\n");
       
   232 		exit(0);
       
   233     } else {
       
   234 		die("$ARGV[0]: no good ensembles found\n");
       
   235 	}
       
   236 }
   229 
   237 
   230 if (defined($opt_B)) {										# scale Z
   238 if (defined($opt_B)) {										# scale Z
   231 	my($zscale) = $opt_B / ($dta{ENSEMBLE}[$atbottom]->{DEPTH} -# downcast
   239 	my($zscale) = $opt_B / ($dta{ENSEMBLE}[$atbottom]->{DEPTH} -# downcast
   232 				     	    $dta{ENSEMBLE}[$firstgood]->{DEPTH});
   240 				     	    $dta{ENSEMBLE}[$firstgood]->{DEPTH});
   233 #	printf(STDERR "scaling downcast depths by %.2f\n",$zscale);
   241 #	printf(STDERR "scaling downcast depths by %.2f\n",$zscale);
   633 
   641 
   634 #======================================================================
   642 #======================================================================
   635 # PRODUCE OUTPUT
   643 # PRODUCE OUTPUT
   636 #======================================================================
   644 #======================================================================
   637 
   645 
   638 printf(STDERR "# of ensembles   : %d\n",scalar(@{$dta{ENSEMBLE}}));
   646 printf(STDERR "# of ensembles       : %d\n",scalar(@{$dta{ENSEMBLE}}));
   639 printf(STDERR "Start of cast    : %s (#%5d) at %6.1fm\n",
   647 printf(STDERR "Start of cast        : %s (#%5d) at %6.1fm\n",
   640 					$dta{ENSEMBLE}[$firstgood]->{TIME},
   648 					$dta{ENSEMBLE}[$firstgood]->{TIME},
   641 					$dta{ENSEMBLE}[$firstgood]->{NUMBER},
   649 					$dta{ENSEMBLE}[$firstgood]->{NUMBER},
   642 					$dta{ENSEMBLE}[$firstgood]->{DEPTH});
   650 					$dta{ENSEMBLE}[$firstgood]->{DEPTH});
   643 printf(STDERR "Bottom of cast   : %s (#%5d) at %6.1fm\n",
   651 printf(STDERR "Bottom of cast (zmax): %s (#%5d) at %6.1fm\n",
   644 					$dta{ENSEMBLE}[$atbottom]->{TIME},
   652 					$dta{ENSEMBLE}[$atbottom]->{TIME},
   645 					$dta{ENSEMBLE}[$atbottom]->{NUMBER},
   653 					$dta{ENSEMBLE}[$atbottom]->{NUMBER},
   646 					$dta{ENSEMBLE}[$atbottom]->{DEPTH});
   654 					$dta{ENSEMBLE}[$atbottom]->{DEPTH});
   647 if (defined($water_depth)) {
   655 if (defined($water_depth)) {
   648 	printf(STDERR "Seabed           :                      at %6.1fm (+-%dm)\n",$water_depth,$sig_wd);
   656 	printf(STDERR "Seabed               :                      at %6.1fm (+-%dm)\n",$water_depth,$sig_wd);
   649 } else {
   657 } else {
   650 	print(STDERR "Seabed           : not found\n");
   658 	print(STDERR "Seabed               : not found\n");
   651 }
   659 }
   652 printf(STDERR "End of cast      : %s (#%5d) at %6.1fm\n",
   660 printf(STDERR "End of cast (zend)   : %s (#%5d) at %6.1fm\n",
   653 					$dta{ENSEMBLE}[$lastgood]->{TIME},
   661 					$dta{ENSEMBLE}[$lastgood]->{TIME},
   654 					$dta{ENSEMBLE}[$lastgood]->{NUMBER},
   662 					$dta{ENSEMBLE}[$lastgood]->{NUMBER},
   655 					$dta{ENSEMBLE}[$lastgood]->{DEPTH});
   663 					$dta{ENSEMBLE}[$lastgood]->{DEPTH});
   656 
   664 
   657 printf(STDERR "Rel. Displacement: x = %d(%d)m / y = %d(%d)m\n",
   665 printf(STDERR "Rel. Displacement    : x = %d(%d)m / y = %d(%d)m\n",
   658 					$dta{ENSEMBLE}[$lastgood]->{X}, $x_err, 
   666 					$dta{ENSEMBLE}[$lastgood]->{X}, $x_err, 
   659 					$dta{ENSEMBLE}[$lastgood]->{Y}, $y_err, 
   667 					$dta{ENSEMBLE}[$lastgood]->{Y}, $y_err, 
   660 				) if defined($opt_M);
   668 				) if defined($opt_M);
   661 
   669 
   662 printf(STDERR "Cast Duration    : %.1f hours (pinging for %.1f hours)\n",
   670 printf(STDERR "Cast Duration        : %.1f hours (pinging for %.1f hours)\n",
   663 					$dta{ENSEMBLE}[$lastgood]->{ELAPSED_TIME} / 3600,
   671 					$dta{ENSEMBLE}[$lastgood]->{ELAPSED_TIME} / 3600,
   664 					($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{UNIX_TIME} -
   672 					($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{UNIX_TIME} -
   665 						$dta{ENSEMBLE}[0]->{UNIX_TIME}) / 3600);
   673 						$dta{ENSEMBLE}[0]->{UNIX_TIME}) / 3600);
   666 
   674 
   667 printf(STDERR "Minimum range    : %dm at ensemble %d, beam %d\n",
   675 printf(STDERR "Minimum range        : %dm at ensemble %d, beam %d\n",
   668 				$dta{DISTANCE_TO_BIN1_CENTER} +
   676 				$dta{DISTANCE_TO_BIN1_CENTER} +
   669 					$min_good_bins*$dta{BIN_LENGTH},
   677 					$min_good_bins*$dta{BIN_LENGTH},
   670 				$dta{ENSEMBLE}[$min_good_ens]->{NUMBER},
   678 				$dta{ENSEMBLE}[$min_good_ens]->{NUMBER},
   671 				$worst_beam);
   679 				$worst_beam);
   672 printf(STDERR "80%%-valid bins   : %.1f\n",$gb+1);
   680 printf(STDERR "80%%-valid bins       : %.1f\n",$gb+1);
   673 printf(STDERR "80%%-valid range  : %dm\n",
   681 printf(STDERR "80%%-valid range      : %dm\n",
   674 				$dta{DISTANCE_TO_BIN1_CENTER} + $gb*$dta{BIN_LENGTH});
   682 				$dta{DISTANCE_TO_BIN1_CENTER} + $gb*$dta{BIN_LENGTH});
   675 printf(STDERR "3-beam solutions : $RDI_Coords::threeBeam_1 " .
   683 printf(STDERR "3-beam solutions     : $RDI_Coords::threeBeam_1 " .
   676 								 "$RDI_Coords::threeBeam_2 " .
   684 								 	 "$RDI_Coords::threeBeam_2 " .
   677 								 "$RDI_Coords::threeBeam_3 " .
   685 								 	 "$RDI_Coords::threeBeam_3 " .
   678                                  "$RDI_Coords::threeBeam_4\n")
   686                                  	 "$RDI_Coords::threeBeam_4\n")
   679 	unless ($opt_4);
   687 	unless ($opt_4);
   680 printf(STDERR "net rotations    : [%d]/%d/%d/[%d]\n",$prerot,$dnrot,$uprot,$postrot);
   688 printf(STDERR "net rotations        : [%d]/%d/%d/[%d]\n",$prerot,$dnrot,$uprot,$postrot);
   681 printf(STDERR "rms pitch/roll   : %.1f/%.1f\n",$dnprrms,$upprrms);
   689 printf(STDERR "rms pitch/roll       : %.1f/%.1f\n",$dnprrms,$upprrms);
   682 
   690 
   683 if ($opt_A) {												# ANTS format
   691 if ($opt_A) {												# ANTS format
   684 	print("#ANTS# [] $USAGE\n");
   692 	print("#ANTS# [] $USAGE\n");
   685 	$uFields = "{u} {u_err} {v} {v_err} {x} {x_err} {y} {y_err}"
   693 	$uFields = "{u} {u_err} {v} {v_err} {x} {x_err} {y} {y_err}"
   686 		if defined($opt_M);
   694 		if defined($opt_M);