source: production/gippsland_2005/run_gippsland.py @ 2136

Last change on this file since 2136 was 2136, checked in by duncan, 18 years ago

scenario

File size: 4.5 KB
Line 
1
2#Convention for strings representing files
3# #_file has the extention
4#           #name does not have the extension
5
6from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\
7     dem2pts, asc_csiro2sww
8from pyvolution.pmesh2domain import pmesh_to_domain_instance
9from caching import cache
10from create_mesh import create_mesh
11from pyvolution.shallow_water import Domain, Reflective_boundary,\
12     File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary
13from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA
14
15# Import this last!  It stuffs up the loading of c extensions otherwise.
16import project
17
18#Data preparation
19#Convert ASC 2 DEM 2 PTS using source data and store result in source data
20# just interested in the boundary/ mesh intereaction first off.
21#cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True},
22#      dependencies = [demname + '.asc'],
23#      verbose = True)
24#      #evaluate = True)
25
26cache(dem2pts, project.demname[:-4], {'verbose': True},
27      dependencies = [project.demname]     
28      ,verbose = False
29      )
30
31
32# Convert CSIRO boundary
33# NOTE: This function is dependent on a lot of files, and I haven't listed
34# them, since there is so many and I don't think they will be changing.
35cache(asc_csiro2sww,
36      (project.bath_dir,
37       project.elevation_dir,
38       project.ucur_dir,
39       project.vcur_dir,
40       project.boundaryname),
41       {'verbose': True,
42       'minlat': -38.25,
43       'maxlat': -37.7,
44       'minlon': 147.0,
45       'maxlon': 148.25,
46       'mean_stage': project.tide,
47       'zscale': 1,                 #Enhance storm surge
48       'fail_on_NaN': False}
49      #,evaluate = True                 
50      ,verbose = False
51      )
52
53meshname = project.meshname
54pointname = project.pointname
55mesh_elevname = project.mesh_elevname
56outputname = project.outputname
57
58#Create the mesh without elevation data
59# 100000 very course
60# 50000 seems to be a show stopper
61meshname, triagle_count = cache(create_mesh,(100000),
62                      {'mesh_file':meshname,
63                       'triangles_in_name':True}
64                      ,dependencies = ['create_mesh.py']
65                      #,evaluate = True     
66                      )
67
68mesh_elevname = mesh_elevname[:-9] + '_' + str(triagle_count) +  \
69                mesh_elevname[-9:]
70outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:]
71
72
73#Add elevation data to the mesh
74#fit_to_mesh_file(mesh_file, point_file, mesh_output_file, DEFAULT_ALPHA,
75#                 verbose=True, expand_search=True, precrop=True)     
76cache(fit_to_mesh_file,(meshname,
77                 pointname,
78                 mesh_elevname,
79                 DEFAULT_ALPHA),
80      {'verbose': True,
81       'expand_search': True,
82       'precrop': True}
83      ,dependencies = [meshname, pointname]
84      #,evaluate = True     
85      ,verbose = False
86      )
87   
88
89#Setup domain
90domain = cache(pmesh_to_domain_instance, (mesh_elevname, Domain),
91               dependencies = [mesh_elevname]                   
92               ,verbose = False
93               )               
94
95
96domain.set_name(project.basename + '_%d' %triagle_count)
97domain.set_datadir(project.outputdir)
98domain.store = True
99domain.quantities_to_be_stored = ['stage']
100
101print 'Number of triangles = ', len(domain)
102print 'The extent is ', domain.get_extent()
103
104#Setup Initial Conditions
105domain.set_quantity('friction', 0)
106domain.set_quantity('stage', project.tide)
107
108
109#Setup Boundary Conditions
110print domain.get_boundary_tags()
111
112print "****** run  ****"
113print "project.boundaryname",project.boundaryname
114print "**********"
115
116Bf = File_boundary(project.boundaryname, domain, verbose = True)
117#domain.starttime = 3000  #Obtained from MOST
118domain.starttime = 0  #Obtained from MOST
119
120Br = Reflective_boundary(domain)
121Bt = Transmissive_boundary(domain)
122Bd = Dirichlet_boundary([project.tide,0,0])
123#Bw = Time_boundary(domain=domain,
124#                   f=lambda t: [(60<t<660)*4, 0, 0])
125
126domain.set_boundary( {'back': Br,'side': Bf, 'ocean': Bf} ) #CSIRO storm surge
127
128#Evolve
129import time
130t0 = time.time()
131
132#for t in domain.evolve(yieldstep = 60, finaltime = 30000):
133for t in domain.evolve(yieldstep = 10, finaltime = 30):
134#                       skip_initial_step = True):
135    domain.write_time()
136    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')       
137
138print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.