V1.2beta3
authorA.M. Thurnherr <athurnherr@yahoo.com>
Sun, 13 Mar 2016 12:33:20 +0000
changeset 39 91458506d56f
parent 38 5d4bbb0a8379
child 40 408fc95bcff8
V1.2beta3
HISTORY
LADCP_w_CTD
LADCP_w_howto.pdf
LADCP_w_ocean
defaults.pl
version.pl
--- a/HISTORY	Thu Mar 10 14:04:14 2016 +0000
+++ b/HISTORY	Sun Mar 13 12:33:20 2016 +0000
@@ -1,9 +1,9 @@
 ======================================================================
                     H I S T O R Y 
                     doc: Mon Oct 12 16:09:24 2015
-                    dlm: Thu Mar 10 11:26:21 2016
+                    dlm: Sun Mar 13 12:32:46 2016
                     (c) 2015 A.M. Thurnherr
-                    uE-Info: 49 10 NIL 0 0 72 3 2 4 NIL ofnI
+                    uE-Info: 51 41 NIL 0 0 72 3 2 4 NIL ofnI
 ======================================================================
 
 V1.0:
@@ -47,3 +47,9 @@
 		- added hab field to .wprof output [LADCP_w_ocean]
 	Mar 10, 2016:
 		- published
+	Mar 13, 2016: V1.2beta3
+		- updated [version.pl] [.hg/hgrc]
+		- added simple ASCII CTD format [LADCP_w_CTD]
+		- added auto directory creation to [defaults.pl]
+		- updated howto
+		- published
--- a/LADCP_w_CTD	Thu Mar 10 14:04:14 2016 +0000
+++ b/LADCP_w_CTD	Sun Mar 13 12:33:20 2016 +0000
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ C T D 
 #                    doc: Mon Nov  3 17:34:19 2014
-#                    dlm: Fri Feb 19 08:01:38 2016
+#                    dlm: Sun Mar 13 11:53:56 2016
 #                    (c) 2014 A.M. Thurnherr
-#                    uE-Info: 241 0 NIL 0 0 72 2 2 4 NIL ofnI
+#                    uE-Info: 222 67 NIL 0 0 72 2 2 4 NIL ofnI
 #======================================================================
 
 $antsSummary = 'pre-process SBE 9plus CTD data for LADCP_w';
@@ -52,6 +52,8 @@
 #	Feb 19, 2016: - improved on-surface data detection (conductivity <= 10mS/cm)
 #				  - BUG: temperatures < 0 were not allowed
 #				  - temperature histogram resolution increased from 1degC to 0.5degC for no good reason
+#	Mar 13, 2016: - added simple ASCII file format
+#				  - BUG: Layout error when input had no lat/lon
 
 ($ANTS)  = (`which ANTSlib`   =~ m{^(.*)/[^/]*$});
 ($WCALC) = ($0                =~ m{^(.*)/[^/]*$});
@@ -90,49 +92,71 @@
 
 print(STDERR "Reading $CNVfile...") if ($opt_v);
 
-($nfields,$nscans,$sampint,$badval,$ftype,$lat,$lon) =			# decode SBE header	
-    SBE_parseHeader(F,0,0);										# SBE field names, no time check
-
-croak("$CNVfile: unexpected sampling interval $sampint\n")
-	unless (abs($sampint-1/24) < 1e-5);
-croak("$CNVfile: no latitude in header\n")
-	unless numberp($lat);
+chomp($rec = <F>);
+croak("$CNVfile: no data\n")
+	unless defined($rec);
 
-$pressF = fnr('prDM');
-
-if ($opt_a) {													# temp/cond alternate sensor pair
-	$tempF	= fnr('t190C');
-	$condF	= fnrNoErr('c1S/m');
-	if (defined($condF)) {
-		$condHistRes = 20;										# 0.2 S/m bins
-	} else {
-		$condF  = fnr('c1mS/cm');
-		$condHistRes = 2;										# 2.0 mS/cm bins
+if ($rec =~ /^\*/) {												# SBE CNV file
+	($nfields,$nscans,$sampint,$badval,$ftype,$lat,$lon) =			# decode SBE header 
+		SBE_parseHeader(F,0,0); 									# SBE field names, no time check
+	
+	croak("$CNVfile: unexpected sampling interval $sampint\n")
+		unless (abs($sampint-1/24) < 1e-5);
+	croak("$CNVfile: no latitude in header\n")
+		unless numberp($lat);
+	
+	$pressF = fnr('prDM');
+	
+	if ($opt_a) {													# temp/cond alternate sensor pair
+		$tempF	= fnr('t190C');
+		$condF	= fnrNoErr('c1S/m');
+		if (defined($condF)) {
+			$condHistRes = 20;										# 0.2 S/m bins
+		} else {
+			$condF	= fnr('c1mS/cm');
+			$condHistRes = 2;										# 2.0 mS/cm bins
+		}
+	} else {														# primary sensor pair
+		$tempF	= fnr('t090C');
+		$condF	= fnrNoErr('c0S/m');
+		if (defined($condF)) {
+			$condHistRes = 20;
+		} else {
+			$condF	= fnr('c0mS/cm');
+			$condHistRes = 2;
+		}
 	}
-} else {														# primary sensor pair
-	$tempF	= fnr('t090C');
-	$condF	= fnrNoErr('c0S/m');
-	if (defined($condF)) {
-		$condHistRes = 20;
-	} else {
-		$condF  = fnr('c0mS/cm');
-		$condHistRes = 2;
+	
+	$latF = &fnrNoErr('lat');										# GPS data if available (to make files useful for u/v processing)
+	$lonF = &fnrNoErr('lon');
+	
+	&antsInstallBufFull(0); 										# read entire CNV file
+	&SBEin(F,$ftype,$nfields,$nscans,$badval);
+	
+	if (@ants_ != $nscans) {
+		if ($opt_v > 1) {
+			printf(STDERR "\n\nWARNING: $CNVfile has wrong number of scans in header\n");
+		} else {
+			printf(STDERR "WARNING: $CNVfile has wrong number of scans in header\n");
+		}
+		$nscans = @ants_;
 	}
-}
-
-$latF = &fnrNoErr('lat');										# GPS data if available (to make files useful for u/v processing)
-$lonF = &fnrNoErr('lon');
-
-&antsInstallBufFull(0);											# read entire CNV file
-&SBEin(F,$ftype,$nfields,$nscans,$badval);
-
-if (@ants_ != $nscans) {
-	if ($opt_v > 1) {
-		printf(STDERR "\n\nWARNING: $CNVfile has wrong number of scans in header\n");
-	} else {
-		printf(STDERR "WARNING: $CNVfile has wrong number of scans in header\n");
+} else { 																			# simple ASCII file format:
+	croak("$CNVfile: ASCII file format error (1st rec must be latitude)\n")			#	header: lat
+		unless numberp($rec) && $rec>=-90 && $rec<=90;
+	&antsAddParams('lat',$lat=$rec);		
+	$sampint = 1/24; $condHistRes = 2;												# 	assumptions: 24Hz
+	&antsAddParams('ITS',90,'cond.unit','mS/cm');									#	ITS-90, mS/cm
+	$pressF = 1; $tempF = 2; $condF = 3;											# 	Layout: scan press temp cond
+	for ($nscans=0; <F>; $nscans++) {
+		chomp;
+		@{$ants_[$nscans]} = split(',');											# 	CSV format
+		croak("$CNVfile: unexpected scan #$ants_[$nscans][0] (%d expected)\n",$nscans+1)
+			unless ($ants_[$nscans][0] == $nscans+1);
+		$ants_[$nscans][$pressF] = nan unless defined($ants_[$nscans][$pressF]);	# missing values
+		$ants_[$nscans][$tempF] = nan unless defined($ants_[$nscans][$tempF]);
+		$ants_[$nscans][$condF] = nan unless defined($ants_[$nscans][$condF]);
 	}
-	$nscans = @ants_;
 }
 
 printf(STDERR "\n\t%d scans",$nscans) if ($opt_v > 1);
@@ -190,10 +214,13 @@
 	#----------------------------------------
 	my($trimmed) = 0;												# trim leading nan pressures
 	shift(@ants_),$trimmed++
-		until numberp($ants_[0][$pressF]) &&
-			  numberp($ants_[0][$condF]) &&
-			  (($P{cond.unit} eq 'mS/cm' && $ants_[0][$condF] > 10) ||
-			   ($P{cond.unit} eq 'S/m'   && $ants_[0][$condF] > 1));
+		until !@ants_ ||
+				numberp($ants_[0][$pressF]) &&
+			  	numberp($ants_[0][$condF]) &&
+			  	(($P{'cond.unit'} eq 'mS/cm' && $ants_[0][$condF] > 10) ||
+			     ($P{'cond.unit'} eq 'S/m'   && $ants_[0][$condF] > 1));
+	croak("\n$CNVfile: no valid records (wrong conductivity units?)\n")
+		unless (@ants_);			     
 	printf(STDERR "\n\t%d initial at-surface records trimmed",$trimmed) if ($opt_v > 1);
 	my($lvp) = $ants_[0][$pressF];
 	my($lvc) = $ants_[0][$condF];
@@ -454,6 +481,7 @@
 	$maxP=$press[$r],$atBtm=$r if ($press[$r] > $maxP);
 	$elapsed[$r] = $r/$opt_s;
 	$depth[$r] = &depth($press[$r],$lat);
+#	print(STDERR "depth[$r] = depth($press[$r],$lat) = $depth[$r]\n");
 	$salin[$r] = &salin($cond[$r],$temp[$r],$press[$r]);
 	$sspd[$r]  = &sVel($salin[$r],$temp[$r],$press[$r]);
 	$min_sspd = $sspd[$r] if ($sspd[$r] < $min_sspd);
@@ -590,8 +618,7 @@
 
 print(STDERR "Writing output...\n") if ($opt_v);
 
-@antsNewLayout = ('elapsed','press','temp','cond','depth','salin','sspd','w.raw','w');
-push(@antsNewLayout,'lat','lon') if (defined($latF));
+@antsNewLayout = ('elapsed','press','temp','cond','depth','salin','sspd','w.raw','w','lat','lon');
 for ($r=0; $r<@w; $r++) {
 	&antsOut($elapsed[$r],$press[$r],$temp[$r],$cond[$r],$depth[$r],$salin[$r],
 			 $sspd[$r],$w[$r],$w_lp[2*$r]/@w_lp,$lat[$r],$lon[$r]);
Binary file LADCP_w_howto.pdf has changed
--- a/LADCP_w_ocean	Thu Mar 10 14:04:14 2016 +0000
+++ b/LADCP_w_ocean	Sun Mar 13 12:33:20 2016 +0000
@@ -2,9 +2,9 @@
 #======================================================================
 #                    L A D C P _ W _ O C E A N 
 #                    doc: Fri Dec 17 18:11:13 2010
-#                    dlm: Wed Mar  9 17:18:37 2016
+#                    dlm: Sun Mar 13 10:48:17 2016
 #                    (c) 2010 A.M. Thurnherr
-#                    uE-Info: 225 46 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 226 76 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # TODO:
@@ -223,6 +223,7 @@
 #	Mar  8, 2016: - removed L0 water-depth-difference warning
 #				  - added test for 1500m/s sound speed
 #	Mar  9, 2016: - added hab field to .wprof output
+#	Mar 13, 2016: - cleaned up warnings created before LADCP_file is defined
 # HISTORY END
 
 # CTD REQUIREMENTS
@@ -431,7 +432,8 @@
 	return if ($opt_v == 0);
 
 	if ($opt_v == 1) {
-		print(STDERR "$LADCP_file: WARNING (L$lvl): ");
+		print(STDERR "$LADCP_file: ") if defined($LADCP_file);
+		print(STDERR "WARNING (L$lvl): ");
 		printf(STDERR @msg);
 	} else {
 		print(STDERR "\n-------------\nWARNING (L$lvl): ");
--- a/defaults.pl	Thu Mar 10 14:04:14 2016 +0000
+++ b/defaults.pl	Sun Mar 13 12:33:20 2016 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    D E F A U L T S . P L 
 #                    doc: Tue Oct 11 17:11:21 2011
-#                    dlm: Thu Jan 28 16:55:23 2016
+#                    dlm: Sun Mar 13 10:50:09 2016
 #                    (c) 2011 A.M. Thurnherr
-#                    uE-Info: 466 0 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 130 13 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -67,6 +67,7 @@
 #	Jan 26, 2016: - removed -d
 #				  - changed outGrid_firstBin default to '*', also lastBin
 #	Jan 27, 2016: - added documentation
+#	Mar 16, 2016: - added auto creation of output directory
 
 #======================================================================
 # Data Input 
@@ -123,7 +124,11 @@
 
 # Output subdirectories
 
-error("$RUN: no such directory\n") unless (-d $RUN);
+unless (-d $RUN) {
+	warning(0,"Creating output directory ./$RUN\n");
+	mkdir($RUN);
+	error("./$RUN: no such directory\n") unless (-d $RUN);
+}
 $data_subdir = $plot_subdir = $log_subdir = $RUN;
 
 
--- a/version.pl	Thu Mar 10 14:04:14 2016 +0000
+++ b/version.pl	Sun Mar 13 12:33:20 2016 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    V E R S I O N . P L 
 #                    doc: Tue Oct 13 10:40:57 2015
-#                    dlm: Wed Mar  9 17:13:52 2016
+#                    dlm: Sun Mar 13 09:36:41 2016
 #                    (c) 2015 A.M. Thurnherr
-#                    uE-Info: 16 20 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 15 20 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 # HISTORY:
@@ -11,9 +11,8 @@
 #	Jan  4, 2016: - added $ADCP_tools_minVersion
 #	Mar  8, 2016: - updated antsMinLibVersion to 6.3
 
-#$VERSION = '1.1beta1';			# Oct 12, 2015
 #$VERSION = '1.1';				# Jan  4, 2016
-$VERSION = '1.2beta2';			# Jan  5, 2016
+$VERSION = '1.2beta3';			# Jan  5, 2016
 
 $antsMinLibVersion 		= 6.3;
 $ADCP_tools_minVersion 	= 1.4;