Ejemplo n.º 1
0
def precip_check(p_dates, p_vals, at_dates, at_vals, interval, cutoff):
    """
        this function checks to see if preciptation values lie with in the given 
    date and temperature values. If they do they are written to a new array 
    as is: else bad_val is written
    
    arguments:
        p_dates:     ((datetime) list)precip date array
        p_vals:      ((float) list)precip value array
        at_dates:    ((datetime) list)air temerature date array
        at_vals:     ((float) list)air temerature value array
        start:       (datetime) the start date
        end:         (datetime) the end date
        cutoff:      (float) the cutoff temperature
    
    returns 
        an array of corrected precip values
    """
    bad_val = 6999
    o_val = []
    index = 0
    while (index < len(p_dates)):
        if not(p_dates[index] == at_dates[index]):
            print_center("dates do not match for precipitation and air temp"
                                                                          ,'*')
            exit_on_failure()
            # how to handle this?
        print p_dates[index], p_vals[index], at_dates[index], at_vals[index]
        date = p_dates[index].replace(year = 1004)
        if not(csvd.is_in_interval(date, interval)):
            o_val.insert(index, bad_val)
            
        elif (at_vals[index] < cutoff):
            o_val.insert(index, bad_val)
        else:
            o_val.insert(index, p_vals[index])
        index += 1

    return o_val
Ejemplo n.º 2
0
def line_to_plot(interval, dates, vals, name = "def"):
    """
        generates a line to plot
    
    arguments:
        interval:   (datetime, datetime) the interval to graph
        dates:      ((datetime)list) dates to plot
        vals:       ((float)list) values to plot
    
    returns:
        a modifiable plot
    """
    o_date = []
    o_val = []
    index = 0 
    while (index < len(dates)):
        if (csvd.is_in_interval(dates[index], interval)):
            temp = dates[index]#.replace(1000)
            o_date.append(temp)
            o_val.append(vals[index])
        index += 1

    return plt.plot(o_date, o_val, label = name)