source: trunk/anuga_validation/uq_flume_2007/plot.py

Last change on this file was 7877, checked in by hudson, 14 years ago

Moved all development files into trunk.

File size: 2.4 KB
Line 
1
2def plot_compare_csv(location, file_sim, file_exp, y_label,
3                     save_as=None,
4                     x_label='Time (s)',
5                     legend_sim='ANUGA simulation',
6                     legend_exp='Measured flume result',
7                     is_interactive=False):
8    """
9    """
10    from pylab import ion, plot, xlabel, ylabel, close, legend, \
11         savefig
12    from anuga.shallow_water.data_manager import csv2dict
13
14
15
16    # Load in the csv files and convert info from strings to floats
17    simulation, _ = csv2dict(file_sim)
18    experiment, _ = csv2dict(file_exp)
19   
20    time_sim = [float(x) for x in simulation['time']]
21    quantity_sim = [float(x) for x in simulation[location]]
22    #print "quantity_sim", quantity_sim
23    time_exp = [float(x) for x in experiment['time']]
24    quantity_exp = [float(x) for x in experiment[location]]
25
26    if is_interactive:
27        ion()
28   
29    plot(time_sim, quantity_sim, time_exp, quantity_exp)
30
31    # Add axis stuff and legend
32    xlabel(x_label)
33    ylabel(y_label)
34    legend((legend_sim, legend_exp))
35   
36    if is_interactive:
37        # Wait for enter pressed
38        raw_input()
39
40    if save_as is not None:
41        savefig(save_as)
42   
43    #Need to close this plot
44    close()
45   
46
47
48#-------------------------------------------------------------
49if __name__ == "__main__":
50    """ Plot the stage graph for the ANUGA validation papar
51    """
52
53    import project
54    import shutil
55    from os import sep, path
56
57    depth_file = "uq-flume-not-sloped-depth.eps"
58    velocity_file = "uq-flume-not-sloped-velocity.eps"
59    # create Depth plot
60    plot_compare_csv(location='0.4:0.2',
61                     file_sim=project.depth_filename,
62                     file_exp=project.experiment_depth_filename,
63                     y_label='Water height (m)',
64                     save_as=depth_file)
65
66    # create Velocity plot
67    plot_compare_csv(location='0.45:0.2',
68                     file_sim=project.velocity_x_filename,
69                     file_exp=project.experiment_vel_filename,
70                     y_label='Velocity (m/s)',
71                     save_as=velocity_file)
72     
73 
74    # Move the files to the dir where the paper is being put together
75    paper_dir = path.join('..','..','anuga_work','publications','anuga_2007')
76    dest = path.join(paper_dir, depth_file)
77    shutil.copyfile(depth_file,dest)
78    dest = path.join(paper_dir, velocity_file)
79    shutil.copyfile(velocity_file,dest)
Note: See TracBrowser for help on using the repository browser.