V6.6
authorA.M. Thurnherr <athurnherr@yahoo.com>
Tue, 29 Mar 2016 14:57:54 -0400
changeset 28 db6c3d13f8be
parent 27 abeaad5308ba
child 29 f41d125405a6
V6.6
HISTORY
ants.pl
libSBE.pl
--- a/HISTORY
+++ b/HISTORY
@@ -1,9 +1,9 @@
 #======================================================================
 #                    H I S T O R Y 
 #                    doc: Thu May  7 13:12:05 2015
-#                    dlm: Thu Mar 17 12:24:52 2016
+#                    dlm: Tue Mar 29 14:57:38 2016
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 54 15 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 61 37 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 May  7, 2015:
@@ -52,5 +52,10 @@
 	- V6.5 [ants.pl] [.hg/hgrc] 
 	- improved [libGMT.pl] to check for gmt5
 	- published
+
+Mar 19, 2016:
+	- significant bugs in [libSBE.pl]
 	
-
+Mar 29, 2106:
+	- V6.6 [ants.pl] [.hg/hgrc] 
+	- published for LADCP_w V1.2beta6
--- a/ants.pl
+++ b/ants.pl
@@ -2,9 +2,9 @@
 #======================================================================
 #                    A N T S . P L 
 #                    doc: Fri Jun 19 14:01:06 1998
-#                    dlm: Thu Mar 17 12:02:55 2016
+#                    dlm: Tue Mar 29 14:57:11 2016
 #                    (c) 1998 A.M. Thurnherr
-#                    uE-Info: 26 21 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 22 34 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -19,11 +19,12 @@
 #  Mar  8, 2016: - updated to V6.3 (for LADCP_w 1.2beta)
 #  Mar 16, 2016: - updated to V6.4 (for LADCP_w 1.2beta5)
 #  Mar 17, 2016: - updated to V6.5
+#  Mar 29, 2016: - updated to V6.6
 
 exec($ENV{ANTS_PERL},$0,@ARGV),die("$ENV{ANTS_PERL}: $!")
     if (defined($ENV{ANTS_PERL}) && $^X ne $ENV{ANTS_PERL});
 
-$antsLibVersion = 6.5;
+$antsLibVersion = 6.6;
 
 die(sprintf("$0: obsolete library V%.1f; V%.1f required\n",
 	$antsLibVersion,$antsMinLibVersion))
--- a/libSBE.pl
+++ b/libSBE.pl
@@ -1,9 +1,9 @@
 #======================================================================
 #                    L I B S B E . P L 
 #                    doc: Mon Nov  3 12:42:14 2014
-#                    dlm: Tue Sep 29 11:01:30 2015
+#                    dlm: Sat Mar 19 18:17:54 2016
 #                    (c) 2014 A.M. Thurnherr
-#                    uE-Info: 45 54 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 18 71 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -12,6 +12,10 @@
 #	Jun 17, 2015: - ensured numeric retvals of SBE_parseheader are returned as numbers
 #	Jun 18, 2015: - BUG: binary code had several bugs
 #	Sep 29, 2015: - added potemp and sigma standard field names
+#	Mar 19, 2016: - BUG: conductivity unit checking on input had multiple bugs
+#				  - solution for files with multiple conductivity units: ignore
+#				    all conducitivities with units not equal to the first cond var
+#				  - added $libSBE_quiet to suppress diagnostic messages
 
 #----------------------------------------------------------------------
 # fname_SBE2std($)
@@ -37,74 +41,74 @@
 	return 'alt_rho0'	if /^density11/;
 	
 	if (/^t090/) {											# temperatures with different scales
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 		return 'temp';
 	} elsif (/^t068/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 		return 'temp';
 	}
 		
 	if (/^t190/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 		return 'alt_temp';
 	} elsif (/^t168/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 		return 'alt_temp';
 	}
 
 	if (/^potemp090/) {											# potential temperatures with different scales
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 		return 'theta0';
 	} elsif (/^potemp068/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 		return 'theta0';
 	}
 		
 	if (/^potemp190/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 		return 'alt_theta0';
 	} elsif (/^potemp168/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 		return 'alt_theta0';
 	}
 
 	if (m{^c0S/m}) {										# conductivity with different units
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} ne 'S/m');
-		&antsAddParams('cond.unit','S/m'); $P{cond.unit} = 'S/m';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'S/m');
+		&antsAddParams('cond.unit','S/m');
 		return 'cond';
 	} elsif (m{^c0mS/cm}) {
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} != 'mS/cm');
-		&antsAddParams('cond.unit','mS/cm'); $P{cond.unit} = 'mS/cm';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'mS/cm');
+		&antsAddParams('cond.unit','mS/cm');
 		return 'cond';
 	}
 		
 	if (m{^c1S/m}) {
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} != 'S/m');
-		&antsAddParams('cond.unit','S/m'); $P{cond.unit} = 'S/m';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'S/m');
+		&antsAddParams('cond.unit','S/m');
 		return 'alt_cond';
 	} elsif (m{^c1mS/cm}) {
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} != 'mS/cm');
-		&antsAddParams('cond.unit','mS/cm'); $P{cond.unit} = 'mS/cm';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'mS/cm');
+		&antsAddParams('cond.unit','mS/cm');
 		return 'alt_cond';
 	}
 
@@ -117,63 +121,63 @@
 	$_ = $_[0];
 
 	if (/^t090/) {											# temperatures with different scales
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 	} elsif (/^t068/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 	}
 		
 	if (/^t190/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 	} elsif (/^t168/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 	}
 
 	if (/^potemp090/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 	} elsif (/^potemp068/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 	}
 		
 	if (/^potemp190/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 90);
 		&antsAddParams('ITS',90); $P{ITS} = 90;
 	} elsif (/^potemp168/) {
-		croak("$0: inconsistent temperature scales\n")
+		return undef
 			if defined($P{ITS}) && ($P{ITS} != 68);
 		&antsAddParams('ITS',68); $P{ITS} = 68;
 	}
 
 	if (m{^c0S/m}) {										# conductivity with different units
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} ne 'S/m');
-		&antsAddParams('cond.unit','S/m'); $P{cond.unit} = 'S/m';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'S/m');
+		&antsAddParams('cond.unit','S/m');
 	} elsif (m{^c0mS/cm}) {
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} != 'mS/cm');
-		&antsAddParams('cond.unit','mS/cm'); $P{cond.unit} = 'mS/cm';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'mS/cm');
+		&antsAddParams('cond.unit','mS/cm');
 	}
 		
 	if (m{^c1S/m}) {
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} != 'S/m');
-		&antsAddParams('cond.unit','S/m'); $P{cond.unit} = 'S/m';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'S/m');
+		&antsAddParams('cond.unit','S/m');
 	} elsif (m{^c1mS/cm}) {
-		croak("$0: inconsistent conductivity units\n")
-			if defined($P{cond.unit}) && ($P{cond.unit} != 'mS/cm');
-		&antsAddParams('cond.unit','mS/cm'); $P{cond.unit} = 'mS/cm';
+		return undef
+			if defined($P{'cond.unit'}) && ($P{'cond.unit'} ne 'mS/cm');
+		&antsAddParams('cond.unit','mS/cm');
 	}
 
 	return $_;
@@ -211,8 +215,11 @@
 #----------------------------------------------------------------------
 # sub SBE_parseHeader(FP,std-field-names,time-check)
 #	- parse header information
+#	- set @ignore_input_fields with fields with inconsistent units
 #----------------------------------------------------------------------
 
+my(@ignore_input_fields);								# in reverse order!!!
+
 sub SBE_parseHeader($$$)
 {
 	my($FP,$sfn,$tc) = @_;
@@ -227,8 +234,14 @@
 		$nfields = $',next if ($hdr =~ /nquan = /); 	# Layout
 		$nrecs = $',next if ($hdr =~ /nvalues = /);
 		if ($hdr =~ /name (\d+) = ([^:]+):/) {
-			$antsNewLayout[$1] = $sfn ? fname_SBE2std($2) : fname_SBE($2);
-			next;
+			my($fn) = $sfn ? fname_SBE2std($2) : fname_SBE($2);
+			if (defined($fn)) {
+				push(@antsNewLayout,$fn);
+			} else {
+				unshift(@ignore_input_fields,$1);
+				&antsInfo("CNV input field \#$1 ($2) ignored, because of unit inconsistency")
+					unless defined($libSBE_quiet);
+			}
 		}
 		    
 		SBE_checkTime($1,$tc),next 						# sanity time check
@@ -314,9 +327,12 @@
 	if ($ftype eq 'ascii') {
 		until ($#ants_>=0 && &antsBufFull()) {
 			return undef unless (@add = &antsFileIn($FP));
-			for (my($f)=0; $f<$nf; $f++) {
+			for (my($f)=0; $f<=$nf; $f++) {
 				$add[$f] = nan if ($add[$f] == $bad);
 			}
+			foreach my $sf (@ignore_input_fields) {
+				splice(@add,$sf,1);
+			}
 			push(@ants_,[@add]);
 		}
 	} elsif ($ftype eq 'binary') {
@@ -341,6 +357,9 @@
 		until ($#ants_>=0 && &antsBufFull()) {					# copy next out
 			return undef unless ($nextR < $nr);
 			@add = @dta[$nextR*$nf..($nextR+1)*$nf-1];
+			foreach my $sf (@ignore_input_fields) {
+				splice(@add,$sf,1);
+			}
 			push(@ants_,[@add]);
 			$nextR++;
         }