source: anuga_validation/convergence_study/animatesww2d_alt.py @ 4695

Last change on this file since 4695 was 4695, checked in by ole, 16 years ago

Started to convert Will Power's plotting script from Matlab to Python

File size: 1.4 KB
Line 
1def animatesww2d_alt(sww_filename, movie_filename, range):
2    """Plot cross section of model output
3    """
4
5    # Read SWW file     
6    from Scientific.IO.NetCDF import NetCDFFile
7    fid = NetCDFFile(sww_filename, 'r')
8   
9    x = fid.variables['x']
10    y = fid.variables['y']
11    volumes = fid.variables['volumes']
12   
13    elevation = fid.variables['elevation']
14    time = fid.variables['time']
15    stage = fid.variables['stage']
16    xmomentum = fid.variables['xmomentum']
17    ymomentum = fid.variables['ymomentum']
18   
19   
20    # Set up plot
21
22    spacing=10 # grid interval in metres
23    hmax=5     # ??
24
25   
26#figure(1);
27
28#if nargin > 1
29#    figure(1);set(gcf,'Position',[200 400 800 300]);
30#    mov=avifile(movie_filename,'FPS',5)
31#end
32
33#i=find(V_y==0);
34
35#[xi,yi]=meshgrid(min(V_x):spacing:max(V_x),min(V_y):spacing:max(V_y));
36
37#elev=griddata(V_x,V_y,V_elevation,xi,yi);
38
39#if nargin < 3
40#    range=[min(V_x) max(V_x) min(min(V_stage))-1 max(max(V_stage))+1];
41#end
42
43#m=V_stage(1,i);
44
45#for t=1:length(V_time)
46   
47#    m=max(m,V_stage(t,i));
48#    plot(V_x(i),V_stage(t,i),V_x(i),V_elevation(i),V_x(i),m,'.');
49
50#    axis(range)
51   
52
53#    title(num2str(V_time(t)));drawnow;
54
55#    if nargin>1
56#        F=getframe(gcf);
57#        mov=addframe(mov,F);   
58#    end
59   
60#end
61
62#if nargin > 1
63#    mov=close(mov);
64#end
65
66
67if __name__ == '__main__':
68
69    import sys
70    animatesww2d_alt(sys.argv[1], 'cross_section_plot', 5)
71   
Note: See TracBrowser for help on using the repository browser.