source: inundation-numpy-branch/pyvolution/tsh2sww.py @ 3514

Last change on this file since 3514 was 3514, checked in by duncan, 18 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: 1.9 KB
Line 
1"""Given a .tsh, print an sww
2"""
3
4######################
5# Module imports
6#
7
8import sys
9from os import sep, path
10sys.path.append('..'+sep+'pyvolution')
11
12from shallow_water import Domain
13from pmesh2domain import pmesh_to_domain_instance
14import time, os 
15from anuga.pyvolution.data_manager import get_dataobject   
16from anuga.pyvolution.util import mean
17
18def tsh2sww(infilename, sww_file_name = None, verbose = False):
19    """
20    Note: This currently just writes the output file in the input file dir.
21    """
22    if verbose == True:print 'Creating domain from', infilename
23    domain = pmesh_to_domain_instance(infilename, Domain)
24    if verbose == True:print "Number of triangles = ", len(domain)
25
26    domain.smooth = True
27    domain.format = 'sww'   #Native netcdf visualisation format
28       
29    file_path, filename = path.split(infilename)
30    filename, ext = path.splitext(filename)
31   
32    if not (sww_file_name == None):
33        file_path, filename = path.split(sww_file_name)
34        filename, ext = path.splitext(filename)
35    domain.filename = filename
36       
37    domain.reduction = mean
38    if verbose == True:print "file_path",file_path
39    if file_path == "":file_path = "."
40    domain.set_datadir(file_path)
41
42    if verbose == True:
43        print "Output written to " + domain.get_datadir() + sep + \
44              domain.filename + "." + domain.format 
45    sww = get_dataobject(domain)
46    sww.store_connectivity()
47    sww.store_timestep('stage')
48
49if __name__ == "__main__":
50    usage = "usage: %s pmesh_file_name [verbose|non_verbose]" %         path.basename(sys.argv[0])
51    if len(sys.argv) < 2:
52        print usage
53    else:
54        filename = sys.argv[1]
55        verbose = False
56    if len(sys.argv) > 2:
57        if sys.argv[2][0] == "v" or sys.argv[2][0] == "V":
58            verbose = True
59        tsh2sww(filename, verbose = verbose)
60   
Note: See TracBrowser for help on using the repository browser.