diff --git a/outputs_2017088_Survey2.py b/outputs_2017088_Survey2.py index 9c14ebc..8131f84 100644 --- a/outputs_2017088_Survey2.py +++ b/outputs_2017088_Survey2.py @@ -195,12 +195,45 @@ def profile_plots_volume(csv_loc, LL_xlsx, output_xlsx, graph_location): row=row+1 return results_volume + def remove_temp_files(directory): for f in os.listdir(directory): os.unlink(os.path.join(directory, f)) return None + +def plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits): + csv_name = profile_name + '.csv' + profiles = pd.read_csv(os.path.join(csv_output_dir, csv_name)) + + # Remove metadata, and extract profile coordinates + profiles = profiles.loc[:, 'Chainage':].set_index('Chainage') + + # Find landward limit of profile (behind beach) + ch_min = ch_limits.loc[profile_name, 'Landward Limit'] + + ax = plt.axes() + for col in profiles.columns: + profile = profiles.loc[ch_min:, col] + date_str = col.split('_')[-1] + date = '{}-{}-{}'.format(date_str[:4], date_str[4:6], date_str[6:]) + + ax.plot(profile.index, profile, label=date) + + ax.set_xlabel('Chainage (m)', labelpad=10) + ax.set_ylabel('Elevation (m AHD)', labelpad=10) + ax.legend(frameon=False, fontsize=9) + + ax.xaxis.set_minor_locator(MultipleLocator(5)) + ax.yaxis.set_minor_locator(MultipleLocator(0.5)) + ax.xaxis.grid(True, which='minor', color='k', linewidth=0.5, alpha=0.3) + ax.yaxis.grid(True,which='minor',color='k', linewidth=0.5, alpha=0.3) + + png_name = os.path.join(graph_loc, profile_name + '.png') + plt.savefig(png_name, bbox_inches='tight', dpi=300) + + input_file = 'Parameter Files/las-manipulation-survey-2.xlsx' params_file=pd.read_excel(input_file, sheet_name="PARAMS") @@ -263,45 +296,18 @@ for i, row in params_file.iterrows(): verbose=False) update_survey_output(df, csv_output_dir) + # Get landward limit of surveys + ch_limits = pd.read_excel(profile_limit_file, index_col='Profile') - - #colourise the point cloud + # Plot profiles of current beach + profile_names = df['Profile'].unique() + for profile_name in profile_names: + plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits) #delete the temp files from the tmp_dir and the interim_dir remove_temp_files(tmp_dir) #remove_temp_files(int_dir) -csv_names = [f for f in os.listdir(csv_output_dir) if f.endswith('.csv')] -ch_limits = pd.read_excel(profile_limit_file, index_col='Profile') - -for csv_name in csv_names: - profile_name = os.path.splitext(csv_name)[0] - profiles = pd.read_csv(os.path.join(csv_output_dir, csv_name)) - - # Remove metadata, and extract profile coordinates - profiles = profiles.loc[:, 'Chainage':].set_index('Chainage') - - # Find landward limit of profile (behind beach) - ch_min = ch_limits.loc[profile_name, 'Landward Limit'] - - ax = plt.axes() - for col in profiles.columns: - profile = profiles.loc[ch_min:, col] - date_str = col.split('_')[-1] - date = '{}-{}-{}'.format(date_str[:4], date_str[4:6], date_str[6:]) - - ax.plot(profile.index, profile, label=date) - - ax.set_xlabel('Chainage (m)', labelpad=10) - ax.set_ylabel('Elevation (m AHD)', labelpad=10) - ax.legend(frameon=False) - plt.show() - - - - - - print("doing the volume analysis") # test=profile_plots_volume(csv_output_dir, profile_limit_file, volume_output, graph_loc)