editPD0
author A.M. Thurnherr <athurnherr@yahoo.com>
Tue, 29 Jun 2021 12:21:32 -0400
changeset 59 4f4530fa35da
parent 43 b63fa355644c
permissions -rwxr-xr-x
V2.4 - New Features: - support for Nortek PD0 files - patchPD0 support for moored ADCP data - bug fixes & minor improvements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     1
#!/usr/bin/perl
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     2
#======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     3
#                    E D I T P D 0 
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     4
#                    doc: Mon Nov 25 20:24:31 2013
43
b63fa355644c commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 42
diff changeset
     5
#                    dlm: Wed Mar 14 21:15:51 2018
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     6
#                    (c) 2013 A.M. Thurnherr
43
b63fa355644c commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 42
diff changeset
     7
#                    uE-Info: 417 0 NIL 0 0 72 2 2 4 NIL ofnI
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     8
#======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     9
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    10
# edit RDI PD0 file, e.g. to replace pitch/roll/heading with external values
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    11
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    12
# NOTES:
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    13
#
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    14
#	- editing instructions can be provided either in an editing file (primarily
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    15
#	  for ensemble-specific editing), or with the -x option on the command line
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    16
#	  (only or editing applied to all ensembles)
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    17
#
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    18
#	- Data-Editing Library:
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    19
#		p(<pitch>)				set pitch value (RDI not gimbal pitch) of current ensemble
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    20
#		r(<roll>)				set roll alue value of current ensemble
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    21
#		h(<heading>)			set heading alue value of current ensemble
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    22
#
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    23
#		swap_beams(<b1>,<b2>)	swap data from beams b1 and b2
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    24
#									- input in beam coords required
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    25
#									- beam rotation is equivalent to 3 consecutive beam swaps
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    26
#									- basic BT data are swapped as well (not RL and not SIGNAL_STRENGTH)
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    27
#
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    28
#		earth2beam()			transform beam to earth coordinates
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    29
#									- does not handle bin-remapping
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    30
#									- input in earth coords required
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    31
#
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    32
#		beam2earth()			transform earth to beam coordinates
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    33
#									- does not handle bin-remapping
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    34
#									- input in beam coords required
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    35
#
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
    36
#		instrument2beam()		transform instrument to earth coordinates
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    37
#									- does not handle bin-remapping
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    38
#									- input in instrument coords required
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
    39
#
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    40
#		ensure_UL()				correct data for wrong transducer orientation
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    41
#		ensure_DL()					- sets correct flag & negates roll value
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
    42
#
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
    43
#		dealias(<WV lim[m/s]>) 	correct data for erroneously low WV setting
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
    44
#									- HEURISTIC, i.e. may not work
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
    45
#
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    46
#	- -x notes:
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    47
#		- multiple perl expressions can be combined with ,
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    48
#
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    49
#	- Edit File Syntax:
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    50
#		- # comments ignored
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    51
#		- empty lines ignored
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    52
#       - [space] <ensemble-number|*> <space> <perl-expr>
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    53
#		- Examples:
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    54
#       	162     p(3), r(4), h(3.14)
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    55
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    56
# HISTORY:
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    57
#   Nov 25, 2013: - created
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    58
#   Dec 18, 2015: - added switch_beams()
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    59
#                 - added -x
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    60
#	Jan  9, 2016: - renamed switch_beams() to swap_beams()
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    61
#				  - wrote documentation
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    62
#				  - change output data-source ID from 0x7F to 0xE0
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    63
#				  - updated getopts to current perl version
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    64
#				  - adapted to [ADCP_tools_lib.pl]
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
    65
#	Feb 15, 2016: - added ensure_UL() ensure_DL()
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
    66
#	Feb 23, 2016: - added -k
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
    67
#	Feb 26, 2016: - added basic BT data to swap_beams()
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
    68
#				  - added earth2beam()
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
    69
#	Apr 12, 2016: - added instrument2beam()
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    70
#	Jun  3, 2016: - added beam2earth()
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    71
#				  - BUG: instrument2earth() set wrong flag
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    72
#	Jun  8, 2016: - adapted to new interface of velInstrumentToBeam()
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    73
#				  - added %-good to beam2earth and earth2beam
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    74
#				  - made single-ping ensemble requirement for most routines
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    75
#	Jul 12, 2016: - updated ensure_{DL,UL} routines
37
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
    76
#	Nov 15, 2016: - BUG: ensure_{DL,UL} routines did not negate heading data
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
    77
#	Jul 27, 2017: - began working on dealias()
41
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
    78
#	Dec  6, 2017: - cosmetics
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    79
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    80
use Getopt::Std;
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    81
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    82
($ADCP_TOOLS) = ($0 =~ m{(.*/)[^/]+});
42
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 41
diff changeset
    83
$ADCP_tools_minVersion = 2.1; 
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    84
require "$ADCP_TOOLS/ADCP_tools_lib.pl";
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    85
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    86
$USAGE = "$0 @ARGV";
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    87
die("Usage: $0 " .
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    88
    '-e) <edit-file> | -x) <expr> ' .
41
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 40
diff changeset
    89
    '[-k)eep original data-source id] ' .
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    90
    "<input file> <output file>\n")
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
    91
        unless (&getopts('ke:x:') && @ARGV == 2);
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    92
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
    93
die("$0: -e <edit-file> or -x <expr> required\n")
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    94
    unless (defined($opt_x) || -r $opt_e);
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    95
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    96
print(STDERR "Reading $ARGV[0]...");                # read data
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    97
readData($ARGV[0],\%dta);
37
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
    98
printf(STDERR "done (%d complete ensembles)\n",
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
    99
	scalar(@{$dta{ENSEMBLE}}));
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   100
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   101
#----------------------------------------------------------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   102
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   103
print(STDERR "Editing Data...");                
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   104
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   105
#--------------------------------------------------
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   106
# Data Editing Library
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   107
#--------------------------------------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   108
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   109
#--------------------------------------------------
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   110
# override pitch/roll/heading
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   111
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   112
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   113
sub p($) { $dta{ENSEMBLE}[$e]->{PITCH} = $_[0]; return 1; }
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   114
sub r($) { $dta{ENSEMBLE}[$e]->{ROLL} = $_[0]; return 1; }
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   115
sub h($) { $dta{ENSEMBLE}[$e]->{HEADING} = $_[0]; return 1;}
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   116
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   117
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   118
# correct data for erroneously low WV limit
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   119
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   120
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   121
{ my(@target);												# static scope, undef initially
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   122
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   123
sub dealias_V0($)
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   124
{
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   125
	my($WV) = @_;
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   126
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   127
	if (@target) {											# dealias everything but first ensemble
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   128
		for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   129
			for (my($beam)=0; $beam<4; $beam++) {
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   130
				next unless defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]);
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   131
				my($dealiased) = 0;
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   132
				$dealiased = ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] - 2*$WV)
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   133
					if ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] > 0);
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   134
				$dealiased = ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] + 2*$WV)
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   135
					if ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] < 0);
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   136
				if (abs($target[$beam]-$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]) >
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   137
					abs($target[$beam]-$dealiased)) {
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   138
						$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] = undef; #$dealiased;
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   139
						$dealiased++;
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   140
				}
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   141
			}
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   142
    	}
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   143
    } else { # @target is undef
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   144
    	$dealiased = 0;
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   145
    }
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   146
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   147
	@target = (0,0,0,0);									# calc ref-lr average target for next ens
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   148
	for (my($bin)=1; $bin<=5; $bin++) {						# should work even if N_BINS < 5
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   149
		for (my($beam)=0; $beam<4; $beam++) {
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   150
			$target[$beam] += $dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]/4
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   151
				if defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]);
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   152
		}
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   153
    }
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   154
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   155
    return 1;
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   156
}
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   157
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   158
} # static scope
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   159
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   160
#--------------------------------------------------
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   161
# override transducer orientation
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   162
#
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   163
#	These routines are intended to correct ADCP data for
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   164
#	erroneous orientation switch readings, primarily because
37
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   165
#	of a stuck switch.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   166
#		Roll: Based on text from the coord trans manual,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   167
#			  it seems likely that the roll data need to
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   168
#			  be negated. In case of 2007(?) CLIVAR I08S
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   169
#			  profile #1 w gets much better with negated
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   170
#			  roll. Also, in 2016 CLIVAR P18 profile 003
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   171
#			  the instrument-offset calculation from
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   172
#			  compass and pitch/roll only agree with the
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   173
#			  roll negated.
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   174
#		Hdg: Based on the time-series of headings recorded
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   175
#		     during P18 profile 003 the heading needs
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   176
#			 to be negated. Doing so yields a good profile.
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   177
#--------------------------------------------------
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   178
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   179
sub ensure_DL()
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   180
{
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   181
	if ($dta{ENSEMBLE}[$e]->{XDUCER_FACING_UP}) {
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   182
		$dta{ENSEMBLE}[$e]->{ROLL} *= -1;
37
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   183
		$dta{ENSEMBLE}[$e]->{HEADING} *= -1; 
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   184
		$dta{ENSEMBLE}[$e]->{HEADING} += 360
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   185
			if ($dta{ENSEMBLE}[$e]->{HEADING} < 0);
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   186
		$dta{ENSEMBLE}[$e]->{XDUCER_FACING_DOWN} = 1;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   187
		$dta{ENSEMBLE}[$e]->{XDUCER_FACING_UP} = undef;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   188
	}
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   189
	return 1;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   190
}
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   191
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   192
sub ensure_UL()
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   193
{
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   194
	if ($dta{ENSEMBLE}[$e]->{XDUCER_FACING_DOWN}) {
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   195
		$dta{ENSEMBLE}[$e]->{ROLL} *= -1;
37
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   196
		$dta{ENSEMBLE}[$e]->{HEADING} *= -1; 
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   197
		$dta{ENSEMBLE}[$e]->{HEADING} += 360
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 36
diff changeset
   198
			if ($dta{ENSEMBLE}[$e]->{HEADING} < 0);
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   199
		$dta{ENSEMBLE}[$e]->{XDUCER_FACING_UP} = 1;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   200
		$dta{ENSEMBLE}[$e]->{XDUCER_FACING_DOWN} = undef;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   201
	}
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   202
	return 1;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   203
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   204
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   205
#--------------------------------------------------
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   206
# swap data from two mis-connected beams
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   207
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   208
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   209
sub swap_beams($$)
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   210
{
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   211
	my($b1,$b2) = @_;
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   212
	my($tmp);
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   213
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   214
#	print(STDERR "\n entering swap_beams($b1,$b2) for ens = $e...");
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   215
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   216
	die("$ARGV[0]: beam-coordinate data required\n")
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   217
		unless ($dta{BEAM_COORDINATES});
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   218
	die("$ARGV[0]: single-ping ensembles required\n")
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   219
		unless ($dta{PINGS_PER_ENSEMBLE} == 1);
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   220
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   221
	if ($dta{BT_PRESENT}) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   222
		$tmp = $dta{ENSEMBLE}[$e]->{BT_RANGE}[$b1-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   223
		$dta{ENSEMBLE}[$e]->{BT_RANGE}[$b1-1] = $dta{ENSEMBLE}[$e]->{BT_RANGE}[$b2-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   224
		$dta{ENSEMBLE}[$e]->{BT_RANGE}[$b2-1] = $tmp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   225
		                
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   226
		$tmp = $dta{ENSEMBLE}[$e]->{BT_VELOCITY}[$b1-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   227
		$dta{ENSEMBLE}[$e]->{BT_VELOCITY}[$b1-1] = $dta{ENSEMBLE}[$e]->{BT_VELOCITY}[$b2-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   228
		$dta{ENSEMBLE}[$e]->{BT_VELOCITY}[$b2-1] = $tmp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   229
		                
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   230
		$tmp = $dta{ENSEMBLE}[$e]->{BT_CORRELATION}[$b1-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   231
		$dta{ENSEMBLE}[$e]->{BT_CORRELATION}[$b1-1] = $dta{ENSEMBLE}[$e]->{BT_CORRELATION}[$b2-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   232
		$dta{ENSEMBLE}[$e]->{BT_CORRELATION}[$b2-1] = $tmp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   233
		                
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   234
		$tmp = $dta{ENSEMBLE}[$e]->{BT_EVAL_AMPLITUDE}[$b1-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   235
		$dta{ENSEMBLE}[$e]->{BT_EVAL_AMPLITUDE}[$b1-1] = $dta{ENSEMBLE}[$e]->{BT_EVAL_AMPLITUDE}[$b2-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   236
		$dta{ENSEMBLE}[$e]->{BT_EVAL_AMPLITUDE}[$b2-1] = $tmp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   237
		                
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   238
		$tmp = $dta{ENSEMBLE}[$e]->{BT_PERCENT_GOOD}[$b1-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   239
		$dta{ENSEMBLE}[$e]->{BT_PERCENT_GOOD}[$b1-1] = $dta{ENSEMBLE}[$e]->{BT_PERCENT_GOOD}[$b2-1];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   240
		$dta{ENSEMBLE}[$e]->{BT_PERCENT_GOOD}[$b2-1] = $tmp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   241
    }		                
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   242
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   243
	for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   244
		$tmp = $dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$b1-1];
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   245
		$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$b1-1] = $dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$b2-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   246
		$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$b2-1] = $tmp;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   247
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   248
		$tmp = $dta{ENSEMBLE}[$e]->{CORRELATION}[$bin][$b1-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   249
		$dta{ENSEMBLE}[$e]->{CORRELATION}[$bin][$b1-1] = $dta{ENSEMBLE}[$e]->{CORRELATION}[$bin][$b2-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   250
		$dta{ENSEMBLE}[$e]->{CORRELATION}[$bin][$b2-1] = $tmp;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   251
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   252
		$tmp = $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$bin][$b1-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   253
		$dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$bin][$b1-1] = $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$bin][$b2-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   254
		$dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$bin][$b2-1] = $tmp;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   255
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   256
		$tmp = $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][$b1-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   257
		$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][$b1-1] = $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][$b2-1];
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   258
		$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][$b2-1] = $tmp;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   259
	}
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   260
	return 1;
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   261
}
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   262
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   263
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   264
#--------------------------------------------------
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   265
# transform earth to beam coordinates
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   266
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   267
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   268
{ my($checked);
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   269
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   270
	sub earth2beam()
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   271
	{
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   272
		unless ($checked) {
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   273
			die("$ARGV[0]: earth-coordinate data required\n")
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   274
				unless ($dta{EARTH_COORDINATES});
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   275
			die("$ARGV[0]: single-ping ensembles required\n")
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   276
				unless ($dta{PINGS_PER_ENSEMBLE} == 1);
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   277
			$dta{BEAM_COORDINATES} = 1; undef($dta{EARTH_COORDINATES});
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   278
			$checked = 1;
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   279
		}
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   280
	    
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   281
		for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   282
			if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][3] == 100) {			# 4-beam solution
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   283
               	@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]} =
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   284
					velEarthToBeam(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]});
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   285
				@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin]} = (100,100,100,100);
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   286
			} else {															# 3-beam solution or no solution
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   287
				undef(@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]});
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   288
				@{$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin]} = (0,0,0,0);
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   289
			}
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   290
		}
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   291
	
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   292
		return 1;
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   293
	}
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   294
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   295
}
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   296
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   297
#--------------------------------------------------
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   298
# transform instrument to beam coordinates
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   299
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   300
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   301
{ my($checked);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   302
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   303
	sub instrument2beam()
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   304
	{
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   305
		unless ($checked) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   306
			die("$ARGV[0]: instrument-coordinate data required\n")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   307
				unless ($dta{INSTRUMENT_COORDINATES});
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   308
			die("$ARGV[0]: single-ping ensembles required\n")
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   309
				unless ($dta{PINGS_PER_ENSEMBLE} == 1);
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   310
			$dta{BEAM_COORDINATES} = 1; undef($dta{INSTRUMENT_COORDINATES});
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   311
			$checked = 1;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   312
		}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   313
	    
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   314
		for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   315
			@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]} =
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   316
				velInstrumentToBeam(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]});
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   317
		}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   318
	
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   319
		return 1;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   320
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   321
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   322
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   323
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   324
#--------------------------------------------------
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   325
# transform instrument to earth coordinates
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   326
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   327
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   328
{ my($checked);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   329
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   330
	sub instrument2earth()
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   331
	{
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   332
		unless ($checked) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   333
			die("$ARGV[0]: instrument-coordinate data required\n")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   334
				unless ($dta{INSTRUMENT_COORDINATES});
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   335
			die("$ARGV[0]: single-ping ensembles required\n")
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   336
				unless ($dta{PINGS_PER_ENSEMBLE} == 1);
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   337
			$dta{EARTH_COORDINATES} = 1; undef($dta{INSTRUMENT_COORDINATES});
34
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   338
			$checked = 1;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   339
		}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   340
	    
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   341
		for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   342
			@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]} =
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   343
				velInstrumentToEarth(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]});
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   344
		}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   345
	
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   346
		return 1;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   347
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   348
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   349
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 32
diff changeset
   350
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   351
#--------------------------------------------------
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   352
# transform beam to earth coordinates
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   353
#--------------------------------------------------
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   354
36
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   355
{ my($checked);
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   356
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   357
	sub beam2earth()
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   358
	{
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   359
		unless ($checked) {
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   360
			die("$ARGV[0]: beam-coordinate data required\n")
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   361
				unless ($dta{BEAM_COORDINATES});
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   362
			die("$ARGV[0]: single-ping ensembles required\n")
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   363
				unless ($dta{PINGS_PER_ENSEMBLE} == 1);
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   364
			$dta{EARTH_COORDINATES} = 1; undef($dta{BEAM_COORDINATES});
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   365
			$checked = 1;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   366
		}
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   367
	    
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   368
		for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) {
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   369
			@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]} =
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   370
				velBeamToEarth(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]});
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   371
			$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][0] = 100*$RDI_Coords::threeBeamFlag;	# 3-beam solution
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   372
			$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][1] = 0;								# error velocity not checked
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   373
			$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][2] =									# no solution -> more than 1 bad beam
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   374
								@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin]} ? 0 : 100;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   375
			$dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][2] =									# 4-beam solution
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   376
								100 -  $dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$bin][0];
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   377
		}
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   378
	
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   379
		return 1;
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   380
	}
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   381
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   382
}
515b06dae59c version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
   383
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   384
#--------------------------------------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   385
# Main Routine
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   386
#--------------------------------------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   387
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   388
if (defined($opt_x)) {															# edit instructions on the command line
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   389
	push(@EE,'*');
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   390
	my($id) = ($opt_x =~ m/^([A-Z]+)\s/);										# e.g. PITCH, ROLL, HEADING
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   391
	$opt_x = sprintf('$dta{ENSEMBLE}[$e]->{%s}',$id)
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   392
		if defined($id);
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   393
	push(@EX,$opt_x);
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   394
}		
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   395
31
b6ca27a1d19c pre Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   396
if (defined($opt_e)) {															# edit instructions in edit file
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   397
	open(EF,$opt_e) || die("$opt_e: $!\n");
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   398
	while (<EF>) {
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   399
		s/\#.*//;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   400
		next if m/^\s+$/;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   401
		my($ens,$expr) = m/^\s*(\*|\d+)\s+(.*)$/;
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   402
	
40
6a46e9d31106 after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents: 37
diff changeset
   403
		my($id) = ($expr =~ m/^([A-Z]+)\s/);									# e.g. PITCH, ROLL, HEADING
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   404
		$expr = sprintf('$dta{ENSEMBLE}[$e]->{%s}',$id)
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   405
			if defined($id);
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   406
		    
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   407
		push(@EE,$ens);
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   408
		push(@EX,$expr);
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   409
	}
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   410
	close(EF);
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   411
}
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   412
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   413
for (local($e)=my($eei)=0; $e<@{$dta{ENSEMBLE}}; $e++) {						# local() needed for p(), r(), h()
32
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   414
	$dta{ENSEMBLE}[$e]->{DATA_SOURCE_ID} = 0xE0									# mark all ensembles except first
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 31
diff changeset
   415
		unless ($opt_k || $e==0);
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   416
	if ($EE[$eei] eq '*' || $EE[$eei] == $dta{ENSEMBLE}[$e]->{NUMBER}) {		# match => edit
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   417
		eval($EX[$eei]) || die("$@ while executing <$EX[$eei]>\n");
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   418
	} elsif ($EE[$eei] > $dta{ENSEMBLE}[$e]->{NUMBER}) {						# next edit later in file => skip
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   419
		next;
28
7c7da52363c2 transport version
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 14
diff changeset
   420
	} else {																	# need next edit
14
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   421
		$eei++;
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   422
		last if ($eei >= @EE);
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   423
		redo;
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   424
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   425
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   426
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   427
print(STDERR "done\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   428
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   429
#----------------------------------------------------------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   430
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   431
print(STDERR "Writing $ARGV[1]...");				# write data
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   432
writeData($ARGV[1],\%dta);
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   433
print(STDERR "done\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   434
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   435
exit(0);