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

Changeset 117

Show
Ignore:
Timestamp:
02/19/08 14:59:59
Author:
haines
Message:

JC for SH, changes to procutil.py to pass along date granularity and raw2proc.py to capture and use that granularity index

Files:

Legend:

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

    r104 r117  
    11#!/usr/bin/env python 
    2 # Last modified:  Time-stamp: <2008-02-12 14:39:18 haines> 
     2# Last modified:  Time-stamp: <2008-02-15 17:30:53 haines> 
    33"""Utilities to help data processing  
    44 
     
    3737     
    3838        cn = os.path.splitext(os.path.basename(config))[0] 
    39         cndt = filt_datetime(os.path.basename(config)) 
     39        cndt = filt_datetime(os.path.basename(config))[0] 
    4040        pi = get_config(cn+'.platform_info') 
    4141        if pi['config_start_date']: 
    42             config_start_dt = filt_datetime(pi['config_start_date']) 
     42            config_start_dt = filt_datetime(pi['config_start_date'])[0] 
    4343        elif pi['config_start_date'] == None: 
    4444            config_start_dt = now_dt 
    4545        if pi['config_end_date']: 
    46             config_end_dt = filt_datetime(pi['config_end_date']) 
     46            config_end_dt = filt_datetime(pi['config_end_date'])[0] 
    4747        elif pi['config_end_date'] == None: 
    4848            config_end_dt = now_dt 
     
    9494        this_month = dt 
    9595    elif type(year) == str : 
    96         dt = filt_datetime(year) 
     96        dt = filt_datetime(year)[0] 
    9797        this_month = dt 
    9898    # 
     
    251251    # find the first (most precise) date match since there might be more than 
    252252    # as we searched more coarse templates, but now we have thrown out  
     253     
    253254    b = [bool(x) for x in matches] 
    254255    try: 
     
    259260    else: 
    260261       dt = matches[ind] 
    261        return dt 
     262       return dt,ind  
    262263 
    263264def display_time_diff(diff): 
  • raw2proc/trunk/raw2proc/raw2proc.py

    r104 r117  
    102102        # datetime from filename  
    103103        cn = os.path.splitext(os.path.basename(config))[0] 
    104         cndt = filt_datetime(os.path.basename(config)) 
     104        cndt = filt_datetime(os.path.basename(config))[0] 
    105105        pi = get_config(cn+'.platform_info') 
    106106        if pi['config_start_date']: 
    107             config_start_dt = filt_datetime(pi['config_start_date']) 
     107            config_start_dt = filt_datetime(pi['config_start_date'])[0] 
    108108        elif pi['config_start_date'] == None: 
    109109            config_start_dt = now_dt 
    110110        if pi['config_end_date']: 
    111             config_end_dt = filt_datetime(pi['config_end_date']) 
     111            config_end_dt = filt_datetime(pi['config_end_date'])[0] 
    112112        elif pi['config_end_date'] == None: 
    113113            config_end_dt = now_dt 
     
    137137        # datetime from filename  
    138138        cn = os.path.splitext(os.path.basename(config))[0] 
    139         cndt = filt_datetime(os.path.basename(config)) 
     139        cndt = filt_datetime(os.path.basename(config))[0] 
    140140        pi = get_config(cn+'.platform_info') 
    141141        if pi['config_end_date'] == None: 
     
    169169    # compute datetime for each file 
    170170    for fn in all_raw_files: 
    171         fndt = filt_datetime(os.path.basename(fn)) 
     171 
     172        # JC changes 
     173        fndt_tuple = filt_datetime(os.path.basename(fn)) 
     174        fndt = fndt_tuple[0]  
     175 
     176        # "ind" var from filt_datetime() - what level of granularity was used 
     177        granularity = fndt_tuple[1] 
     178        if granularity == 4: 
     179            # change dt_start to before monthly filename filt_datetime() date  
     180            dt_start = si['proc_start_dt']-timedelta(days=31) 
     181            print dt_start 
     182        # end JC changes 
     183 
    172184        if fndt: 
    173185            if dt_start <= fndt <= dt_end: 
    174186                raw_files.append(fn) 
    175                 raw_dts.append(fndt) 
    176          
     187                raw_dts.append(fndt)  
    177188    return (raw_files, raw_dts) 
    178189 
     
    183194    now_dt.replace(microsecond=0) 
    184195    if pi['config_start_date']: 
    185         config_start_dt = filt_datetime(pi['config_start_date']) 
     196        config_start_dt = filt_datetime(pi['config_start_date'])[0] 
    186197    elif pi['config_start_date'] == None: 
    187198        config_start_dt = now_dt 
    188199 
    189200    if pi['config_end_date']: 
    190         config_end_dt = filt_datetime(pi['config_end_date']) 
     201        config_end_dt = filt_datetime(pi['config_end_date'])[0] 
    191202    elif pi['config_end_date'] == None: 
    192203        config_end_dt = now_dt 
     
    348359        data = parse(pi, si, lines) 
    349360        # determine which index of data is within the specified timeframe (usually the month) 
     361 
     362        # initial code 
    350363        # data['in'] =  data['dt']>si['proc_start_dt'] and data['dt']<=si['proc_end_dt'] 
     364  
     365        # new code         
    351366        n = len(data['dt']) 
    352367        data['in'] = numpy.array([False for i in range(n)]) 
     
    354369            if val>si['proc_start_dt'] and val<=si['proc_end_dt']: 
    355370                data['in'][index] = True 
    356          
     371        # end new code         
     372 
    357373        # if any records are in the month then write to netcdf 
    358374        if data['in'].any():