-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoretreat_plotter.py
84 lines (58 loc) · 2.11 KB
/
autoretreat_plotter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
# Built in modules
from __future__ import division
import sys
import os
import pdb
import glob
# Third party modules
import numpy as np
import matplotlib.pyplot as plt
def main():
"""Plotter for the delta autoretreat simulation."""
home = os.path.expanduser("~")
savepath = (home + '/Documents/SCarolina-classes/Spring-2014/delta-autoretreat/')
dirname = '20140526-191349'
wd = os.path.join(savepath, dirname)
os.chdir(wd)
# Given the name of the directory where the output is stored, return a list
# of text files.
print 'Looking in directory {}'.format(wd)
print 'These are all the output files'
output_files = sorted(glob.glob('*.txt'), key=os.path.getctime)
print output_files
# Given a list of text files, return a matrix with the relevant columns to
# be plot.
for datafile in output_files:
data = np.loadtxt(datafile)
print datafile
plt.figure(1) #
plt.subplot(311) # First subplot of the first figure.
plt.plot(data[:,0]/1000, data[:,2], 'o') #Plot the bed elevation profile.
plt.subplot(312) # Second subplot in the first figure
plt.plot(data[:,0]/1000, data[:,4], 'o--') # plotting the slopes vs. distance
plt.subplot(313) # Third subplot in the first figure
plt.plot(data[:,0]/1000, data[:,5], 'o') # Plot the transport capacity.
# plt.subplot(414)
# plt.plot(data[-1,4])
plt.figure(1)
plt.subplot(311)
# plt.title('Bed elevation')
plt.xlabel('Distance / km')
plt.ylabel('Bed Elevation / m')
plt.plot(data[:,0]/1000, data[:,3]) #Plot the bed elevation profile.
plt.subplot(312)
plt.yscale('log')
# plt.title('Slopes')
plt.xlabel('Distance / km')
plt.ylabel('Slope / m/m')
plt.subplot(313)
# plt.title('Transport capacity')
plt.xlabel('Distance / km')
plt.ylabel('Bedload transport\n capacity / m$^2$/s')
plt.show()
# given x-y axes, plot them.
return
# Allow for this script to be imported as a module.
if __name__ == "__main__":
main()