source: trunk/anuga_core/documentation/user_manual/examples/file_function_example.py @ 7808

Last change on this file since 7808 was 3643, checked in by ole, 18 years ago

Manual update

File size: 1.2 KB
Line 
1
2#Run bedslopephysical.py first then this
3#
4#Notice the statistics output
5
6from anuga.abstract_2d_finite_volumes.util import file_function
7 
8f = file_function('runup.sww',
9                  quantities = ['stage',  #Quantities we want to interpolate
10                                'elevation',
11                                'xmomentum',
12                                'ymomentum'],
13                  interpolation_points = [ [0.0, 0.0], #Predefined points
14                                           [0.5, 0.5],
15                                           [0.8, 0.7]], 
16                  verbose = True)
17
18
19
20
21
22#Now try to call the function f
23
24#This gives all four quantities at time=1.2 and for predefined point
25#indexed 1  (which is 0.5, 0.5)
26print f(1.2, 1)
27
28
29#To get e.g. xmomentum one may index the output with its number (2)
30print f(1.2, 1)[2]   #xmomentum at time=1.2 and for point number 1
31
32
33#To get a timeseries (arbitrary times within the limits) for stage at point
34#[0.8, 0.7]  (index 2)
35
36t = 0.0
37tmax = 4.0  #From file_function statistics!
38
39print
40print 'Table of interpolated values of stage'
41print 't        f(t, 2)[0]'
42while t <= tmax:
43    print '%.4f  %.4f' %(t, f(t, 2)[0])
44    t += 0.1234
45
46   
47
48
49
Note: See TracBrowser for help on using the repository browser.