1 | """Convert from Arcview ASCII DEMs via native netcdf dem format |
---|
2 | to native pts netcdf format for use with least_squares fits |
---|
3 | """ |
---|
4 | |
---|
5 | import os |
---|
6 | import time |
---|
7 | |
---|
8 | |
---|
9 | from pyvolution.shallow_water import Domain, Reflective_boundary |
---|
10 | from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\ |
---|
11 | dem2pts, ferret2sww |
---|
12 | from pyvolution.pmesh2domain import pmesh_to_domain_instance |
---|
13 | from caching import cache |
---|
14 | import project |
---|
15 | |
---|
16 | #Data preparation |
---|
17 | #Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
18 | demname = project.demname |
---|
19 | |
---|
20 | cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True}, |
---|
21 | dependencies = [demname + '.asc'], |
---|
22 | verbose = True) |
---|
23 | #evaluate = True) |
---|
24 | |
---|
25 | cache(dem2pts, demname, {'verbose': True}, |
---|
26 | dependencies = [demname + '.dem'], |
---|
27 | verbose = True) |
---|
28 | |
---|
29 | #Convert MOST boundary |
---|
30 | |
---|
31 | ferret2sww('test', verbose=False, |
---|
32 | origin = (56, 0, 0)) |
---|
33 | |
---|
34 | |
---|
35 | #Read mesh |
---|
36 | mesh = project.meshname + '.msh' |
---|
37 | domain = cache(pmesh_to_domain_instance, (mesh, Domain), |
---|
38 | dependencies = [mesh], |
---|
39 | verbose = True) |
---|
40 | |
---|
41 | |
---|
42 | domain.set_name(project.basename) |
---|
43 | domain.set_datadir(project.outputdir) |
---|
44 | domain.store = True |
---|
45 | |
---|
46 | print "Number of triangles = ", len(domain) |
---|
47 | print 'The extent is ', domain.get_extent() |
---|
48 | |
---|
49 | |
---|
50 | #IC |
---|
51 | domain.set_quantity('stage', 0) |
---|
52 | domain.set_quantity('elevation', |
---|
53 | filename = demname + '.pts', |
---|
54 | use_cache = True, |
---|
55 | verbose = True) |
---|
56 | |
---|
57 | #BC |
---|
58 | Br = Reflective_boundary(domain) |
---|
59 | domain.set_boundary( {'wall': Br} ) |
---|
60 | |
---|
61 | |
---|
62 | #Run |
---|
63 | for t in domain.evolve(yieldstep = 1, finaltime = 1): |
---|
64 | domain.write_time() |
---|