From 863976c532d7d94334c5952aa70f094db970660b Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Mon, 12 Nov 2018 17:34:00 +1100 Subject: [PATCH] Add corresponding x-coordinate coordinate of lat/lon on beach profile --- src/data/mat_to_csv.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/data/mat_to_csv.py b/src/data/mat_to_csv.py index 77a375d..d4dbbe2 100644 --- a/src/data/mat_to_csv.py +++ b/src/data/mat_to_csv.py @@ -39,12 +39,11 @@ def parse_orientations(orientations_mat): def combine_sites_and_orientaions(df_sites, df_orientations): """ - Replaces beach/lat/lon columns with the unique site_id + Replaces beach/lat/lon columns with the unique site_id. :param dfs: :param df_sites: :return: """ - df_merged_sites = df_sites.merge(df_orientations[['beach', 'lat_center', 'lon_center', 'orientation']], left_on=['beach', 'lat', 'lon'], right_on=['beach', 'lat_center', 'lon_center']) @@ -54,8 +53,20 @@ def combine_sites_and_orientaions(df_sites, df_orientations): if n_unmatched > 0: logger.warning('Not all records (%d of %d) matched with an orientation', n_unmatched, len(df_sites)) + # Drop extra columns + df_merged_sites = df_merged_sites.drop(columns = ['lat_center', 'lon_center']) + return df_merged_sites +def specify_lat_lon_profile_center(df_sites, x_val=200): + """ + Specify which x-coordinate in the beach profile cross section the lat/lon corresponds to + :param df_sites: + :return: + """ + df_sites['profile_x_lat_lon'] = x_val + return df_sites + def parse_waves(waves_mat): """ Parses the raw waves.mat file and returns a pandas dataframe @@ -209,6 +220,7 @@ def main(): logger.info('Combine orientations into sites') df_sites = combine_sites_and_orientaions(df_sites, df_orientations) + df_sites = specify_lat_lon_profile_center(df_sites) logger.info('Setting pandas index') df_profiles.set_index(['site_id', 'profile_type', 'x'], inplace=True)