mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Debugging dwelling below for floor uvalue
This commit is contained in:
parent
db7f28bfc6
commit
7382b17232
2 changed files with 55 additions and 8 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import pandas as pd
|
||||
import numpy as np
|
||||
from tqdm import tqdm
|
||||
import msgpack
|
||||
|
||||
|
|
@ -253,6 +254,7 @@ def make_uvalues(df):
|
|||
# ~~~~~~~~~~~~~~~~~~
|
||||
# Roof
|
||||
# ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
starting_roof_uvalue = x["roof_thermal_transmittance"]
|
||||
if pd.isnull(starting_roof_uvalue):
|
||||
starting_roof_uvalue = get_roof_u_value(
|
||||
|
|
@ -296,24 +298,28 @@ def make_uvalues(df):
|
|||
floor_type = "suspended" if x["is_suspended"] else "solid"
|
||||
wall_type = get_wall_type(**x)
|
||||
|
||||
starting_floor_uvalue = x["floor_thermal_transmittance"]
|
||||
if x["another_property_below"]:
|
||||
starting_floor_uvalue, ending_floor_uvalue = 0, 0
|
||||
else:
|
||||
starting_floor_uvalue = x["floor_thermal_transmittance"]
|
||||
ending_floor_uvalue = x["floor_thermal_transmittance_ENDING"]
|
||||
|
||||
if pd.isnull(starting_floor_uvalue):
|
||||
starting_floor_uvalue = get_floor_u_value(
|
||||
floor_type=floor_type,
|
||||
perimeter=perimeters["estimated_perimeter_STARTING"],
|
||||
area=x[f"TOTAL_FLOOR_AREA_STARTING"],
|
||||
insulation_thickness=extract_insulation_thickness(x["floor_insulation_thickness"]),
|
||||
insulation_thickness=x["floor_insulation_thickness"],
|
||||
wall_type=wall_type,
|
||||
age_band=age_band
|
||||
)
|
||||
|
||||
ending_floor_uvalue = x["floor_thermal_transmittance_ENDING"]
|
||||
if pd.isnull(ending_floor_uvalue):
|
||||
ending_floor_uvalue = get_floor_u_value(
|
||||
floor_type=floor_type,
|
||||
perimeter=perimeters["estimated_perimeter_ENDING"],
|
||||
area=x[f"TOTAL_FLOOR_AREA_ENDING"],
|
||||
insulation_thickness=extract_insulation_thickness(x["floor_insulation_thickness_ENDING"]),
|
||||
insulation_thickness=x["floor_insulation_thickness_ENDING"],
|
||||
wall_type=wall_type,
|
||||
age_band=age_band
|
||||
)
|
||||
|
|
@ -322,8 +328,8 @@ def make_uvalues(df):
|
|||
{
|
||||
"UPRN": uprn,
|
||||
"row_index": row_index,
|
||||
"starting_wall_uvalue": starting_wall_uvalue,
|
||||
"ending_wall_uvalue": ending_wall_uvalue,
|
||||
"starting_walls_uvalue": starting_wall_uvalue,
|
||||
"ending_walls_uvalue": ending_wall_uvalue,
|
||||
"starting_roof_uvalue": starting_roof_uvalue,
|
||||
"ending_roof_uvalue": ending_roof_uvalue,
|
||||
"starting_floor_uvalue": starting_floor_uvalue,
|
||||
|
|
@ -338,6 +344,39 @@ def make_uvalues(df):
|
|||
uvalues, how="left", on=["UPRN", "row_index"]
|
||||
).drop(columns="row_index")
|
||||
|
||||
# Fill missings
|
||||
for component in ["walls", "floor", "roof"]:
|
||||
for suffix in ["", "_ENDING"]:
|
||||
fill_col = f"starting_{component}_uvalue" if suffix == "" else f"ending_{component}_uvalue"
|
||||
|
||||
df[f"{component}_thermal_transmittance{suffix}"] = np.where(
|
||||
pd.isnull(df[f"{component}_thermal_transmittance{suffix}"]),
|
||||
df[fill_col],
|
||||
df[f"{component}_thermal_transmittance{suffix}"]
|
||||
)
|
||||
|
||||
df = df.drop(
|
||||
columns=[
|
||||
"starting_walls_uvalue", "ending_walls_uvalue", "starting_roof_uvalue",
|
||||
"ending_roof_uvalue", "starting_floor_uvalue", "ending_floor_uvalue"
|
||||
]
|
||||
)
|
||||
|
||||
return df
|
||||
|
||||
|
||||
def clean_missings_after_description_process(df):
|
||||
missings = pd.isnull(df).sum()
|
||||
missings = missings[missings > 0]
|
||||
for col in missings.index:
|
||||
unique_values = df[col].unique()
|
||||
if True in unique_values or False in unique_values:
|
||||
df[col] = df[col].fillna(False)
|
||||
if "none" in unique_values:
|
||||
df[col] = df[col].fillna("none")
|
||||
else:
|
||||
df[col] = df[col].fillna("Unknown")
|
||||
|
||||
return df
|
||||
|
||||
|
||||
|
|
@ -489,8 +528,11 @@ def app():
|
|||
columns=["walls_clean_description", "walls_clean_description_ENDING"]
|
||||
)
|
||||
|
||||
def clean_missings():
|
||||
pass
|
||||
# TODO: For some of the features that we clean, we have either a true, false or possibly null value
|
||||
# Those nulls should be False. clean_missings_after_description_process handles this but shouldn't
|
||||
# need to
|
||||
|
||||
data_by_urpn_df = clean_missings_after_description_process(data_by_urpn_df)
|
||||
|
||||
if pd.isnull(data_by_urpn_df).sum().sum():
|
||||
raise ValueError("Null values found in dataset after process_and_prune_desriptions")
|
||||
|
|
|
|||
|
|
@ -401,6 +401,9 @@ def get_floor_u_value(floor_type, area, perimeter, age_band, wall_type, insulati
|
|||
0.701
|
||||
"""
|
||||
|
||||
# Cleans our regularly inputted insulation thickness for usage in this function
|
||||
insulation_thickness = extract_insulation_thickness(insulation_thickness)
|
||||
|
||||
# Define constants
|
||||
lambda_g = 1.5 # thermal conductivity of soil in W/m·K
|
||||
Rsi = 0.17 # in m²K/W
|
||||
|
|
@ -507,3 +510,5 @@ def get_wall_type(
|
|||
|
||||
if is_park_home:
|
||||
return "park home"
|
||||
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue