Exemple #1
0
        df_ec_gaps = et.gap(path_out, df_ec, dtype, make_gap_plots)
        print "#################################################"

    if impute_values:
        df_met = et.impute_master(path_out, df_met)

    # run met calcs
    if make_calcs:
        if station == "s":
            df_calc = et.s_met_calcs(path_out, df_met, df_rad, df_ec, station, make_calc_plots)
        else:
            df_calc = et.d_met_calcs(df_met, df_rad, df_ec, station, make_calc_plots)

    # Output data to csv
    if csv_out:
        et.df_csv(df_ec, path_out + station_prefix + "EC.csv", "EC", "df_ec", output_echo)
        et.df_csv(
            df_ec_all,
            path_out + station_prefix + "EC_all.csv",
            "EC ALL",
            "df_ec_all",
            output_echo,
            index=False,
            header=False,
        )
        et.df_csv(df_met, path_out + station_prefix + "Met.csv", "MET", "df_met", output_echo)
        et.df_csv(df_rad, path_out + station_prefix + "RAD.csv", "RAD", "df_rad", output_echo)
        if make_calcs:
            et.df_csv(df_calc, path_out + station_prefix + "CALCS.csv", "CALCS", "df_calc", output_echo)
    timer.write(" Program  End: " + strftime("%Y-%m-%d %H:%M:%S") + "\n")
    timer.close()
Exemple #2
0
    df_q.loc[(df_q.solar < 10), 'xpt'] = 0

    # daily average of moving median alpha
    # w/o fillna, missing 6/6/13, 8/4/13-8/6/13, some of 8/16-17, 20-24, 26-30/13, 9/4-11/13 but near end?,
    # now fill gaps in rolling median while getting daily means ("forward" fill means not medians)
    ts_maa = df_p['alpha_rollmed'].resample('D', how='mean', fill_method='ffill')
    # MAA match merged into q the pandas way using index reset.set combos
    # my stackoverflow question:
    # http://stackoverflow.com/questions/24788147/pandas-lookup-daily-series-value-for-half-hour-dataframe-index
    df_q['Date'] = pd.to_datetime(df_q.index.date)
    df_q = df_q.reset_index().set_index('Date')
    df_q['MAA'] = ts_maa
    df_q = df_q.reset_index().set_index('yr_dy_t')
    # if e6 isnull, lookup MAA for day and multiply times xpt, if notnull, use e6
    # todo: excel spreadsheet vlookup calc will get a number even when MAA missing: TRUE!!!
    et.df_csv(df_q, path + 'df_q.csv', 'QQQQQ', df_name='df_q', echo=True)
    df_q.ix[pd.isnull(df_q['e6']), 'LE_gap_filled'] = df_q['xpt'] * df_q['MAA']
    df_q.ix[pd.notnull(df_q['e6']), 'LE_gap_filled'] = df_q['e6']

    ####################################################################
    # Get processed precip, water levels, and SR01Up_Avg from CALCS.
    fname = 'Stark_CALCS.csv'
    pathname = path + fname
    df_c = pd.read_csv(pathname,
                       keep_date_col=kdc, warn_bad_lines=True, error_bad_lines=False,
                       index_col='TIMESTAMP')
    df_c = df_c.drop(['0', 'ref_temp', 'precip', 'WL', 'Cp', 'del_T'], axis=1)
    # na_values=[-99999, 99999, 9999, 6999] ?
    df_q = df_q.combine_first(df_c)
    # "average Net Rad"
    df_q['mn_Rn'] = (df_q['REBS'] + df_q['Rn']) / 2