source: anuga_work/development/momentum_sink/scripts/plot_gauges.py @ 6939

Last change on this file since 6939 was 3514, checked in by duncan, 19 years ago

Hi all,
I'm doing a change in the anuga structure, moving the code to

\anuga_core\source\anuga

After you have done an svn update, the PYTHONPATH has to be changed to;
PYTHONPATH = anuga_core/source/

This is part of changes required to make installation of anuga quicker and reducing the size of our sandpits.

If any imports are broken, try fixing them. With adding anuga. to them for example. If this seems to have really broken things, email/phone me.

Cheers
Duncan

File size: 2.4 KB
Line 
1"""Read in sww file, interpolate at specified locations and plot time series
2Additionally, store augmented building database with max inundation depths
3"""
4 # FORMALLY CALLED <process_gauges.py>
5from os import sep
6import project
7from anuga.pyvolution.util import file_function
8#from anuga.pyvolution.coordinate_transforms.redfearn import degminsec2decimal_degrees, redfearn
9from pylab import *
10from compare_sww import gauge_locations
11
12plot = False
13   
14swwfile = project.outputdir + sep  + 'Buildings_3662.sww'
15
16#def get_gauges_from_file(filename):
17#    fid = open(filename)
18#    lines = fid.readlines()
19#    fid.close()
20
21#    gauges = []
22#    gaugelocation = []
23#    for line in lines[1:]:
24#        fields = line.split(',')
25#        location = fields[0]
26#        easting = float(fields[1])
27#        northing = float(fields[2])
28     
29#        gauges.append([easting, northing])
30#        gaugelocation.append(location)
31
32#    #Return gauges and raw data for subsequent storage   
33#    return gauges, lines, gaugelocation
34
35#gauges, lines, locations = get_gauges_from_file(project.gauge_filename)
36
37
38#Read model output
39quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum']
40f = file_function(swwfile,
41                  quantities = quantities,
42                  interpolation_points = gauge_locations,
43                  verbose = True,
44                  use_cache = True)     
45               
46from math import sqrt
47N = len(gauge_locations)
48for k, g in enumerate(gauge_locations):
49    if k%((N+10)/10)==0:
50        print 'Doing row %d of %d' %(k, N)
51
52    model_time = []
53    stages = []
54    elevations = []
55    momenta = []
56
57    max_depth = 0
58    max_momentum = 0   
59    for i, t in enumerate(f.T):
60        w = f(t, point_id = k)[0]
61        z = f(t, point_id = k)[1]
62        uh = f(t, point_id = k)[2]
63        vh = f(t, point_id = k)[3]       
64
65        m = sqrt(uh*uh + vh*vh)   #Absolute momentum
66       
67        model_time.append(t)       
68        stages.append(w)
69        elevations.append(z)  #Should be constant over time
70        momenta.append(m) 
71
72        if w-z > max_depth:
73            max_depth = w-z
74        if m > max_momentum:           
75            max_momentum = m   
76
77        plot(model_time, stages, 'b')
78   
79    print 
80   
81#Store new building file with mak depths added
82
83#FN = 'inundation_augmented_' + project.gauge_filename
84#FN = project.gauge_outname
85#fid = open(FN, 'w')
86#for line in lines:
87#    fid.write(line)
88#fid.close()   
89
Note: See TracBrowser for help on using the repository browser.