Add label showing most recent volume change

etta-drone
Dan Howe 6 years ago
parent c5c63bc579
commit 5656b96545

@ -35,7 +35,7 @@ def remove_temp_files(directory):
return None return None
def plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits): def plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits, delta_vol):
csv_name = profile_name + '.csv' csv_name = profile_name + '.csv'
profiles = pd.read_csv(os.path.join(csv_output_dir, csv_name)) profiles = pd.read_csv(os.path.join(csv_output_dir, csv_name))
@ -55,7 +55,12 @@ def plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits):
ax.set_xlabel('Chainage (m)', labelpad=10) ax.set_xlabel('Chainage (m)', labelpad=10)
ax.set_ylabel('Elevation (m AHD)', labelpad=10) ax.set_ylabel('Elevation (m AHD)', labelpad=10)
ax.legend(frameon=False, fontsize=9)
# Show most recent volume change
ax.annotate('Most recent\nvolume change:\n{:0.1f} m$^3$/m'.format(delta_vol),
(0.1, 0.15), xycoords='axes fraction', fontsize=8,
backgroundcolor='#ffffff', linespacing=1.5)
ax.legend(edgecolor='none', facecolor='#ffffff', fontsize=9)
ax.xaxis.set_minor_locator(MultipleLocator(5)) ax.xaxis.set_minor_locator(MultipleLocator(5))
ax.yaxis.set_minor_locator(MultipleLocator(0.5)) ax.yaxis.set_minor_locator(MultipleLocator(0.5))
@ -99,9 +104,17 @@ def calculate_volumes(profile_name, survey_date, csv_output_dir, ch_limits, volu
volumes.loc[profile_name, date] = volume volumes.loc[profile_name, date] = volume
# Save updated volumes spreadsheet # Save updated volumes spreadsheet
volumes = volumes[volumes.columns.sort_values()]
volumes = volumes.sort_index() volumes = volumes.sort_index()
volumes.to_csv(csv_vol) volumes.to_csv(csv_vol)
# Get most recent volume difference for current profile
previous_vol = volumes.loc[profile_name].values[-2]
current_vol = volumes.loc[profile_name].values[-1]
delta_vol = current_vol - previous_vol
return delta_vol
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -191,8 +204,11 @@ def main():
print('Updating figures...') print('Updating figures...')
profile_names = df['Profile'].unique() profile_names = df['Profile'].unique()
for profile_name in profile_names: for profile_name in profile_names:
plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits) delta_vol = calculate_volumes(profile_name, survey_date,
calculate_volumes(profile_name, survey_date, csv_output_dir, ch_limits, volume_output_dir) csv_output_dir, ch_limits,
volume_output_dir)
plot_profiles(profile_name, csv_output_dir, graph_loc, ch_limits,
delta_vol)
# Remove temprary files # Remove temprary files
remove_temp_files(tmp_dir) remove_temp_files(tmp_dir)
@ -200,3 +216,7 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
if True:
plt.plot([], label='label')
plt.legend(facecolor='r')

Loading…
Cancel
Save