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 | |
---|
10 | #Making assumptions about the location of scenario data |
---|
11 | scenario_dir_name = 'dam_2006' |
---|
12 | |
---|
13 | #swollen/ all data output |
---|
14 | basename = 'source' |
---|
15 | |
---|
16 | if sys.platform == 'win32': |
---|
17 | try: |
---|
18 | home = environ['INUNDATIONHOME'] #Sandpit's parent dir |
---|
19 | except: |
---|
20 | home = '.' |
---|
21 | else: |
---|
22 | home = getenv('INUNDATIONHOME', sep+'d'+sep+'cit'+sep+'1'+sep+'cit'+sep+'risk_assessment_methods_project'+sep+'inundation') |
---|
23 | |
---|
24 | |
---|
25 | if not access(home, F_OK): |
---|
26 | home = '.' |
---|
27 | |
---|
28 | #Derive subdirectories and filenames |
---|
29 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
30 | scenariodir = home+sep+scenario_dir_name |
---|
31 | outputdir = scenariodir+sep+'output'+sep |
---|
32 | outputtimedir = outputdir+time+sep |
---|
33 | meshdir = scenariodir+sep+'meshes'+sep |
---|
34 | |
---|
35 | depth_filename = outputtimedir + "depth.csv" |
---|
36 | velocity_x_filename = outputtimedir + "velocity_x.csv" |
---|
37 | velocity_y_filename = outputtimedir + "velocity_y.csv" |
---|
38 | |
---|
39 | |
---|
40 | # creates copy of output dir structure, if it doesn't exist |
---|
41 | if not access(scenariodir,F_OK): |
---|
42 | mkdir (scenariodir) |
---|
43 | |
---|
44 | if not access(meshdir,F_OK): |
---|
45 | mkdir (meshdir) |
---|
46 | |
---|
47 | if not access(outputdir,F_OK): |
---|
48 | mkdir (outputdir) |
---|
49 | |
---|
50 | if not access(outputtimedir,F_OK): |
---|
51 | mkdir (outputtimedir) |
---|
52 | |
---|
53 | codedir = getcwd()+sep |
---|
54 | |
---|
55 | codedirname = codedir + 'project.py' |
---|
56 | |
---|
57 | meshname = meshdir + basename |
---|
58 | |
---|
59 | outputname = outputtimedir + basename #Used by post processing |
---|
60 | |
---|
61 | mesh_filename = meshname+'.msh' |
---|
62 | |
---|