You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by hu...@apache.org on 2015/08/19 02:37:48 UTC
[2/2] climate git commit: CLIMATE-659 - Remove
SpatialMeanOfTemporalMeanBias
CLIMATE-659 - Remove SpatialMeanOfTemporalMeanBias
Conflicts:
ocw/metrics.py
ocw/tests/test_metrics.py
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/45779fb9
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/45779fb9
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/45779fb9
Branch: refs/heads/master
Commit: 45779fb9890cb6d00e71fd2e47432f9687f39068
Parents: b08d379 ee1d860
Author: huikyole <hu...@argo.jpl.nasa.gov>
Authored: Tue Aug 18 17:36:30 2015 -0700
Committer: huikyole <hu...@argo.jpl.nasa.gov>
Committed: Tue Aug 18 17:36:30 2015 -0700
----------------------------------------------------------------------
ocw/metrics.py | 20 --------------------
ocw/tests/test_metrics.py | 28 ----------------------------
2 files changed, 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/45779fb9/ocw/metrics.py
----------------------------------------------------------------------
diff --cc ocw/metrics.py
index 76fc78b,3d7c536..62f4e3d
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@@ -229,28 -211,14 +229,8 @@@ class TemporalMeanBias(BinaryMetric)
:returns: The mean bias between a reference and target dataset over time.
'''
- diff = target_dataset.values - ref_dataset.values
- if absolute:
- diff = abs(diff)
- mean_bias = ma.mean(diff, axis=0)
-
- return mean_bias
-
+ return calc_bias(target_dataset.values,ref_dataset.values, average_over_time=True)
- class SpatialMeanOfTemporalMeanBias(BinaryMetric):
- '''Calculate the bias averaged over time and domain.'''
-
- def run(self, reference_dataset, target_dataset):
- '''Calculate the bias averaged over time and domain.
- .. note::
- Overrides BinaryMetric.run()
- :param reference_dataset: The reference dataset to use in this metric
- run
- :type reference_dataset: :class:`dataset.Dataset`
- :param target_dataset: The target dataset to evaluate against the
- reference dataset in this metric run
- :type target_dataset: :class:`dataset.Dataset`
- :returns: The bias averaged over time and domain
- '''
-
- bias = target_dataset.values - reference_dataset.values
- return ma.mean(bias)
-
-
class RMSError(BinaryMetric):
'''Calculate the Root Mean Square Difference (RMS Error), with the mean
calculated over time and space.'''
http://git-wip-us.apache.org/repos/asf/climate/blob/45779fb9/ocw/tests/test_metrics.py
----------------------------------------------------------------------
diff --cc ocw/tests/test_metrics.py
index 8d638be,9ee19e2..facf1d3
--- a/ocw/tests/test_metrics.py
+++ b/ocw/tests/test_metrics.py
@@@ -229,34 -208,13 +229,6 @@@ class TestTemporalMeanBias(unittest.Tes
expected_result.fill(-300)
np.testing.assert_array_equal(self.mean_bias.run(self.target_dataset,self.reference_dataset), expected_result)
- class TestSpatialMeanOfTemporalMeanBias(unittest.TestCase):
- '''Test the metrics.SpatialMeanOfTemporalMeanBias metric.'''
- def setUp(self):
- # Set metric.
- self.metric = metrics.SpatialMeanOfTemporalMeanBias()
- # Initialize reference dataset.
- self.ref_lats = np.array([10, 20, 30, 40, 50])
- self.ref_lons = np.array([5, 15, 25, 35, 45])
- self.ref_times = np.array([dt.datetime(2000, x, 1)
- for x in range(1, 13)])
- self.ref_values = np.array(range(300)).reshape(12, 5, 5)
- self.ref_variable = "ref"
- self.ref_dataset = Dataset(self.ref_lats, self.ref_lons,
- self.ref_times, self.ref_values, self.ref_variable)
- # Initialize target dataset.
- self.tgt_lats = np.array([10, 20, 30, 40, 50])
- self.tgt_lons = np.array([5, 15, 25, 35, 45])
- self.tgt_times = np.array([dt.datetime(2000, x, 1)
- for x in range(1, 13)])
- self.tgt_values = np.array(range(299, -1, -1)).reshape(12, 5, 5)
- self.tgt_variable = "tgt"
- self.tgt_dataset = Dataset(self.tgt_lats, self.tgt_lons,
- self.tgt_times, self.tgt_values, self.tgt_variable)
- def test_function_run_abs(self):
- '''Test mean bias function between reference dataset and target dataset with abs as True.'''
- expected_result = np.zeros((5, 5), dtype=np.int)
- expected_result.fill(300)
- np.testing.assert_array_equal(self.mean_bias.run(self.reference_dataset, self.target_dataset, True), expected_result)
--
- def test_function_run(self):
- result = self.metric.run(self.ref_dataset, self.tgt_dataset)
- self.assertEqual(result, 0.0)
--
class TestRMSError(unittest.TestCase):
'''Test the metrics.RMSError metric.'''
def setUp(self):