From 6da791a14ea8ae1750ccb704dd8e12bbde904cae Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 30 Aug 2019 14:16:59 +1000 Subject: [PATCH] Show correct volume change between survey 3 and survey 4b --- las_outputs.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/las_outputs.py b/las_outputs.py index 53c89f7..fb62c7a 100644 --- a/las_outputs.py +++ b/las_outputs.py @@ -153,7 +153,8 @@ def plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits, delta_vol, plt.close() -def calculate_volumes(profile_name, survey_date, csv_output_dir, ch_limits, volume_output_dir): +def calculate_volumes(profile_name, current_survey_date, previous_survey_date, + csv_output_dir, ch_limits, volume_output_dir): csv_prof = profile_name + '.csv' beach = re.search('.*(?=_\d)', profile_name).group() profiles = pd.read_csv(os.path.join(csv_output_dir, csv_prof)) @@ -173,7 +174,7 @@ def calculate_volumes(profile_name, survey_date, csv_output_dir, ch_limits, volu volumes = pd.DataFrame() # Get Nielsen erosion volumes for current survey date - current_survey = 'Elevation_' + survey_date + current_survey = 'Elevation_' + current_survey_date chainage = profiles.loc[:, current_survey].dropna().index elevation = profiles.loc[:, current_survey].dropna().values try: @@ -182,7 +183,7 @@ def calculate_volumes(profile_name, survey_date, csv_output_dir, ch_limits, volu volume = np.nan # Update spreadsheet - volumes.loc[profile_name, 'Volume_' + survey_date] = volume + volumes.loc[profile_name, 'Volume_' + current_survey_date] = volume # Save updated volumes spreadsheet volumes = volumes[volumes.columns.sort_values()] @@ -190,8 +191,8 @@ def calculate_volumes(profile_name, survey_date, csv_output_dir, ch_limits, volu volumes.to_csv(csv_vol) # Get most recent volume difference for current profile - current_date_idx = volumes.columns.get_loc('Volume_' + survey_date) - previous_date_idx = current_date_idx - 1 + current_date_idx = volumes.columns.get_loc('Volume_' + current_survey_date) + previous_date_idx = volumes.columns.get_loc('Volume_' + previous_survey_date) if previous_date_idx < 0: # Return None if there is only one survey @@ -211,6 +212,7 @@ def process(yaml_file): print("Starting to process %s" % params['BEACH']) beach = params['BEACH'] survey_date = str(params['SURVEY DATE']) + survey_date_previous = str(params['PREVIOUS SURVEY DATE']) original_las = params['INPUT LAS'] classified_las_dir = params['LAS CLASSIFIED FOLDER'] shp_swash_dir = params['SHP SWASH FOLDER'] @@ -289,7 +291,7 @@ def process(yaml_file): print('Updating figures...') profile_names = df['Profile'].unique() for profile_name in profile_names: - delta_vol = calculate_volumes(profile_name, survey_date, + delta_vol = calculate_volumes(profile_name, survey_date, survey_date_previous, csv_output_dir, ch_limits, volume_output_dir) plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits,