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

root/sodar/branches/raw2proc-dev/proc_remtech_rawdata_sodar.py

Revision 183 (checked in by cbc, 16 years ago)

Initial checkin of raw2proc plugin.

Line 
1 #!/usr/bin/env python
2 """
3 Parse sodar data and assert what data and info goes into
4 creating and updating monthly netcdf files.
5
6 >> (parse, create, update) = load_processors('proc_rdi_rawdata_sodar')
7 >> data = parse(lines)
8 >> create(platform_info, sensor_info, data)
9 >> update(platform_info, sensor_info, data)
10 """
11
12 def parser(lines):
13     """
14     Parse and assign wind profile data from raw Sodar file.
15     """
16     return data
17
18 def creator(platform_info, sensor_info, data):
19     #
20     #
21     title_str = sensor_info['description']+' at '+ platform_info['location']
22     global_atts = {
23         'title' : title_str,
24         'institution' : 'Unversity of North Carolina at Chapel Hill (UNC-CH)',
25         'institution_url' : 'http://nccoos.unc.edu',
26         'institution_dods_url' : 'http://nccoos.unc.edu',
27         'metadata_url' : 'http://nccoos.unc.edu',
28         'references' : 'http://nccoos.unc.edu',
29         'contact' : 'Sara Haines (haines@email.unc.edu)',
30         #
31         'source' : 'fixed-profiler (acoustic doppler) observation',
32         'history' : 'Data processed by NCCOOS',
33         'comment' : 'File created using pycdf'+pycdfVersion()+' and numpy '+pycdfArrayPkg(),
34         # conventions
35         'Conventions' : 'CF-1.0; SEACOOS-CDL-v2.0',
36         # SEACOOS CDL codes
37         'format_category_code' : 'fixed-profiler',
38         'institution_code' : platform_info['instituion'],
39         'platform_code' : platform_info['id'],
40         'package_code' : sensor_info['id'],
41         # institution specific
42         'project' : 'North Carolina Coastal Ocean Observing System (NCCOOS)',
43         'project_url' : 'http://nccoos.unc.edu',
44         # timeframe of data contained in file yyyy-mm-dd HH:MM:SS
45         'start_date' : data['sample_dt'].strftime("%Y-%m-%d %H:%M:%S"),
46         'end_date' : data['sample_dt'].strftime("%Y-%m-%d %H:%M:%S"),
47         'release_date' : now.strftime("%Y-%m-%d %H:%M:%S"),
48         #
49         'creation_date' : now.strftime("%Y-%m-%d %H:%M:%S"),
50         'modification_date' : now.strftime("%Y-%m-%d %H:%M:%S"),
51         'process_level' : 'level1',
52         #
53         # must type match to data (e.g. fillvalue is real if data is real)
54         '_FillValue' : -99999.,
55         }
56
57     var_atts = {
58         # coordinate variables
59         'time' : {'short_name': 'time',
60                   'long_name': 'Time',
61                   'standard_name': 'time',
62                   'units': 'seconds since 1970-1-1 00:00:00 -0', # UTC
63                   'axis': 'T',
64                   },
65         'lat' : {'short_name': 'lat',
66              'long_name': 'Latitude',
67              'standard_name': 'latitude',
68              'reference':'geographic coordinates',
69              'units': 'degrees_north',
70              'valid_range':(-90.,90.),
71              'axis': 'Y',
72              },
73         'lon' : {'short_name': 'lon',
74                  'long_name': 'Longtitude',
75                  'standard_name': 'longtitude',
76                  'reference':'geographic coordinates',
77                  'units': 'degrees_east',
78                  'valid_range':(-180.,180.),
79                  'axis': 'Y',
80                  },
81         'z' : {'short_name': 'z',
82                'long_name': 'Height',
83                'standard_name': 'height',
84                'reference':'zero at sea-surface',
85                'units': 'm',
86                'axis': 'Z',
87                },
88         # data variables
89         'u': {'long_name': 'East/West Component of Current',
90               'standard_name': 'eastward_current',
91               'units': 'm s-1',
92               'reference': 'clockwise from True East',
93               },
94         'v': {'long_name': 'North/South Component of Current',
95               'standard_name': 'northward_current',                         
96               'units': 'm s-1',
97               'reference': 'clockwise from True North',
98               },
99         'w': {'long_name': 'Upward/Downward Component of Current',
100               'standard_name': 'upward_current',                         
101               'units': 'm s-1',
102               'positive': 'up',
103               },
104         'back_scatter':{'long_name': 'Backscatter',
105                         'standard_name': 'back_scatter',                   
106                         'units': 'decibels',
107                         },
108         'wtemp': {'long_name': 'Water Temperature',
109                   'standard_name': 'water_temperature',
110                   'units': 'degrees Celsius',
111                   },
112         }
113
114
115     # integer values
116     ntime=NC.UNLIMITED
117     nlat=1
118     nlon=1
119     nz=sensor_info['nbins']
120    
121     # dimension names use tuple so order of initialization is maintained
122     dimensions = ('ntime', 'nlat', 'nlon', 'nz')
123    
124     # using tuple of tuples so order of initialization is maintained
125     # using dict for attributes order of init not important
126     # use dimension names not values
127     # (varName, varType, (dimName1, [dimName2], ...))
128     var_inits = (
129         # coordinate variables
130         ('time', NC.INT, ('ntime',)),
131         ('lat', NC.FLOAT, ('nlat',)),
132         ('lon', NC.FLOAT, ('nlon',)),
133         ('z',  NC.FLOAT, ('nz',)),
134         # data variables
135         ('u', NC.FLOAT, ('ntime', 'nz')),
136         ('v', NC.FLOAT, ('ntime', 'nz')),
137         ('w', NC.FLOAT, ('ntime', 'nz')),
138         ('back_scatter', NC.FLOAT, ('ntime', 'nz')),
139         ('wtemp', NC.FLOAT, ('ntime',)),
140         )
141    
142     # var data
143     var_data = (
144         ('lat',  platform_info['lat']),
145         ('lon', platform_info['lon']),
146         ('z', []),
147         ('u', []),
148         ('v', []),
149         ('w', []),
150         ('back_scatter', []),
151         ('wtemp', []),
152         )
153
154     return (global_atts, dimensions, var_inits, var_data)
155
156 def updater(platform_info, sensor_info, data):
157     #
158     global_atts = {
159         # timeframe of data contained in file yyyy-mm-dd HH:MM:SS
160         'end_date' : data['sample_dt'].strftime("%Y-%m-%d %H:%M:%S"),
161         'release_date' : now.strftime("%Y-%m-%d %H:%M:%S"),
162         #
163         'creation_date' : now.strftime("%Y-%m-%d %H:%M:%S"),
164         'modification_date' : now.strftime("%Y-%m-%d %H:%M:%S"),
165         }
166     # var data
167     var_data = (
168         ('u', data['u']),
169         ('v', data['v']),
170         ('w',  data['w']),
171         ('back_scatter', data['back_scatter']),
172         ('wtemp', data['wtemp']),
173         )
174     return (global_atts, var_data)
175 #
176
Note: See TracBrowser for help on using the browser.