Show correct volume change between survey 3 and survey 4b

etta-drone
Dan Howe 5 years ago
parent ca67fe493a
commit 6da791a14e

@ -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,

Loading…
Cancel
Save