Beispiel #1
0
    def test_wrong_iso3_fail(self):

        emptyFlood = RiverFlood()
        with self.assertRaises(KeyError):
            RiverFlood._select_exact_area(['OYY'])
        with self.assertRaises(AttributeError):
            emptyFlood.set_from_nc(years=[2600], dph_path=HAZ_DEMO_FLDDPH,
                                   frc_path=HAZ_DEMO_FLDFRC)
        with self.assertRaises(KeyError):
            emptyFlood.set_from_nc(reg=['OYY'], dph_path=HAZ_DEMO_FLDDPH,
                                   frc_path=HAZ_DEMO_FLDFRC, ISINatIDGrid=True)
    def test_exact_area_selection(self):
        testCentroids, iso, natID = RiverFlood._select_exact_area(['LIE'])

        self.assertEqual(testCentroids.lon.shape[0], 13)
        self.assertAlmostEqual(testCentroids.lon[0], 9.5206968)
        self.assertAlmostEqual(testCentroids.lon[1], 9.5623634)
        self.assertAlmostEqual(testCentroids.lon[2], 9.60403)
        self.assertAlmostEqual(testCentroids.lon[3], 9.5206968)
        self.assertAlmostEqual(testCentroids.lon[4], 9.5623634)
        self.assertAlmostEqual(testCentroids.lon[5], 9.60403)
        self.assertAlmostEqual(testCentroids.lon[6], 9.5206968)
        self.assertAlmostEqual(testCentroids.lon[7], 9.5623634)
        self.assertAlmostEqual(testCentroids.lon[8], 9.60403)
        self.assertAlmostEqual(testCentroids.lon[9], 9.5206968)
        self.assertAlmostEqual(testCentroids.lon[10], 9.5623634)
        self.assertAlmostEqual(testCentroids.lon[11], 9.5206968)
        self.assertAlmostEqual(testCentroids.lon[12], 9.5623634)

        self.assertAlmostEqual(testCentroids.lat[0], 47.0622474)
        self.assertAlmostEqual(testCentroids.lat[1], 47.0622474)
        self.assertAlmostEqual(testCentroids.lat[2], 47.0622474)
        self.assertAlmostEqual(testCentroids.lat[3], 47.103914)
        self.assertAlmostEqual(testCentroids.lat[4], 47.103914)
        self.assertAlmostEqual(testCentroids.lat[5], 47.103914)
        self.assertAlmostEqual(testCentroids.lat[6], 47.1455806)
        self.assertAlmostEqual(testCentroids.lat[7], 47.1455806)
        self.assertAlmostEqual(testCentroids.lat[8], 47.1455806)
        self.assertAlmostEqual(testCentroids.lat[9], 47.1872472)
        self.assertAlmostEqual(testCentroids.lat[10], 47.1872472)
        self.assertAlmostEqual(testCentroids.lat[11], 47.2289138)
        self.assertAlmostEqual(testCentroids.lat[12], 47.2289138)
        self.assertEqual(iso[0], 'LIE')
Beispiel #3
0
    def test_exact_area_selection_region(self):

        testCentr, isos, natIDs = RiverFlood._select_exact_area(reg=['SWA'])

        self.assertEqual(testCentr.shape, (877, 976))
        self.assertAlmostEqual(np.min(testCentr.lat), -0.68767620000001, 4)
        self.assertAlmostEqual(np.max(testCentr.lat), 38.43726119999998, 4)
        self.assertAlmostEqual(np.min(testCentr.lon), 60.52061519999998, 4)
        self.assertAlmostEqual(np.max(testCentr.lon), 101.1455501999999, 4)
        self.assertAlmostEqual(testCentr.lon[10000], 98.27055479999999, 4)
        self.assertAlmostEqual(testCentr.lat[10000], 11.47897099999998, 4)