NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/tower_buoy/trunk/bin/meta_data/meta_data_test.pm

Revision 7 (checked in by cbc, 18 years ago)

--

Line 
1 #meta_data.pm
2 #Time-stamp: <2005-08-06 18:17:28 lstearns>
3 #
4 #Abstract: This module will read in tables of tower related meta data
5 #  and output hash arrays of the information based on param id.  Hacked
6 #  together from the subroutine in tower_parse.perl and perl_defs.pm,
7 #  a piece of code from Brian Blanton (Thanks Brian!!).
8
9 # perl defs and subroutines common to quoddy nc/fc runs
10 # v11/07/2001 B.O.B.
11 # v02/09/2002 B.O.B. to work out of dmf
12 # v06/04/2002 B.O.B. added initial da stuff
13 # v19/08/2002 B.O.B. fixes for changes to "edu" from "com"
14 # v13/09/2002 B.O.B. added truxton stuff
15 # v13/12/2002 B.O.B. version for casco4b inclusion/ ssh assim
16 # vxx/09/2003 B.O.B. modified for SEACOOS
17 # v15/02/2004 B.O.B. turned into perl package provider (seacoos_sab_defs)
18
19
20 package meta_data;  # assumes seacoos_sab_defs.pm
21
22 use strict;
23 use warnings;
24 use vars qw();
25
26
27 BEGIN{
28    use Exporter ();
29    
30    our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
31
32    $VERSION="1.0";
33
34    @ISA = qw(Exporter);
35
36    @EXPORT = qw(
37                 %parse_info %parse_output
38                 %T1_conversion_coeff %T1_conversion_formula
39                 %LSRB_conversion_coeff %LSRB_conversion_formula
40                 %R4_conversion_coeff %R4_conversion_formula
41                 %conversion_coeff %conversion_formula
42                 %range %precision %derived %units
43                 %format %long_name %standard_name
44                 %description %sub_vars %dimensions
45                 %global_format %global_value
46                 %tower_lon %tower_lat
47                 @vars @globals
48     );
49
50    @EXPORT_OK=();
51 }
52
53
54 our(%parse_info,%parse_output,
55     %conversion_coeff,%conversion_formula,
56     %T1_conversion_coeff,%T1_conversion_formula,
57     %LSRB_conversion_coeff,%LSRB_conversion_formula,
58     %R4_conversion_coeff,%R4_conversion_formula,
59     %range,%precision,%derived,%units,
60     %format,%long_name,%standard_name,
61     %description,%sub_vars,%dimensions,
62     %global_format,%global_value,
63     %tower_lon,%tower_lat,
64     @vars,@globals
65    );
66
67 my($param_id,$parse_info,$parse_output,
68    $conversion_coeff,$conversion_formula,
69    $range,$precision,$derived,$units,
70    $format,$long_name,$standard_name,
71    $description,$sub_vars,@sub_vars,
72    $dimensions,$meta_data_dir,
73    $g_a_format,$g_a_value,$g_a_name,
74    $tower_id,$tower_lon,$tower_lat
75   );
76
77 #$meta_data_dir = '/afs/isis.unc.edu/depts/marine/workspace/hseim/'.
78 #    'sablam4/lstearns/perl/test_nemo/meta_data/';
79 $meta_data_dir = '/opt/local/seacoos/bin/meta_data/';
80
81 ######################################################################
82 ### Initialize Info ##################################################
83 #sub initialize_info {
84
85 #$meta_data_dir = "/afs/isis.unc.edu/depts/marine/workspace/hseim/".
86 #  "sablam3/seacoos/meta_data/";
87   #This section is fairly consistant, in fact I'd like to pull it out
88   #and put it in a seperate script that gets loaded.  This is to
89   #read in all of the tables of information that relate to parsing,
90   #conversion, and ancillary information about all of the variables.
91
92   ####################################################################
93   # Read Parsing Information Table
94   open(PARSING_INFO,"${meta_data_dir}parse_test.table");
95
96   #Loop through the lines of the file
97   while (<PARSING_INFO>) {
98     #Get rid of the carriage return.
99     chop;
100
101     #Ignore comments, that is, any line starting with a '#' character
102     #This is done by setting a comment line to an empty line
103     $_=~s/^^\#.*//;
104
105     #Consider only non-empty lines
106     if ($_) {
107       #Split lines of the table using 2 or more spaces (which
108       #allows for single spaces in the entries)
109       ($param_id,$parse_info,$parse_output) = split('\s{2,}');
110      
111       #Store information in hash arrays with the param id as the key
112       $parse_info{$param_id}=$parse_info;
113       $parse_output{$param_id}=$parse_output;
114     }
115   }
116   close(PARSING_INFO);
117
118   ####################################################################
119   # Read Conversions Table
120   open(T1_CONVERSION_INFO,"${meta_data_dir}T1_conversions.table");
121   while (<T1_CONVERSION_INFO>) {
122     chop;
123     $_=~s/^\#.*//;
124     if ($_) {
125       ($param_id,$conversion_coeff,$conversion_formula) = split('\s{2,}');
126       $T1_conversion_coeff{$param_id}=$conversion_coeff;
127       $T1_conversion_formula{$param_id}=$conversion_formula;
128     }
129   }
130   close(T1_CONVERSION_INFO);
131
132   ####################################################################
133   # Read Conversions Table
134   open(LSRB_CONVERSION_INFO,"${meta_data_dir}LSRB_conversions.table");
135   while (<LSRB_CONVERSION_INFO>) {
136     chop;
137     $_=~s/^\#.*//;
138     if ($_) {
139       ($param_id,$conversion_coeff,$conversion_formula) = split('\s{2,}');
140       $LSRB_conversion_coeff{$param_id}=$conversion_coeff;
141       $LSRB_conversion_formula{$param_id}=$conversion_formula;
142     }
143   }
144   close(LSRB_CONVERSION_INFO);
145
146   ####################################################################
147   # Read Conversions Table
148   open(R4_CONVERSION_INFO,"${meta_data_dir}R4_conversions.table");
149   while (<R4_CONVERSION_INFO>) {
150     chop;
151     $_=~s/^\#.*//;
152     if ($_) {
153       ($param_id,$conversion_coeff,$conversion_formula) = split('\s{2,}');
154       $R4_conversion_coeff{$param_id}=$conversion_coeff;
155       $R4_conversion_formula{$param_id}=$conversion_formula;
156     }
157   }
158   close(R4_CONVERSION_INFO);
159
160   ####################################################################
161   # Read Conversions Table
162   open(CONVERSION_INFO,"${meta_data_dir}conversions.table");
163   while (<CONVERSION_INFO>) {
164     chop;
165     $_=~s/^\#.*//;
166     if ($_) {
167       ($param_id,$conversion_coeff,$conversion_formula) = split('\s{2,}');
168       $conversion_coeff{$param_id}=$conversion_coeff;
169       $conversion_formula{$param_id}=$conversion_formula;
170     }
171   }
172   close(CONVERSION_INFO);
173
174   ####################################################################
175   # Read Variables Table
176   open(VARIABLE_INFO,"${meta_data_dir}variable.table");
177   while (<VARIABLE_INFO>) {
178     chop;
179     $_=~s/^\#.*//;
180     if ($_) {
181       ($param_id,$range,$precision,$derived,$units,$format,$dimensions,
182        $long_name,$standard_name,$description) = split('\s{2,}');
183       $range{$param_id}=$range;
184       $precision{$param_id}=$precision;
185       $derived{$param_id}=$derived;
186       $units{$param_id}=$units;
187       $format{$param_id} = $format;
188       $dimensions{$param_id} = $dimensions;
189       $long_name{$param_id}=$long_name;
190       $standard_name{$param_id}=$standard_name;
191       $description{$param_id}=$description;
192       push(@vars,"$param_id");
193     }
194   }
195   close(VARIABLE_INFO);
196
197   ####################################################################
198   # Read Sub_Vars Table
199   open(SUB_VAR_INFO,"${meta_data_dir}subvars.table");
200   while (<SUB_VAR_INFO>) {
201     chop;
202     $_=~s/^\#.*//;
203     if ($_) {
204       ($param_id,$sub_vars) = split('\s{2,}');
205       @sub_vars = split(',',$sub_vars);
206       @{$sub_vars{$param_id}}=@sub_vars;
207     }
208   }
209   close(SUB_VAR_INFO);
210
211   ####################################################################
212   # Read Globals Table
213   open(GLOBAL_INFO,"${meta_data_dir}globals.table");
214   while (<GLOBAL_INFO>) {
215     chop;
216     $_=~s/^\#.*//;
217     if ($_) {
218       ($g_a_name,$g_a_format,$g_a_value) = split('\s{2,}');
219       $global_format{$g_a_name}=$g_a_format;
220       $global_value{$g_a_name}=$g_a_value;
221       push(@globals,"$g_a_name");
222
223     }
224   }
225   close(GLOBAL_INFO);
226
227   ####################################################################
228   # Read Locations Table
229   open(LOCATION_INFO,"${meta_data_dir}locations.table");
230   while (<LOCATION_INFO>) {
231     chop;
232     $_=~s/^\#.*//;
233     if ($_) {
234         ($tower_id,$tower_lat,$tower_lon) = split('\s{2,}');
235         $tower_lat{$tower_id}=$tower_lat;
236         $tower_lon{$tower_id}=$tower_lon;
237     }
238   }
239   close(LOCATION_INFO);
240
241 #}
242
243
244
245 1;
246
Note: See TracBrowser for help on using the browser.