def test_calc_nscale_factors(): canopy_layer_bnd = np.ones(3, dtype=np.float64) nscale_factor = np.empty(3, dtype=np.float64) flag = ffi.cast('char', True) assert vic_lib.calc_Nscale_factors( flag, ffi.cast('double *', canopy_layer_bnd.ctypes.data), 3., 0.5, ffi.cast('double *', nscale_factor.ctypes.data)) is None
def test_correct_precip(): guage_correction = np.zeros(2, dtype=np.float64) assert vic_lib.correct_precip( ffi.cast('double *', guage_correction.ctypes.data), 4., 2., 0.4, 0.005) is None assert guage_correction[SNOW] > 1. assert guage_correction[RAIN] > 1. assert guage_correction[SNOW] > guage_correction[RAIN]
def test_calc_aerodynamic(): r_a = np.zeros(3, dtype=np.float64) u = np.zeros(3, dtype=np.float64) displacement = np.zeros(3, dtype=np.float64) ref_height = np.zeros(3, dtype=np.float64) roughness = np.zeros(3, dtype=np.float64) assert vic_lib.CalcAerodynamic( ffi.cast('_Bool', True), 40., 0.2, 0.0005, 0.001, 0.5, ffi.cast('double *', r_a.ctypes.data), ffi.cast('double *', u.ctypes.data), ffi.cast('double *', displacement.ctypes.data), ffi.cast('double *', ref_height.ctypes.data), ffi.cast('double *', roughness.ctypes.data)) == 0.
def test_calc_aerodynamic(): r_a = np.zeros(3, dtype=np.float64) u = np.zeros(3, dtype=np.float64) displacement = np.zeros(3, dtype=np.float64) ref_height = np.zeros(3, dtype=np.float64) roughness = np.zeros(3, dtype=np.float64) assert ( vic_lib.CalcAerodynamic( ffi.cast("_Bool", True), 40.0, 0.2, 0.0005, 0.001, 0.5, ffi.cast("double *", r_a.ctypes.data), ffi.cast("double *", u.ctypes.data), ffi.cast("double *", displacement.ctypes.data), ffi.cast("double *", ref_height.ctypes.data), ffi.cast("double *", roughness.ctypes.data), ) == 0.0 )
def test_snow_albedo_new_snow(): assert vic_lib.snow_albedo( 0.1, 1., 0.7, -77, 3600., 0, ffi.cast('char', False)) == vic_lib.param.SNOW_NEW_SNOW_ALB
def test_snow_albedo_old_snow(): orig_albedo = 0.7 assert vic_lib.snow_albedo(0., 1., orig_albedo, -77, 3600., 23, ffi.cast('char', False)) < orig_albedo assert vic_lib.snow_albedo(0., 1., orig_albedo, -77, 3600., 23, ffi.cast('char', True)) < orig_albedo
def test_snow_albedo_new_snow(): assert vic_lib.snow_albedo(0.1, 1., 0.7, -77, 3600., 0, ffi.cast( 'char', False)) == vic_lib.param.SNOW_NEW_SNOW_ALB