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

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

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

Clean out plugin template parse function.

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