FLEXPART Testing Environment CTBTO WO8
 All Classes Namespaces Files Functions Variables Pages
Distribution.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 Created on Wed Aug 12 00:25:32 2015
4 
5 @author: morton
6 
7 Don Morton
8 Boreal Scientific Computing LLC, Fairbanks, Alaska, USA
9 Don.Morton@borealscicomp.com
10 """
11 
12 import os
13 
14 import distrotest.BasicTest as BasicTest
15 import distrotest.RunCase as RunCase
16 import distrotest.MetCase as MetCase
17 
18 class Distribution(object):
19 
20 
21  """
22  Distribution() - container that stores properties of a particular FLEXPART
23  distribution test, which will contain one or more MetCase objects, which
24  will contain one or more RunCase objects, which will contain one or more
25  BasicTest objects.
26  Container includes description, path to distribution,
27  path to par_mod.f90 file, and a list of MetCase objects to be applied.
28  """
29 
30  def __init__(self, descr=None, distro_path=None,
31  parmod_path=None,
32  exec_name=None, met_case_list=None):
33 
34  """
35  descr : Description string
36  distro_path : path to source code directory
37  parmod_path : (option) Path to par_mod.f90. If no arg, uses the one
38  in the distribution
39  exec_name : name of executable
40  met_case_list : (optional) List of MetCase objects. Defaults to empty
41  list.
42  """
43 
44  if descr:
45  self._description = descr
46 
47  if distro_path:
48  if os.path.isdir(distro_path):
49  self._distro_path = distro_path
50  else:
51  raise Exception('Cannot find distro_path: ' + distro_path)
52  else:
53  raise Exception('distro_path not defined')
54 
55  # If parmod_path is not defined, then par_mod.f90 is assumed to be in the
56  # source distribution
57  if parmod_path:
58  if os.path.isfile(parmod_path):
59  self._parmod_path = parmod_path
60  else:
61  raise Exception('Cannot find parmod_path: ' + parmod_path)
62  else:
63  self._parmod_path = self._distro_path + '/par_mod.f90'
64  if not os.path.isfile(self._parmod_path):
65  raise Exception('Cannot find parmod_path in distribution: ' + self._parmod_path)
66 
67 
68  # Make sure all elements of met_case_list are indeed MetCase objects
69  if met_case_list:
70  for the_case in met_case_list:
71  if not isinstance(the_case, (MetCase.MetCase)):
72  raise Exception('item in met_case_list not a MetCase obj')
73  self._met_case_list = met_case_list
74  else:
75  self._met_case_list = []
76 
77 
78  if exec_name:
79  self._exec_name = exec_name
80  else:
81  raise Exception("No executable name provided...")
82 
83 
84  def get_descr(self):
85  return self._description
86 
87  def get_distro_path(self):
88  return self._distro_path
89 
90  def get_parmod_path(self):
91  return self._parmod_path
92 
93  def get_exec_name(self):
94  return self._exec_name
95 
96  def get_met_case_list(self):
97  return self._met_case_list
98