def test_calculate(self): rd = self.test_data.get_rd('cancm4_tasmax_2011') field = rd.get() field = field.get_field_slice({'y': slice(0, 10), 'x': slice(0, 10)}) for calc_grouping in [['month'], ['month', 'year']]: tgd = field.temporal.get_grouping(calc_grouping) itg = IcclimSU(field=field, tgd=tgd) ret_icclim = itg.execute() threshold = Threshold(field=field, tgd=tgd, parms={'threshold': 298.15, 'operation': 'gt'}) ret_ocgis = threshold.execute() self.assertNumpyAll(ret_icclim['icclim_SU'].get_value(), ret_ocgis['threshold'].get_value())
def test_execute(self): field = self.get_field(with_value=True, month_count=2) grouping = ['month'] tgd = field.temporal.get_grouping(grouping) dv = Threshold(field=field, parms={ 'threshold': 0.5, 'operation': 'gte' }, tgd=tgd) ret = dv.execute() self.assertEqual(ret['threshold'].get_value().shape, (2, 2, 2, 3, 4)) self.assertNumpyAllClose( ret['threshold'].get_masked_value()[1, 1, 1, 0, :], np.ma.array([13, 16, 15, 12], mask=False))