diff --git a/src/analysis/forecast_twl.py b/src/analysis/forecast_twl.py index 0fab400..7bab74b 100644 --- a/src/analysis/forecast_twl.py +++ b/src/analysis/forecast_twl.py @@ -59,7 +59,9 @@ def forecast_twl( df_twl["beta"] = pd.concat(results) # Estimate runup - R2, setup, S_total, S_inc, S_ig = runup_function(Hs0=df_twl['Hs0'].tolist(), Tp=df_twl["Tp"].tolist(), beta=df_twl["beta"].tolist()) + R2, setup, S_total, S_inc, S_ig = runup_function( + Hs0=df_twl["Hs0"].tolist(), Tp=df_twl["Tp"].tolist(), beta=df_twl["beta"].tolist() + ) df_twl["R2"] = R2 df_twl["setup"] = setup diff --git a/src/analysis/runup_models.py b/src/analysis/runup_models.py index 9176adb..c508f65 100644 --- a/src/analysis/runup_models.py +++ b/src/analysis/runup_models.py @@ -12,7 +12,7 @@ def sto06(Hs0, Tp, beta): df = pd.DataFrame({"Hs0": Hs0, "Tp": Tp, "beta": beta}, index=[x for x in range(0, np.size(Hs0))]) - df["Lp"] = 9.8 * df['Tp'] ** 2 / 2 / np.pi + df["Lp"] = 9.8 * df["Tp"] ** 2 / 2 / np.pi # General equation df["S_ig"] = pd.to_numeric(0.06 * np.sqrt(df["Hs0"] * df["Lp"]), errors="coerce") diff --git a/src/data/parse_mat.py b/src/data/parse_mat.py index 4020479..25a867a 100644 --- a/src/data/parse_mat.py +++ b/src/data/parse_mat.py @@ -200,7 +200,7 @@ def parse_profiles_and_sites(profiles_mat): # Our z values can come from these columns, depending on the isgood flag. # Let's reoganise them into a list of list - z_names = ["Zpre", 'Zpost', 'Zrec1', 'Zrec2', 'Zrec3', 'Zrec4'] + z_names = ["Zpre", "Zpost", "Zrec1", "Zrec2", "Zrec3", "Zrec4"] z_cols = [mat_data[col] for col in z_names] z_sites = [] for cols in zip(*z_cols): @@ -226,8 +226,6 @@ def parse_profiles_and_sites(profiles_mat): # Want to calculation the orientation orientation = {} - - for x, lat, lon, z_site, easting, northing in zip( mat_data["x"][i], mat_data["lats"][i], @@ -237,13 +235,12 @@ def parse_profiles_and_sites(profiles_mat): mat_data["northings"][i], ): - profile_type = None for j, is_good in enumerate([1] + mat_data["isgood"][i]): # Assumes the first profile is always good and is the prestorm profike if j == 0: - profile_type = 'prestorm' + profile_type = "prestorm" z = z_site[j] land_lim = np.nan @@ -253,7 +250,7 @@ def parse_profiles_and_sites(profiles_mat): # Takes the first isgood profile as the post storm profile else: - profile_type = 'poststorm' + profile_type = "poststorm" z = z_site[j] land_lim = mat_data["landlims"][i][j] @@ -287,10 +284,9 @@ def parse_profiles_and_sites(profiles_mat): ) # Stop looking at profiles if we've got our post-storm profile - if profile_type == 'poststorm': + if profile_type == "poststorm": break - orientation = math.degrees( math.atan2( orientation["land_northing"] - orientation["sea_northing"], @@ -334,8 +330,7 @@ def remove_zeros(df_profiles): ) df_profile = df_profiles[idx_site] x_last_ele = df_profile[df_profile.z == 0].index.get_level_values("x")[0] - df_profiles.loc[idx_site & (df_profiles.index.get_level_values("x") > x_last_ele), - "z"] = np.nan + df_profiles.loc[idx_site & (df_profiles.index.get_level_values("x") > x_last_ele), "z"] = np.nan logger.info("Removed zeros from end of profiles") return df_profiles