Skip to content

Commit

Permalink
running initial tests for model
Browse files Browse the repository at this point in the history
  • Loading branch information
bulli92 committed May 31, 2017
1 parent 7d8d865 commit d54181d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
14 changes: 7 additions & 7 deletions sense/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def _set_models(self, RT_s, RT_c):


# set canopy models
if RT_c == 'nix':
assert False
if RT_c == 'dummy':
print('Still need to implement the canopy model here')
else:
assert False, 'Invalid canopy scattering model'

Expand Down Expand Up @@ -177,7 +177,7 @@ class CanopyHomo(object):
in that case the Lambert Beer law applies
"""
def __init__(self, ke_h, ke_v, d, theta):
def __init__(self, **kwargs):
"""
Parameters
----------
Expand All @@ -188,10 +188,10 @@ def __init__(self, ke_h, ke_v, d, theta):
theta : float, ndarray
incidence angle [rad]
"""
self.ke_h = ke_h
self.ke_v = ke_v
self.theta = theta
self.d = d
self.ke_h = kwargs.get('ke_h', None)
self.ke_v = kwargs.get('ke_v', None)
self.theta = kwargs.get('theta', None)
self.d = kwargs.get('d', None)

self.tau_h = self._tau(self.ke_h)
self.tau_v = self._tau(self.ke_v)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_canopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ def test_canopyhomo(self):
ke_v = 3.
theta = 0.5
d = 0.
C = CanopyHomo(ke_h, ke_v, d, theta)
C = CanopyHomo(ke_h=ke_h, ke_v=ke_v, d=d, theta=theta)
self.assertEqual(C.t_v, 1.)
self.assertEqual(C.t_h, 1.)

d = 1.
ke_h = 0.
ke_v = 0.
C = CanopyHomo(ke_h, ke_v, d, theta)
C = CanopyHomo(ke_h=ke_h, ke_v=ke_v, d=d, theta=theta)
self.assertEqual(C.t_v, 1.)
self.assertEqual(C.t_h, 1.)


theta = np.deg2rad(60.)
ke_h = 1.
ke_v = 2.
C = CanopyHomo(ke_h, ke_v, d, theta)
C = CanopyHomo(ke_h=ke_h, ke_v=ke_v, d=d, theta=theta)
self.assertAlmostEqual(C.t_v, np.exp(-4.))
self.assertAlmostEqual(C.t_h, np.exp(-2.))

Expand Down
7 changes: 6 additions & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import numpy as np
from sense import model
from sense.soil import Soil
from sense.model import CanopyHomo

class TestModel(unittest.TestCase):
def test_init(self):
Expand All @@ -22,7 +24,10 @@ def test_init(self):
def test_scat(self):
# some dummy variables
models = {'surface': 'Oh92', 'canopy':'dummy'}
S = model.SingleScatRT(surface='abc', canopy='def', models=models, theta=self.theta)
eps = 5. -3.j
soil = Soil(eps=eps, f=5., s=0.02)
can = CanopyHomo(ke_h=0.05, ke_v=0.02, d=3., theta=np.arange(1.,80.))
S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=self.theta)
S.sigma0()

if __name__ == '__main__':
Expand Down

0 comments on commit d54181d

Please sign in to comment.