FLEXPART Testing Environment CTBTO WO8
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
flextest.FlexpartErrors.FlexpartErrors Class Reference
Inheritance diagram for flextest.FlexpartErrors.FlexpartErrors:
Inheritance graph
[legend]
Collaboration diagram for flextest.FlexpartErrors.FlexpartErrors:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def get_diff_grid
 
def mean_absolute_error
 
def max_absolute_error
 
def max_error
 
def mean_bias
 
def rmse
 

Private Member Functions

def _get_grid
 

Private Attributes

 _control_output
 
 _test_output
 

Detailed Description

A class that takes two FlexpartOutput objects as input and provides
methods for calculation of errors on slices, volumes and timeseries.

The following arguments are included in most of the calls to methods,
so are described here rather than in each method.  There are a variety
of combinations, which might get confusing, as not all arguments are
used in all cases.

timestamp : If it has a value, and if this is not a timeseries, then 
the indicated timestamp is used

timestamp_list : if timeseries is True, then this will be used to provide
the list of timestamps to use.  

level : specifies the level to use for a slice.  Indexed from 1.

level_list : if volume is True, then this will be used to provide the
list of levels to use.

species : species number to use.  Indexed from 1

release : release number to use.  Indexed from 1

age_class : age_class number to use.  Indexed from 1

wet : if True, use the wet deposition.  If dry is also True, the
result is non-deterministic

dry : if True, use the dry deposition.  If wet is also True, the result
is non-deterministic

timeseries : if True, then it will use a timeseries as defined in 
timestamp_list.  If timestamp_list is None, then a timeseries of
all available timestamps will be used

volume : if True, then it will use a volume as defined in level_list.
If level_list is None, then a volume of all available levels will be
used.

Definition at line 12 of file FlexpartErrors.py.

Constructor & Destructor Documentation

def flextest.FlexpartErrors.FlexpartErrors.__init__ (   self,
  control = None,
  test = None 
)
Constructor
control: a FlexpartOutput object to be used as control data
test: a FlexpartOutput object to be used as test data

Definition at line 61 of file FlexpartErrors.py.

61 
62  def __init__(self, control=None, test=None):
63 
64  """
65  Constructor
66  control: a FlexpartOutput object to be used as control data
67  test: a FlexpartOutput object to be used as test data
68  """
69 
70  # Let's do a bit of a sanity check on equal dimensions. Get
71  # a default volume from each and compare
72  # the dimensions. Also check that timestamps are the same.
73 
74 
75  control_volume_shape = control.get_volume().shape
76  test_volume_shape = test.get_volume().shape
77 
78  control_timestamps = control.get_timestamp_list()
79  test_timestamps = test.get_timestamp_list()
80 
81  if control_volume_shape == test_volume_shape and \
82  control_timestamps == test_timestamps:
83 
84  self._control_output = control
85  self._test_output = test
86 
87  else:
88 
89  self._control_output = None
90  self._test_output = None
91 
92 
93 

Member Function Documentation

def flextest.FlexpartErrors.FlexpartErrors._get_grid (   self,
  flexout_obj = None,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
private
Gets the grid as specified by the parameters.  This is a private
method and flexout_obj is intended to be the control or test grid
that this class contains.

Note the True/False values of the last parameters.  They will 
dictate the flow of this routine.

Definition at line 327 of file FlexpartErrors.py.

328  volume=False):
329 
330 
331 
332  """
333  Gets the grid as specified by the parameters. This is a private
334  method and flexout_obj is intended to be the control or test grid
335  that this class contains.
336 
337  Note the True/False values of the last parameters. They will
338  dictate the flow of this routine.
339  """
340 
341  if not timeseries and not volume:
342  # horiz slices
343 
344  if not wet and not dry:
345  the_grid = flexout_obj.get_horiz_slice(
346  timestamp=timestamp,
347  level=level,
348  species=species,
349  release=release,
350  age_class=age_class)
351 
352  else:
353 
354  if wet and dry:
355  logging.error("Bad options - cannot specify both wet and dry")
356  the_grid = None
357  else:
358  if wet: depo_type = 'wet'
359  if dry: depo_type = 'dry'
360 
361  the_grid = flexout_obj.get_deposition(
362  timestamp=timestamp,
363  species=species,
364  release=release,
365  age_class=age_class,
366  depo_type=depo_type)
367 
368 
369  elif volume and not timeseries:
370  # Volume grid
371  the_grid = flexout_obj.get_volume(
372  timestamp=timestamp,
373  level_list=level_list,
374  species=species,
375  release=release,
376  age_class=age_class)
377 
378 
379  elif timeseries and not volume:
380  # Timeseries of horiz slices
381 
382  if not wet and not dry:
383  the_grid = flexout_obj.get_horiz_timeseries(
384  timestamp_list=timestamp_list,
385  level=level,
386  species=species,
387  release=release,
388  age_class=age_class)
389 
390 
391  else:
392 
393  if wet and dry:
394  logging.error("Bad options - cannot specify both wet and dry")
395  the_grid = None
396  else:
397  if wet: depo_type = 'wet'
398  if dry: depo_type = 'dry'
399 
400  the_grid = flexout_obj.get_deposition_timeseries(
401  timestamp_list=timestamp_list,
402  species=species,
403  release=release,
404  age_class=age_class,
405  depo_type=depo_type)
406 
407 
408  elif timeseries and volume:
409  # Timeseries of volumes
410  the_grid = flexout_obj.get_volume_timeseries(
411  timestamp_list=timestamp_list,
412  level_list=level_list,
413  species=species,
414  release=release,
415  age_class=age_class)
416 
417  else:
418  # If we made it here, we have bad combination of options
419  # and can't select a routine to generate the the_grid
420  logging.error("Bad options - cannot generate a the_grid")
421  the_grid = None
422 
423  return the_grid
424 
425 
426 
427 

Here is the caller graph for this function:

def flextest.FlexpartErrors.FlexpartErrors.get_diff_grid (   self,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
Gets the difference grid as specified by the parameters.

Note the True/False values of the last parameters:

Definition at line 104 of file FlexpartErrors.py.

105  volume=False):
106 
107  """
108  Gets the difference grid as specified by the parameters.
109 
110  Note the True/False values of the last parameters:
111 
112 
113  """
114 
115 
116  # Extract grids from the control and test FlexpartOutput objects.
117  # The grid is defined by the various parameters.
118  control_grid = self._get_grid(flexout_obj=self._control_output,
119  timestamp=timestamp,
120  timestamp_list=timestamp_list,
121  level=level,
122  level_list=level_list,
123  species=species,
124  release=release,
125  age_class=age_class,
126  wet=wet,
127  dry=dry,
128  timeseries=timeseries,
129  volume=volume)
130 
131 
132  test_grid = self._get_grid(flexout_obj=self._test_output,
133  timestamp=timestamp,
134  timestamp_list=timestamp_list,
135  level=level,
136  level_list=level_list,
137  species=species,
138  release=release,
139  age_class=age_class,
140  wet=wet,
141  dry=dry,
142  timeseries=timeseries,
143  volume=volume)
144 
145  diff_grid = test_grid - control_grid
146 
147 
148  return diff_grid
149 

Here is the call graph for this function:

Here is the caller graph for this function:

def flextest.FlexpartErrors.FlexpartErrors.max_absolute_error (   self,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
Returns the max absolute error of the test and control grid, as
defined by the parameters

Definition at line 191 of file FlexpartErrors.py.

192  volume=False):
193  """
194  Returns the max absolute error of the test and control grid, as
195  defined by the parameters
196  """
197 
198  diff_grid = self.get_diff_grid(timestamp=timestamp,
199  timestamp_list=timestamp_list,
200  level=level,
201  level_list=level_list,
202  species=species,
203  release=release,
204  age_class=age_class,
205  wet=wet,
206  dry=dry,
207  timeseries=timeseries,
208  volume=volume)
209 
210  return np.absolute(diff_grid).max()
211 

Here is the call graph for this function:

Here is the caller graph for this function:

def flextest.FlexpartErrors.FlexpartErrors.max_error (   self,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
Returns the max error of the test and control grid, as
defined by the parameters.  
NOTE - I "think" this is the same as max_abs_error as written,
and maybe shouldn't have the key=abs... 

Definition at line 222 of file FlexpartErrors.py.

223  volume=False):
224  """
225  Returns the max error of the test and control grid, as
226  defined by the parameters.
227  NOTE - I "think" this is the same as max_abs_error as written,
228  and maybe shouldn't have the key=abs...
229  """
230 
231  diff_grid = self.get_diff_grid(timestamp=timestamp,
232  timestamp_list=timestamp_list,
233  level=level,
234  level_list=level_list,
235  species=species,
236  release=release,
237  age_class=age_class,
238  wet=wet,
239  dry=dry,
240  timeseries=timeseries,
241  volume=volume)
242 
243  return max(diff_grid.max(), diff_grid.min(), key=abs)
244 

Here is the call graph for this function:

Here is the caller graph for this function:

def flextest.FlexpartErrors.FlexpartErrors.mean_absolute_error (   self,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
Returns the mean absolute error of the test and control grid, as
defined by the parameters

Definition at line 160 of file FlexpartErrors.py.

161  volume=False):
162  """
163  Returns the mean absolute error of the test and control grid, as
164  defined by the parameters
165  """
166 
167  diff_grid = self.get_diff_grid(timestamp=timestamp,
168  timestamp_list=timestamp_list,
169  level=level,
170  level_list=level_list,
171  species=species,
172  release=release,
173  age_class=age_class,
174  wet=wet,
175  dry=dry,
176  timeseries=timeseries,
177  volume=volume)
178 
179  return np.absolute(diff_grid).mean()
180 

Here is the call graph for this function:

Here is the caller graph for this function:

def flextest.FlexpartErrors.FlexpartErrors.mean_bias (   self,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
Returns the mean of the biases of the test and control grid, as
defined by the parameters

Definition at line 255 of file FlexpartErrors.py.

256  volume=False):
257  """
258  Returns the mean of the biases of the test and control grid, as
259  defined by the parameters
260  """
261 
262  diff_grid = self.get_diff_grid(timestamp=timestamp,
263  timestamp_list=timestamp_list,
264  level=level,
265  level_list=level_list,
266  species=species,
267  release=release,
268  age_class=age_class,
269  wet=wet,
270  dry=dry,
271  timeseries=timeseries,
272  volume=volume)
273 
274  return diff_grid.mean()
275 

Here is the call graph for this function:

Here is the caller graph for this function:

def flextest.FlexpartErrors.FlexpartErrors.rmse (   self,
  timestamp = None,
  timestamp_list = None,
  level = 1,
  level_list = None,
  species = 1,
  release = 1,
  age_class = 1,
  wet = False,
  dry = False,
  timeseries = False,
  volume = False 
)
Returns the root mean square error of the test and control grid, as
defined by the parameters

Definition at line 286 of file FlexpartErrors.py.

287  volume=False):
288  """
289  Returns the root mean square error of the test and control grid, as
290  defined by the parameters
291  """
292 
293  diff_grid = self.get_diff_grid(timestamp=timestamp,
294  timestamp_list=timestamp_list,
295  level=level,
296  level_list=level_list,
297  species=species,
298  release=release,
299  age_class=age_class,
300  wet=wet,
301  dry=dry,
302  timeseries=timeseries,
303  volume=volume)
304 
305  return np.sqrt( ( diff_grid**2).mean() )
306 
307 
308  return diff_grid.max()
309 
310 
311 
312 
313 
314 
315 

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

flextest.FlexpartErrors.FlexpartErrors._control_output
private

Definition at line 83 of file FlexpartErrors.py.

flextest.FlexpartErrors.FlexpartErrors._test_output
private

Definition at line 84 of file FlexpartErrors.py.


The documentation for this class was generated from the following file: