3 Created on Mon May 4 15:50:42 2015
16 A class that takes two FlexpartOutput objects as input and provides
17 methods for calculation of errors on slices, volumes and timeseries.
19 The following arguments are included in most of the calls to methods,
20 so are described here rather than in each method. There are a variety
21 of combinations, which might get confusing, as not all arguments are
24 timestamp : If it has a value, and if this is not a timeseries, then
25 the indicated timestamp is used
27 timestamp_list : if timeseries is True, then this will be used to provide
28 the list of timestamps to use.
30 level : specifies the level to use for a slice. Indexed from 1.
32 level_list : if volume is True, then this will be used to provide the
33 list of levels to use.
35 species : species number to use. Indexed from 1
37 release : release number to use. Indexed from 1
39 age_class : age_class number to use. Indexed from 1
41 wet : if True, use the wet deposition. If dry is also True, the
42 result is non-deterministic
44 dry : if True, use the dry deposition. If wet is also True, the result
47 timeseries : if True, then it will use a timeseries as defined in
48 timestamp_list. If timestamp_list is None, then a timeseries of
49 all available timestamps will be used
51 volume : if True, then it will use a volume as defined in level_list.
52 If level_list is None, then a volume of all available levels will be
65 control: a FlexpartOutput object to be used as control data
66 test: a FlexpartOutput object to be used as test data
74 control_volume_shape = control.get_volume().shape
75 test_volume_shape = test.get_volume().shape
77 control_timestamps = control.get_timestamp_list()
78 test_timestamps = test.get_timestamp_list()
80 if control_volume_shape == test_volume_shape
and \
81 control_timestamps == test_timestamps:
107 Gets the difference grid as specified by the parameters.
109 Note the True/False values of the last parameters:
119 timestamp_list=timestamp_list,
121 level_list=level_list,
127 timeseries=timeseries,
133 timestamp_list=timestamp_list,
135 level_list=level_list,
141 timeseries=timeseries,
144 diff_grid = test_grid - control_grid
162 Returns the mean absolute error of the test and control grid, as
163 defined by the parameters
167 timestamp_list=timestamp_list,
169 level_list=level_list,
175 timeseries=timeseries,
178 return np.absolute(diff_grid).mean()
193 Returns the max absolute error of the test and control grid, as
194 defined by the parameters
198 timestamp_list=timestamp_list,
200 level_list=level_list,
206 timeseries=timeseries,
209 return np.absolute(diff_grid).max()
224 Returns the max error of the test and control grid, as
225 defined by the parameters.
226 NOTE - I "think" this is the same as max_abs_error as written,
227 and maybe shouldn't have the key=abs...
231 timestamp_list=timestamp_list,
233 level_list=level_list,
239 timeseries=timeseries,
242 return max(diff_grid.max(), diff_grid.min(), key=abs)
257 Returns the mean of the biases of the test and control grid, as
258 defined by the parameters
262 timestamp_list=timestamp_list,
264 level_list=level_list,
270 timeseries=timeseries,
273 return diff_grid.mean()
276 def rmse(self, timestamp=None,
288 Returns the root mean square error of the test and control grid, as
289 defined by the parameters
293 timestamp_list=timestamp_list,
295 level_list=level_list,
301 timeseries=timeseries,
304 return np.sqrt( ( diff_grid**2).mean() )
307 return diff_grid.max()
332 Gets the grid as specified by the parameters. This is a private
333 method and flexout_obj is intended to be the control or test grid
334 that this class contains.
336 Note the True/False values of the last parameters. They will
337 dictate the flow of this routine.
340 if not timeseries
and not volume:
343 if not wet
and not dry:
344 the_grid = flexout_obj.get_horiz_slice(
354 logging.error(
"Bad options - cannot specify both wet and dry")
357 if wet: depo_type =
'wet'
358 if dry: depo_type =
'dry'
360 the_grid = flexout_obj.get_deposition(
368 elif volume
and not timeseries:
370 the_grid = flexout_obj.get_volume(
372 level_list=level_list,
378 elif timeseries
and not volume:
381 if not wet
and not dry:
382 the_grid = flexout_obj.get_horiz_timeseries(
383 timestamp_list=timestamp_list,
393 logging.error(
"Bad options - cannot specify both wet and dry")
396 if wet: depo_type =
'wet'
397 if dry: depo_type =
'dry'
399 the_grid = flexout_obj.get_deposition_timeseries(
400 timestamp_list=timestamp_list,
407 elif timeseries
and volume:
409 the_grid = flexout_obj.get_volume_timeseries(
410 timestamp_list=timestamp_list,
411 level_list=level_list,
419 logging.error(
"Bad options - cannot generate a the_grid")