def getdph_data(self, out):
        name = 'diesel_powerhouse_data.csv'
        data = get_api_data('power_house')
        data = data.set_index('community')
        data['Community'] = ''

        order = [
            'Community', 'total_generators', 'total_capacity',
            'Largest generator (in kW)', 'Sizing', "control_switchgear",
            "waste_heat_recovery_operational", "add_waste_heat_available",
            "est_curret_annual_heating_fuel_displaced",
            "est_potential_annual_heating_fuel_displaced"
        ]
        col_names = [
            'Community', 'Total Number of generators',
            'Total Capacity (in kW)', 'Largest generator (in kW)', 'Sizing',
            "Switchgear Suitable", "Waste Heat Recovery Opperational",
            "Add waste heat Avail",
            "Est. current annual heating fuel gallons displaced",
            "Est. potential annual heating fuel gallons displaced"
        ]

        #~ ### LOOP FOR REPLACING IDS
        for cid in sorted(list(data['community'].values)):
            data['Community'].ix[cid] = self.id_data.ix[cid]['name']

        data['Sizing'] = 'unknown'
        data['Largest generator (in kW)'] = 'unknown'

        data = data[order]
        data.columns = col_names

        data.to_csv(os.path.join(out, name), index=False)
        self.metadata[name] = 'api - ' + str(datetime.now())
    def getpce_data(self, out):
        name = 'power-cost-equalization-pce-data.csv'
        data = get_api_data('pcedata')

        order = [
            u'pce_id',
            u'community_names',
            u'year',
            u'month',
            u'residential_rate',
            u'pce_rate',
            u'effective_rate',
            u'fuel_price',
            u'fuel_used_gal',
            u'fuel_cost',
            u'diesel_efficiency',
            u'diesel_kwh_generated',
            u'hydro_kwh_generated',
            u'other_1_kwh_type',
            u'other_1_kwh_generated',
            u'other_2_kwh_type',
            u'other_2_kwh_generated',
            u'purchased_from',
            u'kwh_purchased',
            u'powerhouse_consumption_kwh',
            u'residential_kwh_sold',
            u'commercial_kwh_sold',
            u'community_kwh_sold',
            u'government_kwh_sold',
            u'unbilled_kwh',
        ]
        data[order].to_csv(os.path.join(out, name), index=False)

        self.metadata[name] = 'api - ' + str(datetime.now())
    def geteia_data(self, out):  # possible future use
        name = 'eia_sales.csv'
        data = get_api_data('eia_861_retail_sales')

        data['Community'] = ''

        order = [
            u'year',
            u'utility',
            'Community',
            u'residential_revenues',
            u'residential_sales',
            u'residential_customers',
            u'commercial_revenues',
            u'commercial_sales',
            u'commercial_customers',
            u'industrial_revenues',
            u'industrial_sales',
            u'industrial_customers',
            u'total_revenue',
            u'total_sales',
            u'total_customers',
        ]
        col_names = [
            'Data Year', 'Utility Number', 'Community',
            'Residential Thousand Dollars', 'Residential Megwatthours',
            'Residential Count', 'Commercial Thousand dollars',
            'Commercial Megwatthours', 'Commercial Count',
            'Industrial Thousand Dollars', 'Industrial Megwatthours',
            'Industrial Count', 'Total Thousand Dollars',
            'Total Megawatthours', 'Total CustomerCount'
        ]

        ### LOOP FOR REPLACING IDS
        #~ for cid in sorted(list(data['id'].values)):
        #~ data['id'].replace(
        #~ [cid],
        #~ [self.id_data.ix[cid]['name']],
        #~ inplace=True
        #~ )

        data = data[order]
        data.columns = col_names
        data.to_csv(os.path.join(out, name), index=False)

        self.metadata[name] = 'api - ' + str(datetime.now())
    def getfps_data(self, out):
        """get fuel price survey data
        """
        name = 'fuel-price-survey-data.csv'
        data = get_api_data('ahfc_fuel_survey_data')

        data = data.set_index('community')

        data["community__name"] = ''
        data["community__gnis_feature_id"] = ''
        data["community__census_code"] = ''

        order = [
            "community__name", 'community__gnis_feature_id',
            'community__census_code', "year", "month", "no_1_fuel_oil_price",
            "no_2_fuel_oil_price", "propane_price", "birch_price",
            "spruce_price", "unspecified_wood_price"
        ]

        col_names = [
            'community__name', 'community__gnis_feature_id',
            'community__census_code', 'year', 'month', 'no_1_fuel_oil_price',
            'no_2_fuel_oil_price', 'propane_price', 'birch_price',
            'spruce_price', 'unspecified_wood_price'
        ]

        ### LOOP FOR REPLACING IDS
        #~ print data.index
        for cid in sorted(set(data.index)):
            #~ print data.ix[cid]
            data['community_name'].ix[cid] = self.id_data.ix[cid]['name']
            data['community__gnis_feature_id'] .ix[cid]= \
                self.id_data.ix[cid]['gnis_feature_id']
            data['community__census_code'].ix[cid] = self.id_data.ix[cid][
                'census_code']

        data['Sizing'] = 'unknown'
        data['Largest generator (in kW)'] = 'unknown'

        data = data[order]
        data.columns = col_names

        #~ print data
        data.to_csv(os.path.join(out, name), index=False)
        self.metadata[name] = 'api - ' + str(datetime.now())
 def get_id_data(self):
     data = get_api_data('community')
     data = data.set_index('id')
     return data