コード例 #1
0
ファイル: test_math.py プロジェクト: NCPP/ocgis
    def test_execute_no_units(self):
        """Test there are no units associated with a natual log."""

        field = self.get_field(with_value=True, month_count=2)
        ln = NaturalLogarithm(field=field, alias='ln')
        dvc = ln.execute()
        self.assertEqual(dvc['ln'].units, None)
コード例 #2
0
ファイル: test_math.py プロジェクト: wk1984/ocgis
    def test_execute_no_units(self):
        """Test there are no units associated with a natual log."""

        field = self.get_field(with_value=True, month_count=2)
        ln = NaturalLogarithm(field=field, alias='ln')
        dvc = ln.execute()
        self.assertEqual(dvc['ln'].units, None)
コード例 #3
0
ファイル: test_math.py プロジェクト: NCPP/ocgis
 def test_execute_spatial_aggregation(self):
     field = self.get_field(with_value=True, month_count=2)
     grouping = ['month']
     tgd = field.temporal.get_grouping(grouping)
     ln = NaturalLogarithm(field=field, tgd=tgd, calc_sample_size=True, spatial_aggregation=True)
     ret = ln.execute()
     self.assertEqual(ret['ln'].get_value().shape, (2, 2, 2, 3, 4))
     self.assertEqual(ret['n_ln'].get_value().mean(), 30.0)
コード例 #4
0
ファイル: test_math.py プロジェクト: tatarinova/ocgis
 def test_NaturalLogarithm(self):
     field = self.get_field(with_value=True,month_count=2)
     ln = NaturalLogarithm(field=field)
     ret = ln.execute()
     self.assertEqual(ret['ln'].value.shape,(2, 60, 2, 3, 4))
     self.assertNumpyAllClose(ret['ln'].value,np.log(field.variables['tmax'].value))
     
     ln = NaturalLogarithm(field=field,calc_sample_size=True)
     ret = ln.execute()
     self.assertNotIn('n_ln',ret.keys())
コード例 #5
0
ファイル: test_math.py プロジェクト: wk1984/ocgis
 def test_execute_spatial_aggregation(self):
     field = self.get_field(with_value=True, month_count=2)
     grouping = ['month']
     tgd = field.temporal.get_grouping(grouping)
     ln = NaturalLogarithm(field=field,
                           tgd=tgd,
                           calc_sample_size=True,
                           spatial_aggregation=True)
     ret = ln.execute()
     self.assertEqual(ret['ln'].get_value().shape, (2, 2, 2, 3, 4))
     self.assertEqual(ret['n_ln'].get_value().mean(), 30.0)
コード例 #6
0
ファイル: test_math.py プロジェクト: NCPP/ocgis
    def test_execute_temporally_grouped(self):
        field = self.get_field(with_value=True, month_count=2)
        grouping = ['month']
        tgd = field.temporal.get_grouping(grouping)
        ln = NaturalLogarithm(field=field, tgd=tgd)
        ret = ln.execute()
        self.assertEqual(ret['ln'].get_value().shape, (2, 2, 2, 3, 4))

        to_test = np.log(field['tmax'].get_value())
        to_test = np.ma.mean(to_test[0, tgd.dgroups[0], 0, :, :], axis=0)
        to_test2 = ret['ln'].get_value()[0, 0, 0, :, :]
        self.assertNumpyAllClose(to_test, to_test2)

        ln = NaturalLogarithm(field=field, tgd=tgd, calc_sample_size=True)
        ret = ln.execute()
        self.assertEqual(ret['ln'].get_value().shape, (2, 2, 2, 3, 4))
        self.assertEqual(ret['n_ln'].get_value().mean(), 30.0)
コード例 #7
0
ファイル: test_math.py プロジェクト: wk1984/ocgis
    def test_execute(self):
        field = self.get_field(with_value=True, month_count=2)
        ln = NaturalLogarithm(field=field)
        ret = ln.execute()
        self.assertEqual(ret['ln'].get_value().shape, (2, 60, 2, 3, 4))
        self.assertNumpyAllClose(ret['ln'].get_value(),
                                 np.log(field['tmax'].get_value()))

        ln = NaturalLogarithm(field=field, calc_sample_size=True)
        ret = ln.execute()
        self.assertNotIn('n_ln', list(ret.keys()))
コード例 #8
0
ファイル: test_math.py プロジェクト: wk1984/ocgis
    def test_execute_temporally_grouped(self):
        field = self.get_field(with_value=True, month_count=2)
        grouping = ['month']
        tgd = field.temporal.get_grouping(grouping)
        ln = NaturalLogarithm(field=field, tgd=tgd)
        ret = ln.execute()
        self.assertEqual(ret['ln'].get_value().shape, (2, 2, 2, 3, 4))

        to_test = np.log(field['tmax'].get_value())
        to_test = np.ma.mean(to_test[0, tgd.dgroups[0], 0, :, :], axis=0)
        to_test2 = ret['ln'].get_value()[0, 0, 0, :, :]
        self.assertNumpyAllClose(to_test, to_test2)

        ln = NaturalLogarithm(field=field, tgd=tgd, calc_sample_size=True)
        ret = ln.execute()
        self.assertEqual(ret['ln'].get_value().shape, (2, 2, 2, 3, 4))
        self.assertEqual(ret['n_ln'].get_value().mean(), 30.0)
コード例 #9
0
ファイル: test_math.py プロジェクト: tatarinova/ocgis
 def test_NaturalLogarithm_units_dimensionless(self):
     field = self.get_field(with_value=True,month_count=2)
     ln = NaturalLogarithm(field=field,alias='ln')
     dvc = ln.execute()
     self.assertEqual(dvc['ln'].units,None)