source: anuga_work/production/dampier_2006/get_timeseries_bf.py @ 4631

Last change on this file since 4631 was 4308, checked in by nick, 17 years ago

update to dampier

File size: 5.7 KB
Line 
1"""
2Generate images of "gauges" for production run
3
4Inputs:
5
6production dirs: dictionary of production directories with a
7                 association to that simulation run, eg high tide,
8                 low tide and MSL.
9                   
10Outputs:
11
12* figures used for report stored in the report_figure directory
13
14"""
15from os import getcwd, sep, altsep, mkdir, access, F_OK
16import project
17from anuga.abstract_2d_finite_volumes.util import sww2timeseries
18from anuga.shallow_water import Domain
19from anuga.pmesh.mesh_interface import create_mesh_from_regions
20from anuga.shallow_water import File_boundary
21#from anuga.fit_interpolate import Interpolation_function
22from anuga.abstract_2d_finite_volumes.util import start_screen_catcher
23
24
25start_screen_catcher(project.temp_dir_name, print_to_screen=True)
26
27# Create report directory
28reportdir = getcwd()+sep+'report'+sep
29if access(reportdir,F_OK) == 0:
30    mkdir (reportdir)
31   
32# sww file created from URS boundary
33production_dirs = {#'20070206_005106_run': '10000 yr wave height'}
34                   'boundaries': 'URS boundary condition'}
35                   
36meshes_dir_name = project.meshes_dir_name+'.msh'
37print 'create mesh' 
38create_mesh_from_regions(project.poly_all,
39                             boundary_tags=None,
40                             maximum_triangle_area=500000,
41                             interior_regions=None,
42                             filename=meshes_dir_name,
43                             use_cache=False,
44                             verbose=True)
45                             
46domain = Domain(meshes_dir_name, use_cache=True, verbose=True)
47#print"domain id", id(domain)
48
49print domain.statistics()
50boundaries_dir_name=project.boundaries_dir_name
51
52domain.set_quantity('stage', 2.4)
53print 'Reading Boundary file', boundaries_dir_name
54Bf = File_boundary(project.boundaries_dir_name3 + '.sww',
55                  domain, time_thinning=1, use_cache=True, verbose=True)
56#print "domain id", id(domain)
57print "Bf id", id(Bf)
58
59print "dir,bf", dir(Bf)
60#print 'finished reading boundary file', Bf.get_midpoint_coords()
61print 'finished reading boundary file', Bf.midpoint_coordinates.shape[0],Bf.midpoint_coordinates[0]
62
63# interpolation_points[0]
64
65#number_of_points = Bf.midpoint_coordinates.shape[0]
66number_of_points = (50,200,324)
67
68#number_of_points = Bf.interpolation_points.shape[0]
69print "number_of_points", number_of_points
70dir(Bf.F)
71#for id in range(number_of_points)[10:]:
72for id in number_of_points:
73    print "id", id
74    x,y=Bf.midpoint_coordinates[id]
75#    x,y=Bf.interpolation_points[id]
76    print"x,y",x,y
77    t_boundary = Bf.F.precomputed_values["stage"][:,id]
78    print "t_boundary", t_boundary
79
80#t_file =
81
82
83import sys   
84sys.exit()
85
86
87
88is_parallel = False
89if is_parallel == True:
90    nodes = 2
91   
92# Generate figures
93swwfiles = {}
94
95if is_parallel == True:
96
97    for i in range(nodes):
98        print 'Sending node %d of %d' %(i,nodes)
99        swwfiles = {}
100        #reportname = report_name + '_%s' %(i)
101        for label_id in production_dirs.keys():
102            if label_id == 'boundaries':
103                file_loc = project.boundaries_in_dir
104                swwfile = file_loc + sep + '20061102_221245_build' + sep + 'dampier.sww'
105                print 'hi'
106            #else:
107            #file_loc = project.output_dir + label_id + sep
108            #sww_extra = '_P%s_%s' %(i,nodes)
109            #swwfile = file_loc + project.scenario_name + sww_extra + '.sww'
110            swwfiles[swwfile] = label_id
111
112        texname, elev_output = sww2timeseries(swwfiles,
113                                              project.gauges_dir_name,
114                                              production_dirs,
115                                              report = False,
116                                              #reportname = reportname,
117                                              plot_quantity = ['stage', 'momentum'],
118                                              generate_fig = False,
119                                              surface = False,
120                                              time_min = None,
121                                              time_max = None,
122                                              title_on = False,
123                                              verbose = True)
124           
125            #latex_output.append(texname)
126   
127else:
128   
129    for label_id in production_dirs.keys():
130       
131        if label_id == 'boundaries':
132                file_loc = project.boundaries_in_dir
133                swwfile = project.boundaries_dir_name3 + '.sww'
134        else:
135            file_loc = project.output_dir + label_id + sep
136            swwfile = file_loc + project.scenario_name + '.sww'
137        swwfiles[swwfile] = label_id
138       
139    texname, elev_output = sww2timeseries(swwfiles,
140                                          project.gauges_dir_name_test,
141                                          production_dirs,
142                                          report = False,
143                                          #reportname = report_name,
144                                          plot_quantity = ['stage', 'momentum'],
145                                          surface = False,
146                                          time_min = None,
147                                          time_max = None,
148                                          title_on = False,
149                                          verbose = True)
150
151    fid = open(filename)
152    lines = fid.readlines()
153    fid.close()
154    polygon = []
155    for line in lines:
156        fields = line.split(split)
157        polygon.append( [float(fields[0]), float(fields[1])] )
158
159
Note: See TracBrowser for help on using the repository browser.