Exemple #1
0
def facility_vs_building_set(s):
    print s
    conn = uo.connect('all')
    if s == 'AI':
        ids = gbs.get_cat_set(['A', 'I'], conn)
    elif s == 'covered':
        ids = gbs.get_covered_set()
        df_f = pd.read_csv(os.getcwd() + '/input/FY/covered/Covered_Facilities_All Energy mmBTUs_FY14_EISA07Sec432_input.csv')
        facility_eisa = set(df_f['Facility_Number'].tolist())
        facility_eisa = [x[:8] for x in facility_eisa if type(x) != float]
    f_ids = [x for x in ids if '0000' in x]
    # for x in sorted(f_ids):
    #     print x
    b_ids = [x for x in ids if not '0000' in x]
    print 'total {0}, facility {1}, building {2}'.format(len(ids), len(f_ids), len(b_ids))
    bf_ids = ['{0}0000{1}'.format(x[:2], x[-2:]) for x in b_ids]
    print len(common)
    common = (set(bf_ids).intersection(f_ids))
    for y in common:
        print y
        print [x for x in b_ids if '{0}0000{1}'.format(x[:2], x[-2:]) == y]
    if s == 'covered':
        print 'eisa facility', len(facility_eisa)
        print 'common ids from eisa', len(set(f_ids).intersection(facility_eisa))
        print 'different ids from eisa', (set(f_ids).difference(facility_eisa))
        common = (set(f_ids).difference(facility_eisa))
        for y in common:
            print y
            print [x for x in b_ids if '{0}0000{1}'.format(x[:2], x[-2:]) == y]
Exemple #2
0
def facility_vs_building_set(s):
    print s
    conn = uo.connect('all')
    if s == 'AI':
        ids = gbs.get_cat_set(['A', 'I'], conn)
    elif s == 'covered':
        ids = gbs.get_covered_set()
        df_f = pd.read_csv(
            os.getcwd() +
            '/input/FY/covered/Covered_Facilities_All Energy mmBTUs_FY14_EISA07Sec432_input.csv'
        )
        facility_eisa = set(df_f['Facility_Number'].tolist())
        facility_eisa = [x[:8] for x in facility_eisa if type(x) != float]
    f_ids = [x for x in ids if '0000' in x]
    # for x in sorted(f_ids):
    #     print x
    b_ids = [x for x in ids if not '0000' in x]
    print 'total {0}, facility {1}, building {2}'.format(
        len(ids), len(f_ids), len(b_ids))
    bf_ids = ['{0}0000{1}'.format(x[:2], x[-2:]) for x in b_ids]
    print len(common)
    common = (set(bf_ids).intersection(f_ids))
    for y in common:
        print y
        print[x for x in b_ids if '{0}0000{1}'.format(x[:2], x[-2:]) == y]
    if s == 'covered':
        print 'eisa facility', len(facility_eisa)
        print 'common ids from eisa', len(
            set(f_ids).intersection(facility_eisa))
        print 'different ids from eisa', (set(f_ids).difference(facility_eisa))
        common = (set(f_ids).difference(facility_eisa))
        for y in common:
            print y
            print[x for x in b_ids if '{0}0000{1}'.format(x[:2], x[-2:]) == y]
Exemple #3
0
def table_for_robust_set():
    conn = uo.connect('all')
    study_set = gbs.get_energy_set('eui').intersection(gbs.get_cat_set(['A', 'I'], conn))
    df = pd.read_csv(os.getcwd() + '/plot_FY_weather/html/table/action_saving.csv')
    df = df[df['Building_Number'].isin(study_set)]
    df.sort('Building_Number', inplace=True)
    df.to_csv(os.getcwd() + '/plot_FY_weather/html/table/action_saving_robustset.csv', index=False)
    return
Exemple #4
0
def table_for_robust_set():
    conn = uo.connect('all')
    study_set = gbs.get_energy_set('eui').intersection(
        gbs.get_cat_set(['A', 'I'], conn))
    df = pd.read_csv(os.getcwd() +
                     '/plot_FY_weather/html/table/action_saving.csv')
    df = df[df['Building_Number'].isin(study_set)]
    df.sort('Building_Number', inplace=True)
    df.to_csv(os.getcwd() +
              '/plot_FY_weather/html/table/action_saving_robustset.csv',
              index=False)
    return
Exemple #5
0
def study_set_plot():
    conn = uo.connect('all')
    with conn:
        # df1 = pd.read_sql('SELECT DISTINCT Building_Number, Fiscal_Year FROM EUAS_monthly', conn)
        df1 = pd.read_sql(
            'SELECT DISTINCT Building_Number, Fiscal_Year FROM eui_by_fy',
            conn)
        df2 = pd.read_sql('SELECT Building_Number, Cat FROM EUAS_category',
                          conn)
    meter_set = gbs.get_action_set('high_level_ECM', ['Advanced Metering'])
    df = pd.merge(df1, df2, on='Building_Number', how='left')
    df = df[df['Fiscal_Year'] > 2006]
    df = df[df['Fiscal_Year'] < 2016]
    df3 = df.groupby('Building_Number').filter(lambda x: len(x) > 5)
    ai_set = gbs.get_cat_set(['A', 'I'], conn)
    # invest = gbs.get_invest_set()[-1]
    invest = gbs.get_ecm_set()
    all_building = set(df3['Building_Number'].tolist())
    print 'all building > 5 years of data: {0}'.format(len(all_building))
    print 'all building > 5 years of data + ecm: {0}'.format(
        len(all_building.intersection(invest)))
    print 'all building > 5 years of data + meter: {0}'.format(
        len(all_building.intersection(meter_set)))

    df4 = df[df['Cat'].isin(
        ['A', 'I'])].groupby('Building_Number').filter(lambda x: len(x) > 5)
    ai_building = set(df4['Building_Number'].tolist())
    print 'A + I building > 5 years of data: {0}'.format(len(ai_building))
    print 'A + I building > 5 years of data + ecm: {0}'.format(
        len(ai_building.intersection(invest)))
    print 'A + I building > 5 years of data + meter: {0}'.format(
        len(ai_building.intersection(meter_set)))

    print 'elec ', len(gbs.get_energy_set('elec').intersection(ai_set))
    print 'elec + ecm', len(
        gbs.get_energy_set('elec').intersection(ai_set).intersection(invest))
    print 'elec + meter', len(
        gbs.get_energy_set('elec').intersection(ai_set).intersection(
            meter_set))

    print 'gas ', len(gbs.get_energy_set('gas').intersection(ai_set))
    print 'gas + ecm', len(
        gbs.get_energy_set('gas').intersection(ai_set).intersection(invest))
    print 'gas + meter', len(
        gbs.get_energy_set('gas').intersection(ai_set).intersection(meter_set))
    print 'eui', len(gbs.get_energy_set('eui').intersection(ai_set))
    print 'eui + ecm', len(
        gbs.get_energy_set('eui').intersection(ai_set).intersection(invest))
    print 'eui + meter', len(
        gbs.get_energy_set('eui').intersection(ai_set).intersection(meter_set))
    return
Exemple #6
0
def invest_cnt():
    conn = uo.connect('all')
    with conn:
        df = pd.read_sql(
            'SELECT DISTINCT Building_Number, high_level_ECM, detail_level_ECM FROM EUAS_ecm WHERE detail_level_ECM != \'GSALink\'',
            conn)
    eng_set = gbs.get_energy_set('eui')
    ai_set = gbs.get_cat_set(['A', 'I'], conn)
    study_set = eng_set.intersection(ai_set)
    df = df[df['Building_Number'].isin(study_set)]
    print df.groupby(['high_level_ECM', 'detail_level_ECM']).count()
    print len(df)
    df = df.groupby(['Building_Number']).filter(lambda x: len(x) == 1)
    print len(df)
    print df.head()
    print df.groupby(['high_level_ECM', 'detail_level_ECM']).count()
    return
Exemple #7
0
def count_invest():
    conn = uo.connect('all')
    with conn:
        df1 = pd.read_sql(
            'SELECT DISTINCT Building_Number, high_level_ECM FROM EUAS_ecm WHERE high_level_ECM != \'GSALink\'',
            conn)
        df2 = pd.read_sql(
            'SELECT DISTINCT Building_Number, ECM_program FROM EUAS_ecm_program',
            conn)
    eng_set = gbs.get_energy_set('eui')
    ai_set = gbs.get_cat_set(['A', 'I'], conn)
    study_set = eng_set.intersection(ai_set)
    df1.dropna(subset=['high_level_ECM'], inplace=True)
    df2.dropna(subset=['ECM_program'], inplace=True)
    df1 = df1[df1['Building_Number'].isin(study_set)]
    df2 = df2[df2['Building_Number'].isin(study_set)]
    print df1['high_level_ECM'].value_counts()
    print df2['ECM_program'].value_counts()
    return