1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
2 | Also includes origin for slump scenario. |
---|
3 | """ |
---|
4 | |
---|
5 | from os import sep, environ, getenv, getcwd |
---|
6 | import sys |
---|
7 | from time import localtime, strftime |
---|
8 | from os import mkdir, access, F_OK |
---|
9 | from anuga.abstract_2d_finite_volumes.util import add_directories, \ |
---|
10 | copy_code_files |
---|
11 | |
---|
12 | from anuga.utilities.system_tools import get_user_name |
---|
13 | |
---|
14 | #swollen/ all data output |
---|
15 | basename = 'source' |
---|
16 | |
---|
17 | user = get_user_name() |
---|
18 | if sys.platform == 'win32': |
---|
19 | try: |
---|
20 | home = environ['INUNDATIONHOME'] |
---|
21 | except: |
---|
22 | home = '.' |
---|
23 | else: |
---|
24 | home = getenv('INUNDATIONHOME', sep+'d'+sep+'cit'+sep+'1'+sep+'cit'+sep+'risk_assessment_methods_project'+sep+'inundation') |
---|
25 | |
---|
26 | if not access(home, F_OK): |
---|
27 | home = '.' |
---|
28 | |
---|
29 | # Create the structure of where the output will go |
---|
30 | create_scenario_dir = ['data','flumes','dam_2006'] |
---|
31 | |
---|
32 | scenariodir=add_directories(home, create_scenario_dir) |
---|
33 | |
---|
34 | |
---|
35 | #Derive subdirectories and filenames |
---|
36 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
37 | outputdir = scenariodir+sep+'output'+sep |
---|
38 | outputtimedir = outputdir+time+sep |
---|
39 | meshdir = scenariodir+sep+'meshes'+sep |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | depth_filename = outputtimedir + "depth.csv" |
---|
44 | velocity_x_filename = outputtimedir + "velocity_x.csv" |
---|
45 | velocity_y_filename = outputtimedir + "velocity_y.csv" |
---|
46 | |
---|
47 | |
---|
48 | # creates copy of output dir structure, if it doesn't exist |
---|
49 | if not access(meshdir,F_OK): |
---|
50 | mkdir (meshdir) |
---|
51 | |
---|
52 | if not access(outputdir,F_OK): |
---|
53 | mkdir (outputdir) |
---|
54 | |
---|
55 | if not access(outputtimedir,F_OK): |
---|
56 | mkdir (outputtimedir) |
---|
57 | |
---|
58 | codedir = getcwd()+sep |
---|
59 | codedirname = codedir + 'project.py' |
---|
60 | |
---|
61 | meshname = meshdir + basename |
---|
62 | |
---|
63 | outputname = outputtimedir + basename #Used by post processing |
---|
64 | |
---|
65 | mesh_filename = meshname+'.msh' |
---|
66 | |
---|