Example #1
0
 def test_get_countries_per_region(self):
     """Test static get_countries_per_region()"""
     ifs = IFSTropCyclone()
     out = ifs.get_countries_per_region('NA2')
     self.assertEqual(out[0], 'USA and Canada')
     self.assertEqual(out[1], 2)
     self.assertListEqual(out[2], [124, 840])
     self.assertListEqual(out[3], ['CAN', 'USA'])
Example #2
0
 def test_default_values_pass(self):
     """Test return TDR optimized IFs (TDR=1)"""
     ifs = IFSTropCyclone()
     v_halfs = ifs.set_calibrated_regional_IFs()
     # extract IF for region WP4
     if_wp4 = ifs.get_func(fun_id=9)[0]
     self.assertIn('TC', ifs.get_ids().keys())
     self.assertEqual(ifs.size(), 10)
     self.assertEqual(ifs.get_ids()['TC'], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
     self.assertEqual(if_wp4.intensity_unit, 'm/s')
     self.assertEqual(if_wp4.name, 'North West Pacific (WP4)')
     self.assertAlmostEqual(v_halfs['WP2'], 188.4, places=7)
     self.assertAlmostEqual(v_halfs['ROW'], 110.1, places=7)
     self.assertListEqual(list(if_wp4.intensity), list(np.arange(0, 121, 5)))
     self.assertEqual(if_wp4.paa.min(), 1.)
     self.assertEqual(if_wp4.mdd.min(), 0.0)
     self.assertAlmostEqual(if_wp4.mdd.max(), 0.15779133833203, places=5)
     self.assertAlmostEqual(if_wp4.calc_mdr(75), 0.02607326527808, places=5)
Example #3
0
 def test_RMSF_pass(self):
     """Test return RMSF optimized IFs (RMSF=minimum)"""
     ifs = IFSTropCyclone()
     v_halfs = ifs.set_calibrated_regional_IFs('RMSF')
     # extract IF for region NA1
     if_na1 = ifs.get_func(fun_id=1)[0]
     self.assertEqual(ifs.size(), 10)
     self.assertEqual(ifs.get_ids()['TC'], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
     self.assertEqual(if_na1.intensity_unit, 'm/s')
     self.assertEqual(if_na1.name, 'Caribbean and Mexico (NA1)')
     self.assertAlmostEqual(v_halfs['NA1'], 59.6, places=7)
     self.assertAlmostEqual(v_halfs['ROW'], 73.4, places=7)
     self.assertListEqual(list(if_na1.intensity), list(np.arange(0, 121, 5)))
     self.assertEqual(if_na1.mdd.min(), 0.0)
     self.assertAlmostEqual(if_na1.mdd.max(), 0.95560418241669, places=5)
     self.assertAlmostEqual(if_na1.calc_mdr(75), 0.7546423895457, places=5)
Example #4
0
 def test_quantile_pass(self):
     """Test return IFs from quantile of inidividual event fitting (EDR=1)"""
     ifs = IFSTropCyclone()
     ifs.set_calibrated_regional_IFs('EDR')
     ifs_p10 = IFSTropCyclone()
     ifs_p10.set_calibrated_regional_IFs('EDR', q=.1)
     # extract IF for region SI
     if_si = ifs.get_func(fun_id=5)[0]
     if_si_p10 = ifs_p10.get_func(fun_id=5)[0]
     self.assertEqual(ifs.size(), 10)
     self.assertEqual(ifs_p10.size(), 10)
     self.assertEqual(if_si.intensity_unit, 'm/s')
     self.assertEqual(if_si_p10.name, 'South Indian (SI)')
     self.assertAlmostEqual(if_si_p10.mdd.max(), 0.99999999880, places=5)
     self.assertAlmostEqual(if_si.calc_mdr(30), 0.01620503041, places=5)
     intensity = np.random.randint(26, if_si.intensity.max())
     self.assertTrue(
         if_si.calc_mdr(intensity) < if_si_p10.calc_mdr(intensity))