[5076] | 1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
| 2 | Also includes origin for slump scenario. |
---|
| 3 | """ |
---|
| 4 | |
---|
[5392] | 5 | from os import sep, getenv, getcwd, mkdir, access, F_OK |
---|
[5076] | 6 | import sys |
---|
| 7 | from time import localtime, strftime |
---|
[5392] | 8 | from os.path import join |
---|
| 9 | from anuga.shallow_water.data_manager import copy_code_files |
---|
| 10 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
[5076] | 11 | |
---|
| 12 | from anuga.utilities.system_tools import get_user_name |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | class Project: |
---|
| 16 | def __init__(self, |
---|
[5577] | 17 | trunk=['data','flumes','Hinwood_2008'], |
---|
[5076] | 18 | outputdir_name = None, |
---|
| 19 | home = None): |
---|
| 20 | |
---|
| 21 | self.user = get_user_name() |
---|
| 22 | if home is None: |
---|
[5350] | 23 | try: |
---|
| 24 | home = getenv('INUNDATIONHOME') #Sandpit's parent dir |
---|
| 25 | except: |
---|
| 26 | home = '.' |
---|
[5076] | 27 | self.home = home |
---|
| 28 | # Create the structure of where the output directories will go |
---|
| 29 | scenariodir=add_directories(home, trunk) |
---|
| 30 | |
---|
| 31 | #Derive subdirectories and filenames |
---|
| 32 | if outputdir_name is None: |
---|
| 33 | #gets time for dir |
---|
[5350] | 34 | outputdir_name = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
| 35 | |
---|
[5076] | 36 | general_outputdir = scenariodir+sep+'output'+sep |
---|
| 37 | self.outputdir = general_outputdir+outputdir_name+sep |
---|
| 38 | self.meshdir = scenariodir+sep+'meshes'+sep |
---|
[5350] | 39 | self.scenariodir = scenariodir+sep |
---|
[5392] | 40 | self.boundarydir = self.outputdir |
---|
| 41 | self.raw_data_dir = join(scenariodir, 'raw_data') |
---|
[5410] | 42 | self.plots_dir = join(scenariodir, 'plots') |
---|
[5577] | 43 | self.rmsd_dir = join(scenariodir, 'rmsd') |
---|
[5076] | 44 | |
---|
| 45 | # creates copy of output dir structure, if it doesn't exist |
---|
| 46 | if not access(self.meshdir,F_OK): |
---|
| 47 | mkdir (self.meshdir) |
---|
| 48 | if not access(general_outputdir,F_OK): |
---|
| 49 | mkdir (general_outputdir) |
---|
| 50 | if not access(self.outputdir,F_OK): |
---|
| 51 | mkdir (self.outputdir) |
---|
[5410] | 52 | if not access(self.plots_dir,F_OK): |
---|
| 53 | mkdir (self.plots_dir) |
---|
[5577] | 54 | if not access(self.rmsd_dir,F_OK): |
---|
| 55 | mkdir (self.rmsd_dir) |
---|
[5076] | 56 | |
---|
| 57 | self.codedir = getcwd()+sep |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | #------------------------------------------------------------- |
---|
| 61 | if __name__ == "__main__": |
---|
| 62 | p = Project(['eagle'], 'lego','.') |
---|
| 63 | print p.outputdir |
---|
| 64 | print p.meshdir |
---|