Definition at line 32 of file FlexpartCase.py.
def flextest.FlexpartCase.FlexpartCase.__init__ |
( |
|
self, |
|
|
|
src_dir = None , |
|
|
|
dest_dir = None , |
|
|
|
met_dir = None , |
|
|
|
met_nest_dir = None , |
|
|
|
flexpart_exe = None |
|
) |
| |
Set up the class
src_dir : a directory structure all set to run FLEXPART. Note that
the paths in pathnames must be all relative within this directory.
This directory will also need to contain the met data in directory
met_data
dest_dir : location that src_dir will be copied to, and where the
run will be executed. dest_dir cannot already exist. We make
this restriction to prevent accidental overwriting of something
important.
met_dir : location of met files. Assumed to have a valid
AVAILABLE file in it
flexpart_exe : full path to a FLEXPART executable
Definition at line 38 of file FlexpartCase.py.
39 met_dir=
None, met_nest_dir=
None, flexpart_exe=
None):
43 src_dir : a directory structure all set to run FLEXPART. Note that
44 the paths in pathnames must be all relative within this directory.
45 This directory will also need to contain the met data in directory
48 dest_dir : location that src_dir will be copied to, and where the
49 run will be executed. dest_dir cannot already exist. We make
50 this restriction to prevent accidental overwriting of something
53 met_dir : location of met files. Assumed to have a valid
57 flexpart_exe : full path to a FLEXPART executable
68 if os.path.isdir(src_dir):
71 msg =
'src_dir not found: ' + src_dir
74 msg =
'No src_dir argument'
80 if os.path.isdir(dest_dir):
81 msg =
'dest_dir cannot already exist: ' + dest_dir
86 msg =
'No dest_dir argument'
92 if os.path.isdir(met_dir):
95 msg =
'met_dir not found: ' + met_dir
98 msg =
'No met_dir argument'
104 if os.path.isdir(met_nest_dir):
107 msg =
'met_nest_dir not found: ' + met_nest_dir
113 if os.path.isfile(flexpart_exe)
and os.access(flexpart_exe, os.X_OK):
116 msg =
'flexpart_exe does not exist and/or is not executable'
119 msg =
'No flexpart_exe argument'
127 if not os.path.isdir(dest_dir):
131 shutil.copytree(src_dir, dest_dir)
132 logging.info(
'FlexpartCase: copying case dir to temp location')
136 diffs = filecmp.dircmp(src_dir, dest_dir)
138 logging.warning(
'FlexpartCase: src and dest differ')
144 logging.warning(
'FlexpartCase: copy failed')
147 logging.warning(
'FlexpartCase: dest_dir exists')
153 if not os.path.isdir(dest_dir +
'/output'):
156 os.mkdir(dest_dir +
'/output', 0755)
158 msg =
'No output dir present in case directory'
163 os.symlink(self.
_met_dir, dest_dir +
'/met_data')
165 msg =
'Unable to create met_data symlink to: ' + self.
_met_dir
173 msg =
'Unable to create met_data_nest symlink to: ' + \
178 if not os.path.isfile(dest_dir +
'/met_data/AVAILABLE'):
179 msg =
'Unable to find AVAILABLE in ' + dest_dir +
'/met_data'
183 if not os.path.isfile(dest_dir +
'/met_data_nest/AVAILABLE'):
184 msg =
'Unable to find AVAILABLE in ' + dest_dir +
'/met_data_nest'