Changeset 448
- Timestamp:
- 09/19/11 17:41:14
- Files:
-
- raw2proc/trunk/raw2proc/baypoint_config_20101115.py (added)
- raw2proc/trunk/raw2proc/billymitchell_config_20090623.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/billymitchell_config_20110607.py (added)
- raw2proc/trunk/raw2proc/billymitchell_config_20110914.py (added)
- raw2proc/trunk/raw2proc/bogue_config_20090915.py (modified) (1 diff)
- raw2proc/trunk/raw2proc/crow_config_20090122.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/hampton_config_20080930.py (modified) (1 diff)
- raw2proc/trunk/raw2proc/morgan_config_20080701.py (modified) (1 diff)
- raw2proc/trunk/raw2proc/ncutil.py (modified) (1 diff)
- raw2proc/trunk/raw2proc/proc_avp_ascii_met.py (modified) (4 diffs)
- raw2proc/trunk/raw2proc/proc_avp_ysi_6600_v1_CDL2.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_avp_ysi_6600_v2_CDL2.py (modified) (3 diffs)
- raw2proc/trunk/raw2proc/proc_codar_totals.py (modified) (5 diffs)
- raw2proc/trunk/raw2proc/proc_cr1000_flow.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_cr1000_wq.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_cr10x_flow_v1.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_cr10x_flow_v2.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_cr10x_wq_v1.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_cr10x_wq_v2.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_nortek_wds_dw.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/proc_nortek_wpa_adcp.py (modified) (4 diffs)
- raw2proc/trunk/raw2proc/proc_rdi_dspec_dw.py (modified) (2 diffs)
- raw2proc/trunk/raw2proc/procutil.py (modified) (20 diffs)
- raw2proc/trunk/raw2proc/raw2proc.py (modified) (5 diffs)
- raw2proc/trunk/raw2proc/spin/spin_morgan_avp.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
raw2proc/trunk/raw2proc/billymitchell_config_20090623.py
r320 r448 7 7 'institution' : 'nccoos', 8 8 'config_start_date' : '2009-06-23 00:00:00', 9 'config_end_date' : None, # None or yyyy-mm-dd HH:MM:SS9 'config_end_date' : '2010-09-02 00:00:00', # None or yyyy-mm-dd HH:MM:SS 10 10 'packages' : ('sfas',), 11 11 } … … 23 23 'altitude_interval' : 5, # meters 24 24 'num_altitudes' : 39, 25 'sensor_elevation' : 0, # meters 25 'sensor_elevation' : 0, # meters (runway elev is at 5.2 m) 26 26 'plot_module' : 'billymitchell_sodar_plot', 27 27 'plot_names' : ('timeseries', 'wind_vectors', 'wind_barbs'), raw2proc/trunk/raw2proc/bogue_config_20090915.py
r320 r448 23 23 'nbins' : 20, 24 24 'bin_size' : 0.5, # meters 25 'transducer_ht' : 0.5, # meters above the bottom 26 # 'blanking_ht' : 0.41, # meters above transducer 27 'blanking_ht' : 0.4, # meters above transducer 25 'transducer_ht' : 0.75, # meters above the bottom 26 'blanking_ht' : 0.9, # meters above transducer 28 27 'plot_module' : 'bogue_adcp_plot', 29 28 'plot_names' : ('timeseries',), raw2proc/trunk/raw2proc/crow_config_20090122.py
r320 r448 27 27 'plot_module' : 'crow_flow_plot', 28 28 'plot_names' : ('timeseries',), 29 'csv_dir' : '/seacoos/data/nccoos/latest_csv', 30 'csv_vars' : ('time', 'rain','sontek_flow','sontek_wl'), 29 31 # 'nbins' : 69, 30 32 # 'bin_size' : 0.5, # meters … … 41 43 'plot_module' : 'crow_wq_plot', 42 44 'plot_names' : ('timeseries',), 45 'csv_dir' : '/seacoos/data/nccoos/latest_csv', 46 'csv_vars' : ('time', 'wtemp','cond','do_sat', 'do_mg', 'ph', 'turb', 'battvolts'), 43 47 }, 44 48 } raw2proc/trunk/raw2proc/hampton_config_20080930.py
r336 r448 8 8 # 9 9 'config_start_date' : '2008-09-30 00:00:00', 10 'config_end_date' : None, # None or yyyy-mm-dd HH:MM:SS10 'config_end_date' : '2010-10-19 00:00:00', # None or yyyy-mm-dd HH:MM:SS 11 11 'packages' : ('avp', 'met'), 12 12 } raw2proc/trunk/raw2proc/morgan_config_20080701.py
r336 r448 20 20 'raw_file_glob' : '*.[Dd][Aa][Tt]', 21 21 'proc_dir' : '/seacoos/data/nccoos/level1/morgan/avp/', 22 'process_module' : 'proc_avp_ysi_6600_v2_ CDL2',22 'process_module' : 'proc_avp_ysi_6600_v2_moving_point', 23 23 'utc_offset' : 5., # hours offset to Eastern Standard 24 24 'bin_size' : 0.1, # meters raw2proc/trunk/raw2proc/ncutil.py
r336 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <201 0-07-30 13:00:15haines>2 # Last modified: Time-stamp: <2011-05-05 15:31:37 haines> 3 3 """ 4 4 Create, update and load utilities for netcdf files raw2proc/trunk/raw2proc/proc_avp_ascii_met.py
r233 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-01-26 11:23:09haines>2 # Last modified: Time-stamp: <2010-12-09 16:15:23 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 57 57 # get sample datetime from filename 58 58 fn = sensor_info['fn'] 59 sample_dt_start = filt_datetime(fn) [0]59 sample_dt_start = filt_datetime(fn) 60 60 61 61 # if line has weird ascii chars -- remove it … … 254 254 'long_name': 'Number of wind samples in sample period', 255 255 'standard_name': 'number_of_samples', 256 'units': ' m s-1',256 'units': '', 257 257 }, 258 258 … … 290 290 ('lat', platform_info['lat']), 291 291 ('lon', platform_info['lon']), 292 ('z', 1),292 ('z', sensor_info['anemometer_height']), 293 293 # 294 294 ('time', data['time'][i]), raw2proc/trunk/raw2proc/proc_avp_ysi_6600_v1_CDL2.py
r336 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <2010- 05-12 11:19:45haines>2 # Last modified: Time-stamp: <2010-12-09 16:15:11 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 101 101 # get sample datetime from filename 102 102 fn = sensor_info['fn'] 103 sample_dt_start = filt_datetime(fn) [0]103 sample_dt_start = filt_datetime(fn) 104 104 105 105 # how many profiles in one file, count number of "Profile Time:" in lines raw2proc/trunk/raw2proc/proc_avp_ysi_6600_v2_CDL2.py
r336 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <201 0-05-26 14:26:42haines>2 # Last modified: Time-stamp: <2011-02-24 11:00:27 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 90 90 # get sample datetime from filename 91 91 fn = sensor_info['fn'] 92 sample_dt_start = filt_datetime(fn) [0]92 sample_dt_start = filt_datetime(fn) 93 93 94 94 # how many profiles in one file, count number of "Profile Time:" in lines … … 145 145 # if line has weird ascii chars -- skip it and iterate to next line 146 146 if re.search(r"[\x1a]", line): 147 print 'skipping bad data line ... ' + str(line)147 # print 'skipping bad data line ... ' + str(line) 148 148 continue 149 149 raw2proc/trunk/raw2proc/proc_codar_totals.py
r336 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <2010-0 7-30 12:57:22haines>2 # Last modified: Time-stamp: <2010-09-20 12:32:19 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 90 90 nrow = int(v) 91 91 92 if nrow :92 if nrow>2: 93 93 # read data from string of lines but make it behave like a file object with StringIO 94 94 s = StringIO(''.join(lines)) … … 96 96 d = numpy.loadtxt(s, comments='%') 97 97 # lat, lon, u, v = numpy.loadtxt(s, usecols=(0,1,2,3), comments='%', unpack=True) 98 98 99 if 'TOT4' in ftype: 99 100 lon = d[:,0] … … 118 119 s6 = d[:,19] 119 120 120 uim = griddata(lon, lat, wu, xi, yi) 121 vim = griddata(lon, lat, wv, xi, yi) 122 # returned masked array as an ndarray with masked values filled with fill_value 123 ui = uim.filled(fill_value=numpy.nan) 124 vi = vim.filled(fill_value=numpy.nan) 121 try: 122 uim = griddata(lon, lat, wu, xi, yi) 123 vim = griddata(lon, lat, wv, xi, yi) 124 # returned masked array as an ndarray with masked values filled with fill_value 125 ui = uim.filled(fill_value=numpy.nan) 126 vi = vim.filled(fill_value=numpy.nan) 127 # print ui.shape 128 except IndexError: 129 print "raw2proc: IndexError in griddata() -- skipping data" 125 130 126 131 # --------------------------------------------------------------- 127 128 132 i = 0 129 133 data['dt'][i] = sample_dt # … … 132 136 data['lat'] = yi # new latitude grid 133 137 134 if nrow :138 if nrow and nrow>2: 135 139 # use transpose so order is (time, x, y) for netcdf convention 136 140 data['u'][i] = ui.T # u-component of water velocity (cm/s) raw2proc/trunk/raw2proc/proc_cr1000_flow.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-07 14:32:39haines>2 # Last modified: Time-stamp: <2010-12-09 16:14:55 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 62 62 # get sample datetime from filename 63 63 fn = sensor_info['fn'] 64 sample_dt_start = filt_datetime(fn) [0]64 sample_dt_start = filt_datetime(fn) 65 65 66 66 # how many samples (don't count header 4 lines) raw2proc/trunk/raw2proc/proc_cr1000_wq.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-15 08:31:52haines>2 # Last modified: Time-stamp: <2010-12-09 16:14:48 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 56 56 # get sample datetime from filename 57 57 fn = sensor_info['fn'] 58 sample_dt_start = filt_datetime(fn) [0]58 sample_dt_start = filt_datetime(fn) 59 59 60 60 # how many samples (don't count header 4 lines) raw2proc/trunk/raw2proc/proc_cr10x_flow_v1.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-07 15:02:51haines>2 # Last modified: Time-stamp: <2010-12-09 16:14:39 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 74 74 # get sample datetime from filename 75 75 fn = sensor_info['fn'] 76 sample_dt_start = filt_datetime(fn) [0]76 sample_dt_start = filt_datetime(fn) 77 77 78 78 # how many samples raw2proc/trunk/raw2proc/proc_cr10x_flow_v2.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-07 15:03:02haines>2 # Last modified: Time-stamp: <2010-12-09 16:14:26 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 92 92 # get sample datetime from filename 93 93 fn = sensor_info['fn'] 94 sample_dt_start = filt_datetime(fn) [0]94 sample_dt_start = filt_datetime(fn) 95 95 96 96 # how many samples raw2proc/trunk/raw2proc/proc_cr10x_wq_v1.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-15 08:32:19 haines>2 # Last modified: Time-stamp: <2010-12-09 16:14:19 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 52 52 # get sample datetime from filename 53 53 fn = sensor_info['fn'] 54 sample_dt_start = filt_datetime(fn) [0]54 sample_dt_start = filt_datetime(fn) 55 55 56 56 # how many samples raw2proc/trunk/raw2proc/proc_cr10x_wq_v2.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-15 08:32:33haines>2 # Last modified: Time-stamp: <2010-12-09 16:14:11 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 89 89 # get sample datetime from filename 90 90 fn = sensor_info['fn'] 91 sample_dt_start = filt_datetime(fn) [0]91 sample_dt_start = filt_datetime(fn) 92 92 93 93 # how many samples raw2proc/trunk/raw2proc/proc_nortek_wds_dw.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-10-28 17:27:56 haines>2 # Last modified: Time-stamp: <2010-12-09 16:13:56 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 92 92 # get sample datetime from filename 93 93 fn = sensor_info['fn'] 94 sample_dt_start = filt_datetime(fn) [0]94 sample_dt_start = filt_datetime(fn) 95 95 96 96 # try getting sample date/times from .wap raw2proc/trunk/raw2proc/proc_nortek_wpa_adcp.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <2010- 01-22 12:11:55haines>2 # Last modified: Time-stamp: <2010-12-09 16:13:37 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 73 73 # get sample datetime from filename 74 74 fn = sensor_info['fn'] 75 sample_dt_start = filt_datetime(fn) [0]75 sample_dt_start = filt_datetime(fn) 76 76 77 77 nbins = sensor_info['nbins'] # Number of bins in data … … 108 108 # Nortek awac beam angle is fixed at 25 deg 109 109 # adjustment is cos(25 deg) (which is approx .90*height) 110 bin_habs = (bin_habs*numpy.cos(25.*numpy.pi/180)) 110 # ------------------- 111 # bin_habs = (bin_habs*numpy.cos(25.*numpy.pi/180)) 112 # ------------------- 113 # commented out by SH -- 18 Aug 2010 114 # This does not apply to habs provided in .wpa. They 115 # are adjusted for beam angle in ascii output. 111 116 iaboveblank = bin_habs > th+bh+(bin_size) 112 117 … … 168 173 bin_number = wpa[0] 169 174 j = wpa[0]-1 170 print j175 # print j 171 176 hab[j] = wpa[1] 172 177 raw2proc/trunk/raw2proc/proc_rdi_dspec_dw.py
r211 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 08-10-01 12:47:26haines>2 # Last modified: Time-stamp: <2010-12-09 16:13:21 haines> 3 3 """ 4 4 how to parse data, and assert what data and info goes into … … 78 78 # print " ... %s" % (fn,) 79 79 if sensor_info['utc_offset']: 80 sample_dt = filt_datetime(fn) [0]+ \80 sample_dt = filt_datetime(fn) + \ 81 81 timedelta(hours=sensor_info['utc_offset']) 82 82 else: 83 sample_dt = filt_datetime(fn) [0]83 sample_dt = filt_datetime(fn) 84 84 85 85 # extract header (first 6 lines) raw2proc/trunk/raw2proc/procutil.py
r336 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <2010- 07-30 14:10:56haines>2 # Last modified: Time-stamp: <2010-12-15 09:32:53 haines> 3 3 """Utilities to help data processing 4 4 … … 13 13 from datetime import datetime, timedelta, tzinfo 14 14 from dateutil.tz import tzlocal, tzutc 15 from dateutil.parser import parse 15 16 import time 16 17 import math … … 38 39 39 40 cn = os.path.splitext(os.path.basename(config))[0] 40 cndt = filt_datetime(os.path.basename(config)) [0]41 cndt = filt_datetime(os.path.basename(config)) 41 42 pi = get_config(cn+'.platform_info') 42 43 if pi['config_start_date']: 43 config_start_dt = filt_datetime(pi['config_start_date']) [0]44 config_start_dt = filt_datetime(pi['config_start_date']) 44 45 elif pi['config_start_date'] == None: 45 46 config_start_dt = now_dt 46 47 if pi['config_end_date']: 47 config_end_dt = filt_datetime(pi['config_end_date']) [0]48 config_end_dt = filt_datetime(pi['config_end_date']) 48 49 elif pi['config_end_date'] == None: 49 50 config_end_dt = now_dt … … 95 96 this_month = dt 96 97 elif type(year) == str : 97 dt = filt_datetime(year) [0]98 dt = filt_datetime(year) 98 99 this_month = dt 99 100 # … … 138 139 return dt 139 140 140 def filt_datetime (input_string, remove_ext=True):141 def filt_datetime_test(input_string, remove_ext=True): 141 142 """ 142 143 Following the template, (YY)YYMMDDhhmmss … … 145 146 return its datetime object. 146 147 """ 148 149 from dateutil.parser import parse 147 150 148 151 # remove any trailing filename extension … … 152 155 (s, e) = splitext(input_string) 153 156 input_string = s 157 158 try: 159 dt = parse(input_string, fuzzy=True) 160 except ValueError, e: 161 print 'filt_datetime: Could not parse date. No date found in ', input_string 162 dt = None 163 else: 164 return dt 165 166 167 168 169 def filt_datetime(input_string, gran=False, remove_ext=True): 170 """ 171 Following the template, (YY)YYMMDDhhmmss 172 and versions with of this with decreasing time precision, 173 find the most precise, reasonable string match and 174 return its datetime object. 175 176 gran=False don't return granularity number 177 178 179 """ 180 181 # remove any trailing filename extension 182 from os.path import splitext 183 import re 184 if remove_ext: 185 (s, e) = splitext(input_string) 186 input_string = s 154 187 155 188 # YYYYMMDDhhmmss and should handle most cases of the stamp … … 161 194 162 195 case1_regex = r""" 163 # case 1: (YY)YYMMDDhhmmss164 (\d{4} |\d{2}) # 2- or 4-digit YEAR (e.g. '07' or '2007')196 # case 1: YYYYMMDDhhmmss 197 (\d{4}) # 2- or 4-digit YEAR (e.g. '07' or '2007') 165 198 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 166 199 (\d{2}) # 2-digit MONTH (e.g. '12') … … 176 209 177 210 case2_regex = r""" 178 # case 2: (YY)YYMMDDhhmm (no seconds)179 (\d{4} |\d{2}) # 2- or 4-digit YEAR211 # case 2: YYYYMMDDhhmm (no seconds) 212 (\d{4}) # 2- or 4-digit YEAR 180 213 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 181 214 (\d{2}) # 2-digit MONTH … … 189 222 190 223 case3_regex = r""" 191 # case 3: (YY)YYMMDDhh (no seconds, no minutes)192 (\d{4} |\d{2}) # 2- or 4-digit YEAR224 # case 3: YYYYMMDDhh (no seconds, no minutes) 225 (\d{4}) # 2- or 4-digit YEAR 193 226 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 194 227 (\d{2}) # 2-digit MONTH … … 200 233 201 234 case4_regex = r""" 202 # case 4: (YY)YYMMDD (no time values, just date)203 (\d{4} |\d{2}) # 2- or 4-digit YEAR235 # case 4: YYYYMMDD (no time values, just date) 236 (\d{4}) # 2- or 4-digit YEAR 204 237 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 205 238 (\d{2}) # 2-digit MONTH … … 209 242 210 243 case5_regex = r""" 211 # case 5: (YY)YYMM (no time values, just month year) 212 (\d{4}|\d{2}) # 2- or 4-digit YEAR 244 # case 5: YYYYMM (no time values, just month year) 245 (\d{4}) # 2- or 4-digit YEAR 246 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 247 (\d{2}) # 2-digit MONTH 248 """ 249 250 case6_regex = r""" 251 # case 6: YYMMDDhhmmss 252 (\d{2}) # 2- or 4-digit YEAR (e.g. '07' or '2007') 253 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 254 (\d{2}) # 2-digit MONTH (e.g. '12') 255 \D? # optional 1 character non-digit separator 256 (\d{2}) # 2-digit DAY of month (e.g. '10') 257 \D? # optional 1 character non-digit separator (e.g. ' ' or 'T') 258 (\d{2}) # 2-digit HOUR (e.g. '10') 259 \D? # optional 1 character non-digit separator (e.g. ' ' or ':') 260 (\d{2}) # 2-digit MINUTE (e.g. '10') 261 \D? # optional 1 character non-digit separator (e.g. ' ' or ':') 262 (\d{2}) # 2-digit SECOND (e.g. '10') 263 """ 264 265 case7_regex = r""" 266 # case 7: YYMMDDhhmm (no seconds) 267 (\d{2}) # 2- or 4-digit YEAR 268 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 269 (\d{2}) # 2-digit MONTH 270 \D? # optional 1 character non-digit separator 271 (\d{2}) # 2-digit DAY 272 \D? # optional 1 character non-digit separator (e.g. ' ' or 'T') 273 (\d{2}) # 2-digit HOUR 274 \D? # optional 1 character non-digit separator (e.g. ' ' or ':') 275 (\d{2}) # 2-digit MINUTE 276 """ 277 278 case8_regex = r""" 279 # case 8: YYMMDDhh (no seconds, no minutes) 280 (\d{2}) # 2- or 4-digit YEAR 281 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 282 (\d{2}) # 2-digit MONTH 283 \D? # optional 1 character non-digit separator 284 (\d{2}) # 2-digit DAY 285 \D? # optional 1 character non-digit separator (e.g. ' ' or 'T') 286 (\d{2}) # 2-digit HOUR 287 """ 288 289 case9_regex = r""" 290 # case 9: YYMMDD (no time values, just date) 291 (\d{2}) # 2- or 4-digit YEAR 292 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 293 (\d{2}) # 2-digit MONTH 294 \D? # optional 1 character non-digit separator 295 (\d{2}) # 2-digit DAY 296 """ 297 298 case10_regex = r""" 299 # case 10: YYMM (no time values, just month year) 300 (\d{2}) # 2- or 4-digit YEAR 213 301 \D? # optional 1 character non-digit separator (e.g. ' ' or '-') 214 302 (\d{2}) # 2-digit MONTH … … 219 307 220 308 # cases are ordered from precise to more coarse resolution of time 221 cases = [case1_regex, case2_regex, case3_regex, case4_regex, case5_regex ]309 cases = [case1_regex, case2_regex, case3_regex, case4_regex, case5_regex, case6_regex, case7_regex, case8_regex, case9_regex] 222 310 patterns = [re.compile(c, re.VERBOSE) for c in cases] 223 311 matches = [p.search(input_string) for p in patterns] … … 255 343 daysdiff = abs(z.days) 256 344 # if this date unreasonable (>10 years*365), throw it out 257 # something parsed wrong258 if daysdiff > 36 50:345 # garbage was parsed 346 if daysdiff > 3600: 259 347 dt = None 260 348 else: 261 349 dt = None 262 263 350 # place datetime object or None within sequence of matches 264 351 matches[ind] = dt … … 275 362 else: 276 363 dt = matches[ind] 277 return dt,ind 364 if gran: 365 return dt,ind 366 else: 367 return dt 278 368 279 369 def display_time_diff(diff): … … 341 431 new_dt = numpy.insert(numpy.array(dt), igap+1, dt_insert) 342 432 # insert NaN value at the gaps (insert placed just before obs) 343 new_data = numpy.insert(numpy.array(data ), igap+1, numpy.nan, axis=0)433 new_data = numpy.insert(numpy.array(data, dtype=float), igap+1, numpy.nan, axis=0) 344 434 # if all the data is NaN, then autoscale crocks. This prevents 345 435 # throwing an error (but be careful if using for anything other than grafs) … … 625 715 val = vd[-1] 626 716 627 # if can take the length of val 628 # probably a list, tuple 717 # if can take the length of val, val is probably a list, tuple of profile data 629 718 # there will be more than one value of which we want a mean (ignoring NaN') 630 719 if bool('__len__' in dir(val)): 631 val = numpy.mean(numpy.ma.masked_where(numpy.isnan(val), val)) 720 val = numpy.mean(numpy.ma.masked_where(numpy.isnan(val), val)) 721 var_name_str = 'Depth Averaged '+var_name_str 632 722 633 723 # to metric … … 640 730 valunits_from = 'degC' 641 731 valunits_to = 'degC' 642 elif 'velocity' in sn :732 elif 'velocity' in sn or 'speed' in sn or 'current' in sn: 643 733 valunits_to = 'm s-1' 644 734 elif 'flux' in sn or sn in ('discharge',): … … 679 769 valunits_from = 'degC' 680 770 valunits_to = 'degF' 681 elif 'velocity' in sn :771 elif 'velocity' in sn or 'speed' in sn or 'current' in sn: 682 772 valunits_to = 'knots' 683 773 elif 'flux' in sn or sn in ('discharge',): … … 716 806 if vn=='time': 717 807 f.write('"**%s:** %s", ""\n' % ('Sample Time', last_dt_str)) 808 elif vn=='blank': 809 f.write('"%s", "%s", "%s"\n' % (' ', ' ', ' ')) 718 810 else: 719 811 f.write('"%s", "%s", "%s"\n' % (var_name_str, metric_str, english_str)) raw2proc/trunk/raw2proc/raw2proc.py
r320 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-05 21:32:18 haines>2 # Last modified: Time-stamp: <2011-02-17 10:57:48 haines> 3 3 """Process raw data to monthly netCDF data files 4 4 … … 109 109 # datetime from filename 110 110 cn = os.path.splitext(os.path.basename(config))[0] 111 cndt = filt_datetime(os.path.basename(config)) [0]111 cndt = filt_datetime(os.path.basename(config)) 112 112 pi = get_config(cn+'.platform_info') 113 113 if pi['config_start_date']: 114 config_start_dt = filt_datetime(pi['config_start_date']) [0]114 config_start_dt = filt_datetime(pi['config_start_date']) 115 115 elif pi['config_start_date'] == None: 116 116 config_start_dt = now_dt 117 117 if pi['config_end_date']: 118 config_end_dt = filt_datetime(pi['config_end_date']) [0]118 config_end_dt = filt_datetime(pi['config_end_date']) 119 119 elif pi['config_end_date'] == None: 120 120 config_end_dt = now_dt … … 144 144 # datetime from filename 145 145 cn = os.path.splitext(os.path.basename(config))[0] 146 cndt = filt_datetime(os.path.basename(config)) [0]146 cndt = filt_datetime(os.path.basename(config)) 147 147 pi = get_config(cn+'.platform_info') 148 148 if pi['config_end_date'] == None: … … 180 180 # compute datetime for each file 181 181 for fn in all_raw_files: 182 # JC changes 183 fndt_tuple = filt_datetime(os.path.basename(fn)) 184 fndt = fndt_tuple[0] 182 (fndt, granularity) = filt_datetime(os.path.basename(fn), gran=True) 185 183 186 184 # "ind" var from filt_datetime() - what level of granularity was used 187 granularity = fndt_tuple[1]188 185 if granularity == 4: 189 186 # change dt_start to before monthly filename filt_datetime() date 190 187 dt_start = si['proc_start_dt']-timedelta(days=31) 191 188 # print dt_start 192 # end JC changes 189 193 190 if fndt: 194 191 if dt_start <= fndt <= dt_end or m: … … 203 200 now_dt.replace(microsecond=0) 204 201 if pi['config_start_date']: 205 config_start_dt = filt_datetime(pi['config_start_date']) [0]202 config_start_dt = filt_datetime(pi['config_start_date']) 206 203 elif pi['config_start_date'] == None: 207 204 config_start_dt = now_dt 208 205 209 206 if pi['config_end_date']: 210 config_end_dt = filt_datetime(pi['config_end_date']) [0]207 config_end_dt = filt_datetime(pi['config_end_date']) 211 208 elif pi['config_end_date'] == None: 212 209 config_end_dt = now_dt raw2proc/trunk/raw2proc/spin/spin_morgan_avp.py
r330 r448 1 1 #!/usr/bin/env python 2 # Last modified: Time-stamp: <20 09-12-16 12:41:39haines>2 # Last modified: Time-stamp: <2011-02-16 16:55:15 haines> 3 3 """Spin processing of raw data to monthly netCDF data files""" 4 4 5 5 from raw2proc import * 6 7 raw2proc('manual', 'morgan', 'avp', '2010_12') 8 raw2proc('manual', 'morgan', 'avp', '2010_11') 9 raw2proc('manual', 'morgan', 'avp', '2010_10') 10 raw2proc('manual', 'morgan', 'avp', '2010_09') 11 raw2proc('manual', 'morgan', 'avp', '2010_08') 12 raw2proc('manual', 'morgan', 'avp', '2010_07') 13 raw2proc('manual', 'morgan', 'avp', '2010_06') 14 raw2proc('manual', 'morgan', 'avp', '2010_05') 15 raw2proc('manual', 'morgan', 'avp', '2010_04') 16 raw2proc('manual', 'morgan', 'avp', '2010_03') 17 raw2proc('manual', 'morgan', 'avp', '2010_02') 18 raw2proc('manual', 'morgan', 'avp', '2010_01') 6 19 7 20 raw2proc('manual', 'morgan', 'avp', '2009_12')