Fix bugs for forecasting impacts

develop
Chris Leaman 6 years ago
parent c73e2dd254
commit 44310e3be4

@ -45,7 +45,8 @@ def forecast_twl(
df_twl["beta"] = pd.concat(results) df_twl["beta"] = pd.concat(results)
elif slope == "mean": elif slope == "mean":
df_temp = df_twl.join(df_profile_features, how="inner") df_temp = df_twl.join(df_profile_features.query("profile_type=='prestorm'").reset_index(level='profile_type')
, how="inner")
df_temp["mhw"] = 0.5 df_temp["mhw"] = 0.5
with Pool(processes=n_processes) as pool: with Pool(processes=n_processes) as pool:
results = pool.starmap( results = pool.starmap(
@ -226,7 +227,12 @@ def slope_from_profile(profile_x, profile_z, top_elevation, btm_elevation, metho
end_points[end_type]["x"] = intersection_x[-1] end_points[end_type]["x"] = intersection_x[-1]
else: else:
# For bottom elevation, take most landward intersection that is seaward of top elevation # For bottom elevation, take most landward intersection that is seaward of top elevation
end_points[end_type]["x"] = [x for x in intersection_x if x > end_points["top"]["x"]][0] end_point_btm = [x for x in intersection_x if x > end_points["top"]["x"]]
if len(end_point_btm) == 0:
# If there doesn't seem to be an intersection seaward of the top elevation, return none.
return None
else:
end_points[end_type]["x"] = end_point_btm[0]
if method == "end_points": if method == "end_points":
x_top = end_points["top"]["x"] x_top = end_points["top"]["x"]
@ -286,7 +292,7 @@ def create_twl_forecast(waves_csv, tides_csv, profiles_csv, profile_features_csv
df_waves = pd.read_csv(waves_csv, index_col=[0, 1]) df_waves = pd.read_csv(waves_csv, index_col=[0, 1])
df_tides = pd.read_csv(tides_csv, index_col=[0, 1]) df_tides = pd.read_csv(tides_csv, index_col=[0, 1])
df_profiles = pd.read_csv(profiles_csv, index_col=[0, 1, 2]) df_profiles = pd.read_csv(profiles_csv, index_col=[0, 1, 2])
df_profile_features = pd.read_csv(profile_features_csv, index_col=[0]) df_profile_features = pd.read_csv(profile_features_csv, index_col=[0,1])
logger.info("Forecasting TWL") logger.info("Forecasting TWL")
df_twl_foreshore_slope_sto06 = forecast_twl( df_twl_foreshore_slope_sto06 = forecast_twl(

Loading…
Cancel
Save