LADCPintsh
changeset 25 91bd907db97f
parent 20 7caeef8595b0
child 26 d778b73f2a43
equal deleted inserted replaced
24:40756f8aff85 25:91bd907db97f
     1 #!/usr/bin/perl
     1 #!/usr/bin/perl
     2 #======================================================================
     2 #======================================================================
     3 #                    L A D C P I N T S H 
     3 #                    L A D C P I N T S H 
     4 #                    doc: Thu Oct 14 21:22:50 2010
     4 #                    doc: Thu Oct 14 21:22:50 2010
     5 #                    dlm: Fri Jul 12 12:18:07 2013
     5 #                    dlm: Thu Mar 20 11:57:54 2014
     6 #                    (c) 2010 A.M. Thurnherr & E. Firing
     6 #                    (c) 2010 A.M. Thurnherr & E. Firing
     7 #                    uE-Info: 57 59 NIL 0 0 72 2 2 4 NIL ofnI
     7 #                    uE-Info: 58 55 NIL 0 0 72 2 2 4 NIL ofnI
     8 #======================================================================
     8 #======================================================================
     9 
     9 
    10 $antsSummary = 'integrate LADCP shear';
    10 $antsSummary = 'integrate LADCP shear';
    11 
    11 
    12 # NOTES:
    12 # NOTES:
    53 #	Jun 14, 2012: - noticed that -b now works also with LDEO SADCP files :-); renamed -b option to -r
    53 #	Jun 14, 2012: - noticed that -b now works also with LDEO SADCP files :-); renamed -b option to -r
    54 #	Jun  5, 2013: - BUG: code bombed when either UC or DC was missing
    54 #	Jun  5, 2013: - BUG: code bombed when either UC or DC was missing
    55 #	Jun 28, 2013: - adapated to new :: convention
    55 #	Jun 28, 2013: - adapated to new :: convention
    56 #				  - make sure LADCP DUL metadata are dealt with correctly
    56 #				  - make sure LADCP DUL metadata are dealt with correctly
    57 #	Jul 12, 2013: - clarified -u usage with better messages
    57 #	Jul 12, 2013: - clarified -u usage with better messages
       
    58 #	Mar 20, 2014: - fiddled while debugging [LADCPproc]
    58 
    59 
    59 ($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
    60 ($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
    60 require "$ANTS/ants.pl";
    61 require "$ANTS/ants.pl";
    61 require "$ANTS/libstats.pl";
    62 require "$ANTS/libstats.pl";
    62 
    63 
   164 		
   165 		
   165 	$dc_nsamp = $ants_[0][$dc_nshF];						# number of shear samples
   166 	$dc_nsamp = $ants_[0][$dc_nshF];						# number of shear samples
   166 	$uc_nsamp = $ants_[0][$uc_nshF];
   167 	$uc_nsamp = $ants_[0][$uc_nshF];
   167 	if (defined($opt_u)) {
   168 	if (defined($opt_u)) {
   168 		$dl_nsamp = $dc_nsamp + $uc_nsamp;
   169 		$dl_nsamp = $dc_nsamp + $uc_nsamp;
   169 		$ul_nsamp = $UL_[$dc_nshF] + $UL_[$uc_nshF];
       
   170 		$dc_nsamp += $UL_[$dc_nshF];
   170 		$dc_nsamp += $UL_[$dc_nshF];
   171 		$uc_nsamp += $UL_[$uc_nshF];
   171 		$uc_nsamp += $UL_[$uc_nshF];
   172 	}
   172 		$ul_nsamp = $dc_nsamp + $uc_nsamp;
   173 	$dc_nsamp[$r] = $dc_nsamp;
   173 	}
       
   174 	
       
   175 	$dc_nsamp[$r] = $dc_nsamp;								# save for each record
   174 	$uc_nsamp[$r] = $uc_nsamp;
   176 	$uc_nsamp[$r] = $uc_nsamp;
   175 	$nsamp[$r] = $dc_nsamp + $uc_nsamp;
   177 	$nsamp[$r] = $dc_nsamp + $uc_nsamp;
   176 	if (defined($opt_u)) {
   178 	if (defined($opt_u)) {
   177 		$ul_nsamp[$r] = $ul_nsamp;
   179 		$ul_nsamp[$r] = $ul_nsamp;
   178 		$dl_nsamp[$r] = $dl_nsamp;
   180 		$dl_nsamp[$r] = $dl_nsamp;
   259 			$uz[$r] = $uc_uz[$r];
   261 			$uz[$r] = $uc_uz[$r];
   260 			$vz[$r] = $uc_vz[$r];
   262 			$vz[$r] = $uc_vz[$r];
   261 			$wz[$r] = $uc_wz[$r];
   263 			$wz[$r] = $uc_wz[$r];
   262 			$elapsed[$r] = $uc_elapsed[$r];
   264 			$elapsed[$r] = $uc_elapsed[$r];
   263         }
   265         }
       
   266 		print(STDERR "uz[$r] := $uz[$r] [$dc_uz[$r]/$uc_uz[$r]] (dcf=$dcf ucf=$ucf)\n");
   264 	} else {
   267 	} else {
   265 		$uz[$r] = $vz[$r] = $wz[$r] = $elapsed[$r] = nan;
   268 		$uz[$r] = $vz[$r] = $wz[$r] = $elapsed[$r] = nan;
   266 	}
   269 	}
   267 
   270 
   268 	if (numberp($uz[$r]) && $curGap>0) {						# end of gap
   271 	if (numberp($uz[$r]) && $curGap>0) {						# end of gap
   376 # Step 4: Reference Velocities
   379 # Step 4: Reference Velocities
   377 #======================================================================
   380 #======================================================================
   378 
   381 
   379 my($refU,$refV,$refW,$dc_refU,$dc_refV,$dc_refW,$uc_refU,$uc_refV,$uc_refW);
   382 my($refU,$refV,$refW,$dc_refU,$dc_refV,$dc_refW,$uc_refU,$uc_refV,$uc_refW);
   380 
   383 
   381 if (defined($opt_r)) {											# reference to bottom-track profile
   384 if (defined($opt_r)) {											# reference using velocity profile
   382 	print(STDERR "Loading reference-velocity data from $opt_r...\n")
   385 	print(STDERR "Loading reference-velocity data from $opt_r...\n")
   383 		if ($opt_d);
   386 		if ($opt_d);
   384 	open(BTF,$opt_r) || croak("$opt_r: $!\n");
   387 	open(BTF,$opt_r) || croak("$opt_r: $!\n");
   385 
   388 
   386 	my(@BTL) = &antsFileLayout(BTF);
   389 	my(@BTL) = &antsFileLayout(BTF);
   501 		if ($dc_nSumVel > 0) {
   504 		if ($dc_nSumVel > 0) {
   502 			$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu;
   505 			$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu;
   503 			$dc_refV = $dc_sumV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv;
   506 			$dc_refV = $dc_sumV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv;
   504 			$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw if (@BT_w);
   507 			$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw if (@BT_w);
   505 		} else {
   508 		} else {
   506 			&antsInfo("$opt_r: insufficient reference-velocity data to constrain dc profile --- baroclinic profile only");
   509 			&antsInfo("$opt_r: insufficient reference-velocity data to constrain DC profile --- baroclinic profile only");
   507 		}
   510 		}
   508 	    
   511 	    
   509 		if ($uc_nSumVel > 0) {
   512 		if ($uc_nSumVel > 0) {
   510 			$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu;
   513 			$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu;
   511 			$uc_refV = $uc_sumV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv;
   514 			$uc_refV = $uc_sumV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv;
   512 		    $uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw if (@BT_w);
   515 		    $uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw if (@BT_w);
   513 		} else {
   516 		} else {
   514 			&antsInfo("$opt_r: insufficient reference-velocity data to constrain dc profile --- baroclinic profile only");
   517 			&antsInfo("$opt_r: insufficient reference-velocity data to constrain UC profile --- baroclinic profile only");
   515 		}
   518 		}
   516 	} else {
   519 	} else {
   517 		&antsInfo("$opt_r: no valid reference-velocity data --- baroclinic profiles only");
   520 		&antsInfo("$opt_r: no valid reference-velocity data --- baroclinic profiles only");
   518 	}
   521 	}
   519 }
   522 }