diff --git a/etl/air_source_heat_pump/AirSourceHeatPumpEfficiency.py b/etl/air_source_heat_pump/AirSourceHeatPumpEfficiency.py index 044cc830..e4eeedaf 100644 --- a/etl/air_source_heat_pump/AirSourceHeatPumpEfficiency.py +++ b/etl/air_source_heat_pump/AirSourceHeatPumpEfficiency.py @@ -22,68 +22,78 @@ class AirSourceHeatPumpEfficiency: def create_dataset(self): logger.info("Creating solar photo supply dataset") - all_counts = [] + heating_data = [] for dir in tqdm(self.file_directories): filepath = dir / "certificates.csv" df = pd.read_csv(filepath, low_memory=False) - df = df[~pd.isnull(df["UPRN"])] - df["UPRN"] = df["UPRN"].astype(int).astype(str) + # df = df[~pd.isnull(df["UPRN"])] + # df["UPRN"] = df["UPRN"].astype(int).astype(str) # Take entries after SAP12 df["LODGEMENT_DATE"] = pd.to_datetime(df["LODGEMENT_DATE"]) df = df[df["LODGEMENT_DATE"] > EARLIEST_EPC_DATE] - df = df[ - ~df["TENURE"].isin( - [ - "unknown", - "Not defined - use in the case of a new dwelling for which the intended tenure in not known. " - "It is not to be used for an existing dwelling" - ] - ) - ] + # df = df[ + # ~df["TENURE"].isin( + # [ + # "unknown", + # "Not defined - use in the case of a new dwelling for which the intended tenure in not known. " + # "It is not to be used for an existing dwelling" + # ] + # ) + # ] # Take entries that contain an air source heat pump df = df[ - df["MAINHEAT_DESCRIPTION"].str.contains("air source heat pump", case=False, na=False) - ] + ( + # Air source heat pumps + (df["MAINHEAT_DESCRIPTION"] == "Air source heat pump, radiators, electric") & + (df["MAINHEATCONT_DESCRIPTION"] == "Time and temperature zone control") + ) | + ( + # High heat retention storage + df["MAINHEATCONT_DESCRIPTION"] == "Controls for high heat retention storage heaters" + ) + ] # Drop rows that have a missing PROPERTY_TYPE, BUILT_FORM, CONSTRUCTION_AGE_BAND, TOTAL_FLOOR_AREA for col in ["PROPERTY_TYPE", "BUILT_FORM", "CONSTRUCTION_AGE_BAND", "TOTAL_FLOOR_AREA"]: df = df[~pd.isnull(df[col])] - # Get the columns we're interested in - df = df[ - [ - "PROPERTY_TYPE", - "BUILT_FORM", - "MAINHEAT_DESCRIPTION", - "MAINHEAT_ENERGY_EFF", - "MAINHEATCONT_DESCRIPTION", - "MAINHEATC_ENERGY_EFF", - "MAIN_FUEL", - "HOTWATER_DESCRIPTION", - "HOT_WATER_ENERGY_EFF", - "MAINS_GAS_FLAG" - ] + + heating_data.append(df) + + # temp + # import pickle + # with open("heating_data - delete me.pkl", "wb") as f: + # pickle.dump(heating_data, f) + + heating_df = pd.concat(heating_data) + # Clean construction age band + from etl.epc.DataProcessor import EPCDataProcessor + heating_df["CONSTRUCTION_AGE_BAND_CLEAN"] = heating_df["CONSTRUCTION_AGE_BAND"].apply( + lambda x: EPCDataProcessor.clean_construction_age_band(x) + ) + + ashp_df = heating_df[ + (heating_df["MAINHEAT_DESCRIPTION"] == "Air source heat pump, radiators, electric") & + # ~heating_df["CONSTRUCTION_AGE_BAND"].str.contains("England and Wales") + (~heating_df["CONSTRUCTION_AGE_BAND"].isin(["NO DATA!", "INVALID!"])) & + (heating_df["LODGEMENT_DATE"] >= pd.to_datetime("2019-01-01")) ] - - counts = df.groupby( + ashp_efficiencies = ( + ashp_df.groupby( [ - "PROPERTY_TYPE", - "BUILT_FORM", - "MAINHEAT_DESCRIPTION", + "CONSTRUCTION_AGE_BAND_CLEAN", + # "WALLS_DESCRIPTION", + # "ROOF_DESCRIPTION", "MAINHEAT_ENERGY_EFF", - "MAINHEATCONT_DESCRIPTION", - "MAINHEATC_ENERGY_EFF", - "MAIN_FUEL", - "HOTWATER_DESCRIPTION", - "HOT_WATER_ENERGY_EFF", - "MAINS_GAS_FLAG" ] - ).size().reset_index(name="count") + )["LMK_KEY"].count().reset_index() + ) - all_counts.append(counts) + ashp_df["MAINHEAT_ENERGY_EFF"].value_counts() - all_counts = pd.concat(all_counts) + ashp_efficiencies["CONSTRUCTION_AGE_BAND_CLEAN"].value_counts() + ashp_efficiency_agg all_counts_agg = all_counts.groupby( [ diff --git a/etl/air_source_heat_pump/app.py b/etl/air_source_heat_pump/app.py index ac87b34b..ed846d23 100644 --- a/etl/air_source_heat_pump/app.py +++ b/etl/air_source_heat_pump/app.py @@ -1,8 +1,10 @@ +import inspect from pathlib import Path from backend.app.plan.utils import get_cleaned from etl.air_source_heat_pump.AirSourceHeatPumpEfficiency import AirSourceHeatPumpEfficiency -DATA_DIRECTORY = Path(__file__).parent / "local_data" / "all-domestic-certificates" +file_src = inspect.getfile(lambda: None) +DATA_DIRECTORY = Path(file_src).parent / "local_data" / "all-domestic-certificates" def app(): diff --git a/recommendations/HeatingRecommender.py b/recommendations/HeatingRecommender.py index b4ca9a49..203bab87 100644 --- a/recommendations/HeatingRecommender.py +++ b/recommendations/HeatingRecommender.py @@ -434,7 +434,7 @@ class HeatingRecommender: ashp_costs_with_controls[key] += controls_rec[key] if controls_rec is None: - description = "Install an air source heat pump." + description = "Install a Mitsubish air source heat pump." elif already_installed: description = "The property already has an air source heat pump, no further action needed." else: @@ -457,8 +457,8 @@ class HeatingRecommender: ) simulation_config = { - "mainheat_energy_eff_ending": "Good", - "hot_water_energy_eff_ending": "Good" + "mainheat_energy_eff_ending": "Very Good", + "hot_water_energy_eff_ending": "Very Good" } description_simulation = { "mainheat-description": new_heating_description, @@ -725,7 +725,7 @@ class HeatingRecommender: description_prefix = "" controls_recommender.recommend( - heating_description="Electric storage heaters, radiators", description_prefix=description_prefix + heating_description="Electric storage heaters", description_prefix=description_prefix ) has_hhr = self.is_hhr_already_installed() @@ -740,7 +740,7 @@ class HeatingRecommender: self.property.main_heating["clean_description"] ]["hhr"]["mainheating_description"] else: - new_heating_description = "Electric storage heaters, radiators" + new_heating_description = "Electric storage heaters" # Set up artefacts, suitable for the simulation and regardless of controls heating_ending_config = MainHeatAttributes(new_heating_description).process()