Example #1
0
 def setUp(self):
     self.swb = SoilWaterBalance(
         theta_s=0.425,
         theta_fc=0.287,
         theta_wp=0.14,
         zr=0.5,
         zr_factor=1000,
         p=0.5,
         draintime=16.2,
         timeseries=None,
         theta_init=None,
         mif=None,
     )
Example #2
0
class DpTestCase(TestCase):
    def setUp(self):
        self.swb = SoilWaterBalance(
            theta_s=0.425,
            theta_fc=0.287,
            theta_wp=0.14,
            zr=0.5,
            zr_factor=1000,
            p=0.5,
            draintime=16.3,
            timeseries=None,
            theta_init=0.15,
            mif=1.0,
        )

    def test_dp_when_theta_less_than_theta_s(self):
        self.assertAlmostEqual(self.swb.dp(0.4, 20.0), 4.69325153)

    def test_dp_when_theta_more_than_theta_s(self):
        self.assertAlmostEqual(self.swb.dp(0.5, 20.0), 5.46012270)
Example #3
0
class SimpleMethodsTestCase(TestCase):
    def setUp(self):
        self.swb = SoilWaterBalance(
            theta_s=0.425,
            theta_fc=0.287,
            theta_wp=0.14,
            zr=0.5,
            zr_factor=1000,
            p=0.5,
            draintime=16.2,
            timeseries=None,
            theta_init=None,
            refill_factor=None,
        )

    def test_taw(self):
        self.assertAlmostEqual(self.swb.taw, 73.5)

    def test_raw(self):
        self.assertAlmostEqual(self.swb.raw, 36.75)

    def test_dr_from_theta(self):
        self.assertAlmostEqual(self.swb.dr_from_theta(0.277326),
                               4.837,
                               places=3)

    def test_theta_from_dr(self):
        self.assertAlmostEqual(self.swb.theta_from_dr(4.837), 0.277, places=3)

    def test_ks(self):
        self.assertAlmostEqual(self.swb.ks(37.746), 0.973, places=3)

    def test_ks_when_above_threshold(self):
        self.assertAlmostEqual(self.swb.ks(30), 1)

    def test_dp(self):
        self.assertAlmostEqual(self.swb.dp(0.311, 0), 0.741, places=3)

    def test_dp_zero(self):
        self.assertEqual(self.swb.dp(0.186, 0), 0)

    def test_ro_at_saturation(self):
        # When we are already saturated (0.425), all precipitation (15 mm) runs off
        self.assertAlmostEqual(self.swb.ro(15, 0.425), 15)

    def test_ro_zero(self):
        # When the soil is practically dry and 2 mm falls, nothing runs off
        self.assertEqual(self.swb.ro(2, 0.14), 0)