def test_valleyband_cube(self): """test correct cube data is produced for land bands < 0m""" result = GenOrogMasks().gen_orography_masks(self.orography, self.landmask, self.valley_key, self.valley_threshold)[0] self.assertEqual(result.attributes['Topographical Type'], 'Land') self.assertEqual( result.coord('topographic_bound_lower').points, self.valley_threshold[0]) self.assertEqual( result.coord('topographic_bound_upper').points, self.valley_threshold[1])
def test_maxband_cube(self): """test correct cube data is produced for land bands > max""" result = GenOrogMasks().gen_orography_masks(self.orography, self.landmask, self.max_key, self.max_threshold)[0] self.assertEqual(result.attributes['Topographical Type'], 'Max_Land_Threshold') self.assertEqual( result.coord('topographic_bound_lower').points, self.max_threshold[0]) msg = 'Expected to find exactly 1 coordinate, but found none.' with self.assertRaisesRegexp(CoordinateNotFoundError, msg): result.coord('topographic_bound_upper')
def test_landband_cube(self): """test correct cube data is produced for land bands > 0m""" result = GenOrogMasks().gen_orography_masks(self.orography, self.landmask, self.land_threshold) self.assertEqual( result.attributes["topographic_zones_include_seapoints"], "False") self.assertEqual( result.coord("topographic_zone").points, np.mean(self.land_threshold)) self.assertEqual( result.coord("topographic_zone").bounds[0][0], self.land_threshold[0]) self.assertEqual( result.coord("topographic_zone").bounds[0][1], self.land_threshold[1])
def test_landband_cube(self): """test correct cube data is produced for land bands > 0m""" result = GenOrogMasks().gen_orography_masks(self.orography, self.landmask, self.land_key, self.land_threshold) self.assertEqual(result.attributes['Topographical Type'], 'Land') self.assertEqual( result.coord('topographic_zone').points, np.mean(self.land_threshold)) self.assertEqual( result.coord('topographic_zone').bounds[0][0], self.land_threshold[0]) self.assertEqual( result.coord('topographic_zone').bounds[0][1], self.land_threshold[1])
def test_nonzero_landband_cube(self): """test that a correct cube is produced when neither landband bound is zero.""" result = GenOrogMasks().gen_orography_masks( self.orography, self.landmask, self.nonzero_land_threshold) self.assertEqual( result.coord('topographic_zone').points, np.mean(self.nonzero_land_threshold))
def test_high_landband_cube(self): """test that a correct cube is produced when the land band is higher than any land in the test cube.""" result = GenOrogMasks().gen_orography_masks(self.orography, self.landmask, self.high_land_threshold) self.assertEqual( result.coord("topographic_zone").points, np.mean(self.high_land_threshold))
def test_unit_conversion_for_landband_data(self): """test correct mask is produced for land bands > 0m""" land_threshold = [0, 0.05] threshold_units = "km" result = GenOrogMasks().gen_orography_masks( self.orography, self.landmask, land_threshold, units=threshold_units ) self.assertArrayAlmostEqual(result.data, self.exp_landmask) self.assertEqual(result.coord("topographic_zone").units, Unit("m"))