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

Changeset 220

Show
Ignore:
Timestamp:
01/09/09 11:13:39
Author:
haines
Message:

AVP fixed profiler CDL2; hampton processing added YSI 6600 V1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • raw2proc/trunk/raw2proc/proc_avp_ascii_met.py

    r218 r220  
    11#!/usr/bin/env python 
    2 # Last modified:  Time-stamp: <2008-11-13 11:55:34 haines> 
     2# Last modified:  Time-stamp: <2009-01-08 15:27:29 haines> 
    33""" 
    44how to parse data, and assert what data and info goes into 
     
    5858    fn = sensor_info['fn'] 
    5959    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() 
    6068    N = len(lines) 
    6169    data = { 
     
    7179 
    7280    i = 0  
    73     lines.sort() 
    74  
    7581    mvar = platform_info['mvar']  # Magnetic Variation at station 
    76     # mvar = -8.0 # (??????) 
    77  
    78     wnd = [] 
     82 
    7983    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             
    8089        wnd = [] 
     90 
    8191        # split line and parse float and integers 
    82         sw = re.split('[\s/\:]*', line) 
     92        sw = re.split('[\s\/\:]*', line) 
    8393        for s in sw: 
    8494            m = re.search(REAL_RE_STR, s) 
     
    8696                wnd.append(float(m.groups()[0])) 
    8797 
    88         if len(wnd)==12:                                                                              
     98        if len(wnd)>=11: 
    8999            # get sample datetime from data 
    90100            sample_str = '%02d-%02d-%4d %02d:%02d:%02d' % tuple(wnd[0:6]) 
     
    100110            u = wnd[9]         # Easterly (?) Component (m/s) (mag or true??) 
    101111            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             
    104118            # combine wind dir and buoy compass direction 
    105119            # correct direction from magnetic N to true N 
     
    119133            i=i+1 
    120134 
    121         # if len(wnd)==12 
     135        # if len(wnd)>=11 
    122136    # for line 
    123137 
     
    126140def creator(platform_info, sensor_info, data): 
    127141        # 
     142        # subset data only to month being processed (see raw2proc.process()) 
     143        i = data['in'] 
     144        dt = data['dt'][i] 
    128145        #  
    129146        title_str = sensor_info['description']+' at '+ platform_info['location'] 
     
    151168                'project_url' : 'http://nccoos.org', 
    152169                # timeframe of data contained in file yyyy-mm-dd HH:MM:SS 
    153                 'start_date' : data['dt'][0].strftime("%Y-%m-%d %H:%M:%S"), 
    154                 'end_date' : data['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"),  
    155172                'release_date' : now_dt.strftime("%Y-%m-%d %H:%M:%S"), 
    156173                # 
     
    160177                # 
    161178                # must type match to data (e.g. fillvalue is real if data is real) 
    162                 '_FillValue' : -99999.
     179                '_FillValue' : numpy.nan
    163180                } 
    164181 
     
    269286                ) 
    270287 
    271         # subset data only to month being processed (see raw2proc.process()) 
    272         i = data['in'] 
    273  
    274288        # var data  
    275289        var_data = ( 
     
    291305def updater(platform_info, sensor_info, data): 
    292306        # 
     307        # subset data only to month being processed (see raw2proc.process()) 
     308        i = data['in'] 
     309        dt = data['dt'][i] 
     310        # 
    293311        global_atts = {  
    294312                # update times of data contained in file (yyyy-mm-dd HH:MM:SS) 
    295313                # last date in monthly file 
    296                 'end_date' : data['dt'][-1].strftime("%Y-%m-%d %H:%M:%S"),  
     314                'end_date' : dt[-1].strftime("%Y-%m-%d %H:%M:%S"),  
    297315                'release_date' : now_dt.strftime("%Y-%m-%d %H:%M:%S"), 
    298316                #