| 25 | >>> main_data.format |
---|
| 26 | 'FORMAT-1' |
---|
| 27 | >>> main_data.first |
---|
| 28 | datetime.datetime(2009, 11, 17, 0, 30) |
---|
| 29 | >>> main_data.file_count |
---|
| 30 | 0 |
---|
| 31 | >>> main_data.comment_count |
---|
| 32 | 6 |
---|
| 33 | >>> main_data.variable_count |
---|
| 34 | 6 |
---|
| 35 | >>> main_data.elevation_count |
---|
| 36 | 39 |
---|
| 37 | >>> main_data.comments == {'device serial number':'A-F-0050', |
---|
| 38 | ... 'station code':'billymitchell', |
---|
| 39 | ... 'software version':'APRun 1.31', |
---|
| 40 | ... 'antenna azimuth angle [deg]':'0', |
---|
| 41 | ... 'height above ground [m]':'0', |
---|
| 42 | ... 'height above sea level [m]':'0'} |
---|
| 43 | True |
---|
| 44 | >>> main_data.variables == [{'label':'height','symbol':'z', |
---|
| 45 | ... 'units':'m','type':'Z1', |
---|
| 46 | ... 'mask':'0','gap':'99999',}, |
---|
| 47 | ... {'label':'wind speed','symbol':'speed', |
---|
| 48 | ... 'units':'m/s','type':'G1', |
---|
| 49 | ... 'mask':'0','gap':'99.99',}, |
---|
| 50 | ... {'label':'wind direction','symbol':'dir', |
---|
| 51 | ... 'units':'deg','type':'R1', |
---|
| 52 | ... 'mask':'0','gap':'999.9',}, |
---|
| 53 | ... {'label':'wind W','symbol':'W', |
---|
| 54 | ... 'units':'m/s','type':'S', |
---|
| 55 | ... 'mask':'0','gap':'99.99',}, |
---|
| 56 | ... {'label':'sigma W','symbol':'sigW', |
---|
| 57 | ... 'units':'m/s','type':'S', |
---|
| 58 | ... 'mask':'0','gap':'99.99',}, |
---|
| 59 | ... {'label':'backscatter','symbol':'bck', |
---|
| 60 | ... 'units':'','type':'S', |
---|
| 61 | ... 'mask':'0','gap':'9.99E+37',},] |
---|
| 62 | True |
---|
| 63 | >>> main_data.error == {'label':'error code', |
---|
| 64 | ... 'bits':'- - - - - - - - groundclutter - - - - - - -', |
---|
| 65 | ... 'mask':'IIIIIIIIWIIIIIII',} |
---|
| 66 | True |
---|
53 | | >>> main_data(datetime(2009, 11, 17, 0, 30)).stop |
---|
54 | | datetime.datetime(2009, 11, 17, 0, 30) |
---|
55 | | >>> main_data(datetime(2009, 11, 17, 0, 0),True).start |
---|
56 | | datetime.datetime(2009, 11, 17, 0, 0) |
---|
83 | | >>> main_data(datetime(2009, 11, 18, 0, 0)).stop |
---|
84 | | datetime.datetime(2009, 11, 18, 0, 0) |
---|
85 | | >>> main_data(datetime(2009, 11, 17, 23, 0),True).start |
---|
86 | | datetime.datetime(2009, 11, 17, 23, 0) |
---|
| 175 | |
---|
| 176 | self.format = format_header_spec[0] |
---|
| 177 | |
---|
| 178 | timestamp = format_header_spec[1] |
---|
| 179 | date, first, file_count = timestamp.split() |
---|
| 180 | date_year, date_month, date_day = date.split('-') |
---|
| 181 | first_hour, first_minute, first_second = first.split(':') |
---|
| 182 | self.first = datetime(int(date_year), |
---|
| 183 | int(date_month), |
---|
| 184 | int(date_day), |
---|
| 185 | int(first_hour), |
---|
| 186 | int(first_minute), # omit optional microseconds |
---|
| 187 | int(first_second)) # and tzinfo |
---|
| 188 | self.file_count = int(file_count) |
---|
| 189 | |
---|
| 190 | self.instrument_type = format_header_spec[2] |
---|
| 191 | |
---|
| 192 | comment_count, variable_count, elevation_count = \ |
---|
| 193 | format_header_spec[3].split() |
---|
| 194 | self.comment_count = int(comment_count) |
---|
| 195 | self.variable_count = int(variable_count) |
---|
| 196 | self.elevation_count = int(elevation_count) |
---|
150 | | if line.strip()] |
---|
| 203 | if not line.strip().startswith('#')] |
---|
| 204 | self.comments = dict([(name.strip(),value.strip()) |
---|
| 205 | for line |
---|
| 206 | in file_header_body[0:self.comment_count] |
---|
| 207 | for name,value |
---|
| 208 | in (line.split(':'),)]) |
---|
| 209 | self.file_type = file_header_body[self.comment_count] |
---|
| 210 | self.variables = [{'label':label.strip(), |
---|
| 211 | 'symbol':symbol.strip(), |
---|
| 212 | 'units':units.strip(), |
---|
| 213 | 'type':vtype.strip(), |
---|
| 214 | 'mask':mask.strip(), |
---|
| 215 | 'gap':gap.strip(),} |
---|
| 216 | for line |
---|
| 217 | in file_header_body[self.comment_count + 1:-1] |
---|
| 218 | for label,symbol,units,vtype,mask,gap |
---|
| 219 | in (line.split('#'),)] |
---|
| 220 | self.error = [{'label':label.strip(), |
---|
| 221 | 'bits':bits.strip(), |
---|
| 222 | 'mask':mask.strip(),} |
---|
| 223 | for label,bits,units,vtype,mask |
---|
| 224 | in (file_header_body[-1].split('#'),)][0] |
---|
| 225 | |
---|