Exemple #1
0
class TestModelledModelDictFn(unittest.TestCase):
    
    @data(ModelledVarMAVG(), ModelledVarAANOM())
    def test_gcm_key(self, data):
        self.assertIn("ingv_echam4", data.dataset.as_dict())
        
    def test_gcm_key_ensemble(self):
        data = ModelledStat()
        self.assertIn("ensemble_90", data.dataset.as_dict())
        
    @data([ModelledVarMAVG(), ("BR",)], 
        [ModelledVarAANOM(), ("JP",)], 
        [ModelledStat(), ("AU", "NZ")],
        )
    def test_region_key(self, foo):
        data, expected_regions = foo
        for gcm_dict in data.dataset.as_dict().values():
            for region in expected_regions:
                self.assertIn(region, gcm_dict)

    @data([ModelledVarMAVG(), "2039"], [ModelledStat(), "2065"])
    def test_date_key_monthly(self, foo):
        data, year = foo
        res = data.dataset.as_dict()
        for gcm_dict in res.values():
            for region_dict in gcm_dict.values():
                self.assertEqual(len(region_dict[year]), 12)

    def test_date_key_yearly(self):
        data = ModelledVarAANOM()
        res = data.dataset.as_dict()
        for gcm_dict in res.values():
            for region_dict in gcm_dict.values():
                # Just check one date
                self.assertIn("2079", region_dict)

    def test_date_key_yearly_datetime(self):
        data = ModelledVarAANOM()
        res = data.dataset.as_dict(use_datetime=True)
        for gcm_dict in res.values():
            for region_dict in gcm_dict.values():
                # Just check one date
                self.assertIn(datetime.date(2079, 1, 1), region_dict)

    def test_value(self):
        data = ModelledStat()
        res = data.dataset.as_dict()["ensemble_90"]["NZ"]["2065"][10]
        self.assertEqual(res, 12.763983215594646)

    def test_value_b1_scenario_kwarg(self):
        data = ModelledStat()
        res = data.dataset.as_dict(sres="b1")["ensemble_90"]["NZ"]["2065"][10]
        self.assertEqual(res, 12.463586228230714)
Exemple #2
0
class TestModelledModelBasicAttrs(unittest.TestCase):

    @data(ModelledVarMAVG(), ModelledVarAANOM())
    def test_gcm_attr(self, data):
        self.assertIn("bccr_bcm2_0", data.dataset.gcms)

    def test_gcm_attr_ensemble(self):
        data = ModelledStat()
        self.assertIn("ensemble_10", data.dataset.gcms)

    @data(ModelledVarMAVG(), ModelledVarAANOM(), ModelledStat())
    def test_scenario_attr(self, data):
        self.assertIn("a2", data.dataset.sres)
        self.assertIn("b1", data.dataset.sres)
Exemple #3
0
 def test_value_b1_scenario_kwarg(self):
     data = ModelledStat()
     res = data.dataset.as_dict(sres="b1")["ensemble_90"]["NZ"]["2065"][10]
     self.assertEqual(res, 12.463586228230714)
Exemple #4
0
 def test_value(self):
     data = ModelledStat()
     res = data.dataset.as_dict()["ensemble_90"]["NZ"]["2065"][10]
     self.assertEqual(res, 12.763983215594646)
Exemple #5
0
 def test_gcm_key_ensemble(self):
     data = ModelledStat()
     self.assertIn("ensemble_90", data.dataset.as_dict())
Exemple #6
0
 def test_stat_datetime(self):
     data = ModelledStat()
     dt = lambda x: datetime.date(x, 1, 1)
     expected = [(dt(2046), dt(2065))]
     self.assertEqual(data.dataset.dates(use_datetime=True), expected)
Exemple #7
0
 def test_stat(self):
     data = ModelledStat()
     expected = [("2046", "2065")]
     self.assertEqual(data.dataset.dates(), expected)
Exemple #8
0
 def test_gcm_attr_ensemble(self):
     data = ModelledStat()
     self.assertIn("ensemble_10", data.dataset.gcms)