FLEXPART Testing Environment CTBTO WO8
 All Classes Namespaces Files Functions Variables Pages
RunCase.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 Created on Tue Aug 11 19:35:59 2015
4 
5 @author: morton
6 """
7 
8 
9 import os
10 
11 import distrotest.BasicTest as BasicTest
12 
13 class RunCase(object):
14 
15 
16  """
17  RunCase.py - container that stores properties of a particular run, including
18  description, directory of case files, and a list of BasicTest objects to be
19  applied. A Case corresponds to a specific simulation (e.g. forward or backward,
20  specific set of inputs, specific domain, species, etc.)
21  """
22 
23  def __init__(self, descr=None, case_dir=None,
24  control_data_dir=None, test_list=None):
25 
26  """
27  descr : (optional) Description string
28  case_dir : directory where case configuration files is located
29  control_data_dir : (optional). Alternate location of control output
30  data. If not defined, then defaults to <case_dir>/output
31  test_list : (optional) List of BasicTest objects. Defaults to None.
32  """
33 
34  if descr:
35  self._description = descr
36 
37  if case_dir:
38  if os.path.isdir(case_dir):
39  self._case_dir = case_dir
40  else:
41  raise Exception('Cannot find case_dir: ' + case_dir)
42  else:
43  raise Exception('case_dir not defined')
44 
45 
46  if control_data_dir:
47  self._control_data_dir = control_data_dir
48  else:
49  self._control_data_dir = self._case_dir + '/output'
50 
51  # Default to the "output" dir of the case directory
52  #print control_data_dir, self._control_data_dir
53  if not os.path.isdir(self._control_data_dir):
54  raise Exception('control_data_dir not valid: ' + self._control_data_dir)
55 
56  # Make sure all elements of test_list are indeed BasicTest objects
57  if test_list:
58  for the_test in test_list:
59  if not isinstance(the_test, (BasicTest.BasicTest)):
60  raise Exception('item in test_list not a BasicTest obj')
61  self._test_list = test_list
62  else:
63  self._test_list = []
64 
65 
66  def get_descr(self):
67  return self._description
68 
69  def get_case_dir(self):
70  return self._case_dir
71 
73  return self._control_data_dir
74 
75 
76  def get_test_list(self):
77  return self._test_list
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89