Changeset 220
- Timestamp:
- 01/09/09 11:13:39
- Files:
-
- raw2proc/trunk/raw2proc/proc_avp_ascii_met.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
raw2proc/trunk/raw2proc/proc_avp_ascii_met.py
r218 r220 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <200 8-11-13 11:55:34haines>2 # Last modified: Time-stamp: <2009-01-08 15:27:29 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 58 58 fn = sensor_info['fn'] 59 59 sample_dt_start = filt_datetime(fn)[0] 60 61 # if line has weird ascii chars -- remove it 62 for index, line in enumerate(lines): 63 if re.search(r"[\x1a]", line): 64 # print '... ... remove unexpected ... ' + str(line) 65 lines.pop(index) 66 67 lines.sort() 60 68 N = len(lines) 61 69 data = { … … 71 79 72 80 i = 0 73 lines.sort()74 75 81 mvar = platform_info['mvar'] # Magnetic Variation at station 76 # mvar = -8.0 # (??????) 77 78 wnd = [] 82 79 83 for line in lines: 84 # if line has weird ascii chars -- skip it and iterate to next line 85 if re.search(r"[\x1a]", line): 86 print 'skipping bad data line ... ' + str(line) 87 continue 88 80 89 wnd = [] 90 81 91 # split line and parse float and integers 82 sw = re.split('[\s /\:]*', line)92 sw = re.split('[\s\/\:]*', line) 83 93 for s in sw: 84 94 m = re.search(REAL_RE_STR, s) … … 86 96 wnd.append(float(m.groups()[0])) 87 97 88 if len(wnd) ==12:98 if len(wnd)>=11: 89 99 # get sample datetime from data 90 100 sample_str = '%02d-%02d-%4d %02d:%02d:%02d' % tuple(wnd[0:6]) … … 100 110 u = wnd[9] # Easterly (?) Component (m/s) (mag or true??) 101 111 v = wnd[10] # Northerly (?) Component (m/s) (mag or true??) 102 nwnd = int(wnd[11]) # Number of samples in wind average 103 112 if len(wnd)>=12: 113 nwnd = int(wnd[11]) 114 else: 115 nwnd = numpy.nan # Number of samples in wind average 116 # prior to Sep 2008 number of samples were not recorded 117 104 118 # combine wind dir and buoy compass direction 105 119 # correct direction from magnetic N to true N … … 119 133 i=i+1 120 134 121 # if len(wnd) ==12135 # if len(wnd)>=11 122 136 # for line 123 137 … … 126 140 def creator(platform_info, sensor_info, data): 127 141 # 142 # subset data only to month being processed (see raw2proc.process()) 143 i = data['in'] 144 dt = data['dt'][i] 128 145 # 129 146 title_str = sensor_info['description']+' at '+ platform_info['location'] … … 151 168 'project_url' : 'http://nccoos.org', 152 169 # timeframe of data contained in file yyyy-mm-dd HH:MM:SS 153 'start_date' : d ata['dt'][0].strftime("%Y-%m-%d %H:%M:%S"),154 'end_date' : d ata['dt'][-1].strftime("%Y-%m-%d %H:%M:%S"),170 'start_date' : dt[0].strftime("%Y-%m-%d %H:%M:%S"), 171 'end_date' : dt[-1].strftime("%Y-%m-%d %H:%M:%S"), 155 172 'release_date' : now_dt.strftime("%Y-%m-%d %H:%M:%S"), 156 173 # … … 160 177 # 161 178 # must type match to data (e.g. fillvalue is real if data is real) 162 '_FillValue' : -99999.,179 '_FillValue' : numpy.nan, 163 180 } 164 181 … … 269 286 ) 270 287 271 # subset data only to month being processed (see raw2proc.process())272 i = data['in']273 274 288 # var data 275 289 var_data = ( … … 291 305 def updater(platform_info, sensor_info, data): 292 306 # 307 # subset data only to month being processed (see raw2proc.process()) 308 i = data['in'] 309 dt = data['dt'][i] 310 # 293 311 global_atts = { 294 312 # update times of data contained in file (yyyy-mm-dd HH:MM:SS) 295 313 # last date in monthly file 296 'end_date' : d ata['dt'][-1].strftime("%Y-%m-%d %H:%M:%S"),314 'end_date' : dt[-1].strftime("%Y-%m-%d %H:%M:%S"), 297 315 'release_date' : now_dt.strftime("%Y-%m-%d %H:%M:%S"), 298 316 #