def retrofits(retrofit): """make retrofits.""" obj = CSV("./", "buildings_heat_retrofit{}.csv".format(retrofit)) buildings = pd.read_csv("buildings.csv", index_col=0) buildings = buildings.dropna() buildings = buildings[ [st in StatGebWilhemsburg for st in buildings["statistical area"]]] buildings['heat'] = 0 # sample_size = int(buildings.shape[0] * 0.01) sample_size = int(buildings.shape[0] * 0.1) print("sample size = ", sample_size) random.seed(12345) rows = random.sample(buildings.index.tolist(), sample_size) buildings = buildings.ix[rows] b_dim = buildings.shape[0] cols = buildings.columns.tolist() cols.append("heat") obj.writeLine(cols) for i in range(b_dim): heat = get_heat(buildings.iloc[i], verbose=False, retrofit=retrofit) print("{:>4} / {:<4} --> {:0.2f}kWh/m2a for year {} - s {}".format( i, b_dim, heat/buildings.iloc[i]["sqm"], buildings.iloc[i]["bja"], retrofit)) val = buildings.iloc[i].tolist() val.append(heat) obj.writeLine(val)
def computeHeat(buildings, file_name="buildings_heat.csv", file_path="./"): """Estimate heat demand for all building in the data frame.""" obj = CSV(file_path, file_name) buildings = buildings[ [st in StatGebWilhemsburg for st in buildings["statistical area"]]] b_dim = buildings.shape[0] cols = buildings.columns.tolist() cols.append("heat") obj.writeLine(cols) for i in range(b_dim): heat = get_heat(buildings.iloc[i], verbose=False) print("{:>4} / {:<4} --> {:0.2f}kWh/m2a for year {}".format( i, b_dim, heat/buildings.iloc[i]["sqm"], buildings.iloc[i]["bja"])) val = buildings.iloc[i].tolist() val.append(heat) obj.writeLine(val)