def test_less_refringent_bottom_layer(): # Regression test 19-03-2018: value may change if other bugs found snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density=[290.0, 250.0], radius=50e-6, stickiness=0.2, substrate=make_soil("transparent", 1, 270)) m = make_model("dmrt_qcacp_shortrange", "dort") scat = active(10e9, 45) res = m.run(scat, snowpack) print(res.sigmaVV_dB(), res.sigmaHH_dB()) assert abs(res.sigmaVV_dB() - -50.25547167709486) < 1e-1 assert abs(res.sigmaHH_dB() - -50.52755576862734) < 1e-1 # The following test fails # def test_less_refringent_bottom_layer_VV(): # # Regression test 19-03-2018: value may change if other bugs found # snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density = [290.0, 250.0], radius = 1e-4, stickiness=0.2) # m = make_model("dmrt_qcacp_shortrange", "dort") # scat = active(10e9, 45) # res = m.run(scat, snowpack) # print(res.sigmaVV()) # assert abs(res.sigmaVV() - 7.54253344e-05) < 1e-7 # # # def test_less_refringent_bottom_layer_HH(): # # Regression test 19-03-2018: value may change if other bugs found # snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density = [290.0, 250.0], radius = 1e-4, stickiness=0.2) # m = make_model("dmrt_qcacp_shortrange", "dort") # scat = active(10e9, 45) # res = m.run(scat, snowpack) # print(res.sigmaHH()) # assert abs(res.sigmaHH() - 7.09606407e-05) < 1e-7
def test_iba_oneconfig(): # prepare inputs l = 2 n_max_stream = 64 nl = l//2 # // Forces integer division thickness = np.array([0.1, 0.1]*nl) thickness[-1] = 100 # last one is semi-infinit p_ex = np.array([5e-5]*l) temperature = np.array([250.0, 250.0]*nl) density = [200, 400]*nl # create the snowpack snowpack = make_snowpack(thickness=thickness, microstructure_model="exponential", density=density, temperature=temperature, corr_length=p_ex) # create the snowpack m = make_model("iba_original", "dort") # create the sensor radiometer = sensor_list.amsre('37V') # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) #original absorption (Maetzler 1998) assert abs(res.TbV() - 247.92344524715216) < 1e-4 assert abs(res.TbH() - 237.0863426896562) < 1e-4
def _do_test_isothermal_universe(pc, thickness_1): T = 265 substrate = make_soil('soil_wegmuller', permittivity_model=complex(10, 1), roughness_rms=0.001, temperature=T) snowpack = make_snowpack([0.3, thickness_1], "exponential", density=[200, 300], temperature=T, corr_length=pc, substrate=substrate) atmosphere = SimpleIsotropicAtmosphere(tbdown=T, tbup=0, trans=1) # create the sensor theta = range(10, 80, 5) radiometer = sensor_list.passive(37e9, theta) # create the EM Model m = make_model("iba", "dort") # run the model sresult = m.run(radiometer, snowpack, atmosphere) np.testing.assert_allclose(sresult.TbV(), T, atol=0.01) np.testing.assert_allclose(sresult.TbH(), T, atol=0.01)
def test_simple_isotropic_atmosphere(): # prepare inputs density = [300, 300] temperature = [265, 265] thickness = [0.4, 10] radius = [200e-6, 400e-6] #stickiness = [1000, 1000] stickiness = [0.2, 0.2] rads = sensor_list.amsre('36V') atmos = SimpleIsotropicAtmosphere(30., 6., 0.90) snowpack = make_snowpack(thickness, "sticky_hard_spheres", density=density, temperature=temperature, radius=radius, stickiness=stickiness) # create the EM Model - Equivalent DMRTML iba = make_model("iba", "dort") res1 = iba.run(rads, snowpack) res2 = iba.run(rads, snowpack, atmosphere=atmos) print('TB 1: ', res1.TbV(), 'TB2: ', res2.TbV()) #absorption with effective permittivity #ok_(abs(res1.TbV() - 227.59158654174465) < 1e-2) #ok_(abs(res2.TbV() - 214.64368439876984) < 1e-2) #original absorption (Maetzler 1998) ok_(abs(res1.TbV() - 223.925496277253) < 1e-2) ok_(abs(res2.TbV() - 211.7175839349701) < 1e-2)
def test_less_refringent_bottom_layer_HH(): # Regression test 19-03-2018: value may change if other bugs found snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density=[290.0, 250.0], radius=50e-6, stickiness=0.2) m = make_model("dmrt_qcacp_shortrange", "dort") scat = active(10e9, 45) res = m.run(scat, snowpack) print(res.sigmaHH()) assert abs(res.sigmaHH() - 8.85784528e-06) < 1e-9 # The following test fails # def test_less_refringent_bottom_layer_VV(): # # Regression test 19-03-2018: value may change if other bugs found # snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density = [290.0, 250.0], radius = 1e-4, stickiness=0.2) # m = make_model("dmrt_qcacp_shortrange", "dort") # scat = active(10e9, 45) # res = m.run(scat, snowpack) # print(res.sigmaVV()) # assert abs(res.sigmaVV() - 7.54253344e-05) < 1e-7 # # # def test_less_refringent_bottom_layer_HH(): # # Regression test 19-03-2018: value may change if other bugs found # snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density = [290.0, 250.0], radius = 1e-4, stickiness=0.2) # m = make_model("dmrt_qcacp_shortrange", "dort") # scat = active(10e9, 45) # res = m.run(scat, snowpack) # print(res.sigmaHH()) # assert abs(res.sigmaHH() - 7.09606407e-05) < 1e-7
def test_dmrt_oneconfig(): # prepare inputs l = 2 nl = l//2 # // Forces integer division thickness = np.array([0.1, 0.1]*nl) thickness[-1] = 100 # last one is semi-infinit radius = np.array([2e-4]*l) temperature = np.array([250.0, 250.0]*nl) density = [200, 400]*nl stickiness = [0.1, 0.1]*nl # create the snowpack snowpack = make_snowpack(thickness, "sticky_hard_spheres", density=density, temperature=temperature, radius=radius, stickiness=stickiness) # create the EM Model m = make_model("dmrt_shortrange", "dort") # create the sensor radiometer = amsre('37V') # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) ok_((res.TbV() - 202.34939425929616) < 1e-4) ok_((res.TbH() - 187.05199255031036) < 1e-4)
def test_simple_isotropic_atmosphere(): # prepare inputs density = [300, 300] temperature = [265, 265] thickness = [0.4, 10] radius = [200e-6, 400e-6] stickiness = [0.2, 0.2] rads = sensor_list.amsre('36V') atmos = SimpleIsotropicAtmosphere(30., 6., 0.90) snowpack = make_snowpack(thickness, "sticky_hard_spheres", density=density, temperature=temperature, radius=radius, stickiness=stickiness) # create the EM Model - Equivalent DMRTML iba = make_model("iba", "dort") res1 = iba.run(rads, snowpack) snowpack.atmosphere = atmos res2 = iba.run(rads, snowpack) print('TB 1: ', res1.TbV(), 'TB2: ', res2.TbV()) # absorption with effective permittivity assert abs(res1.TbV() - 227.61318467710458) < 1e-2 assert abs(res2.TbV() - 214.66092232541834) < 1e-2
def test_oneconfig_for_multiyear_sea_ice(): # prepare inputs l, n_max_stream, thickness, temperature, salinity = setup_seaice() p_ex = np.array([1000e-6] * l) # correlation length porosity = 0.08 # ice porosity, in fraction # create an ice column with assumption of spherical brine inclusions (inclusion_shape="spheres"): ice_column = make_ice_column(ice_type="multiyear", thickness=thickness, temperature=temperature, microstructure_model="exponential", brine_inclusion_shape="spheres", salinity=salinity, porosity=porosity, corr_length=p_ex, add_water_substrate="ocean") # create the sensor sensor = sensor_list.passive(1.4e9, 40.) n_max_stream = 128 m = make_model("iba", "dort", rtsolver_options={"n_max_stream": n_max_stream}) # run the model res = m.run(sensor, ice_column) print(res.TbV(), res.TbH()) # absorption with effective permittivity assert abs(res.TbV() - 257.5689162188296) < 1e-4 assert abs(res.TbH() - 232.03924683304172) < 1e-4
def test_oneconfig_for_firstyear_sea_ice(): # prepare inputs l, n_max_stream, thickness, temperature, salinity = setup_seaice() p_ex = np.array([500e-6] * l) # correlation length # create an ice column with assumption of spherical brine inclusions (brine_inclusion_shape="spheres"): ice_column = make_ice_column( ice_type="firstyear", thickness=thickness, temperature=temperature, microstructure_model="exponential", brine_inclusion_shape= "spheres", #inclusion_shape can be "spheres" or "random_needles", or "mix_spheres_needles" salinity= salinity, #either 'salinity' or 'brine_volume_fraction' should be given for sea ice; if salinity is given, brine volume fraction is calculated in the model; if none is given, ice is treated as fresh water ice corr_length=p_ex, add_water_substrate="ocean") # create the sensor sensor = sensor_list.passive(1.4e9, 40.) n_max_stream = 128 m = make_model("iba", "dort", rtsolver_options={"n_max_stream": n_max_stream}) # run the model res = m.run(sensor, ice_column) print(res.TbV(), res.TbH()) #absorption with effective permittivity assert abs(res.TbV() - 256.01165061598317) < 1e-4 assert abs(res.TbH() - 228.47447378338745) < 1e-4
def test_reflector_backscattering(): # prepare inputs density = [0.1] temperature = [210.0] thickness = [0.01] theta = np.arange(5, 60, 1) radar = sensor_list.active(1e9, theta) backscattering_coefficient = {'VV': invdB(-10), 'HH': invdB(-15)} # Substrate: same for both sample locations. Permittivity is irrelevant parameter backscatter_reflector = make_reflector( specular_reflection=0, backscattering_coefficient=backscattering_coefficient) snowpack = make_snowpack(thickness, "homogeneous", density=density, temperature=temperature, substrate=backscatter_reflector) # create the EM Model - Equivalent DMRTML m = make_model("nonscattering", "dort", rtsolver_options=dict(m_max=5)) res = m.run(radar, snowpack) print(res.sigmaVV_dB()) print(res.sigmaHH_dB()) assert np.all(np.abs(res.sigmaVV_dB() - (-10)) < 0.01) assert np.all(np.abs(res.sigmaHH_dB() - (-15)) < 0.01)
def test_snowpack_with_coherent_layer(): # this test is only here to avoid regression, it is not scientifically validated density = [300, 917, 400, 500] thickness = [0.10, 0.01, 0.20, 1000] temperature = 270 corr_length = [200e-6, 0, 200e-6, 200e-6] theta = 60 radiometer = sensor_list.passive(5e9, theta) sp = make_snowpack(thickness, "exponential", density=density, temperature=temperature, corr_length=corr_length) # create the EM Model - Equivalent DMRTML m = make_model("iba", "dort", rtsolver_options={'n_max_stream': 64, 'process_coherent_layers': True}) res = m.run(radiometer, sp) print(res.TbV(), res.TbH()) assert abs(res.TbV() - 261.1994214138529) < 1e-4 assert abs(res.TbH() - 201.1848483718344) < 1e-4
def GetTb(Tz, H, NbLayers, Freq, Angle, NbStreams, Perm, Model, Tbatmo): l = NbLayers # number of layers nbinputlayers = np.size(Tz) temperature = np.transpose(Tz) + 273.15 thickness = np.array([H / l] * l) depthini = np.linspace(0, H, nbinputlayers) depthfin = np.linspace(0, H, l) temp = np.interp(depthfin, depthini, temperature[::-1])[::-1] density = np.zeros(l) radius = 1e-4 medium = list() soilp = dmrtml.HUTRoughSoilParams(273) for d in depthfin: i = np.where(depthfin == d)[0] density[i] = 921.9 - 595.3 * math.exp(-0.01859 * d) if density[i] < 458.5: medium.append('S') elif density[i] < 458.5 and density[i] <= 900.: medium.append('F') else: medium.append('I') # Compute the permittivity for the whole profile e_ice = Permittivity(Perm, temp, density, Freq) if Model == "DMRT-ML": res = dmrtml.dmrtml_bis(Freq, NbStreams, thickness, density, radius, temp, medium=medium, soilp=soilp, tbatmodown=Tbatmo, eps_ice=(e_ice[0, :], e_ice[1, :])) print(temp) return res.TbV(Angle) if Model == "SMRT": if Perm == "Tiuri": ice_permittivity_model = ice_permittivity_tiuri84 if Perm == "Matzler": ice_permittivity_model = ice_permittivity_matzler87 # create the snowpack snowpack = make_snowpack(thickness=thickness, microstructure_model="sticky_hard_spheres", density=density, temperature=temp, radius=radius, ice_permittivity_model=ice_permittivity_model) # create the snowpack m = make_model("dmrt_qcacp_shortrange", "dort") radiometer = sensor.passive(Freq, Angle) res = m.run(radiometer, snowpack) return res.TbV()
def test_less_refringent_bottom_layer_VV(): # Regression test 19-03-2018: value may change if other bugs found snowpack = make_snowpack([0.2, 0.3], "sticky_hard_spheres", density = [290.0, 250.0], radius = 50e-6, stickiness=0.2, substrate=make_soil("transparent", 1, 270)) m = make_model("dmrt_qcacp_shortrange", "dort") scat = active(10e9, 45) res = m.run(scat, snowpack) print(res.sigmaVV()) assert abs(res.sigmaVV() - 9.42202173e-06) < 1e-9
def GetTb_SMRT(Tz, H, NbLayers, Freq, Angle, Perm): l = NbLayers # number of layers nbinputlayers = np.size(Tz) thickness = np.array([H / l] * l) #Prepare temperature field and interpolate on the layer altitude temperature = np.transpose(Tz) + 273.15 zini = np.linspace(0, H, nbinputlayers) zfin = np.linspace(0, H, l) temp = np.interp(zfin, zini, temperature[::-1])[::-1] #print(temperature, temp) #plt.plot(temperature, zini[::-1]) #plt.plot(temp, zfin[::-1]) #plt.show() density = np.zeros(l) p_ex = np.zeros(l) i = 0 for z in zfin: density[i] = 1000. * (0.916 - 0.593 * math.exp(-0.01859 * z) ) #From Macelloni et al, 2016 #p_ex[i] = 1 - 0.9999 * math.exp(-0.01859 * z / 1e4) i = i + 1 p_ex = 1. / (917 - density + 100) #100) p_ex[0] = 1e-4 if Perm == "Tiuri": ice_permittivity_model = ice_permittivity_tiuri84 if Perm == "Matzler": ice_permittivity_model = ice_permittivity_matzler87 # create the snowpack snowpack = make_snowpack( thickness=thickness, microstructure_model="exponential", #sticky_hard_spheres", density=density, temperature=temp, #radius=p_ex, corr_length=p_ex) #stickiness = 0.1) # ice_permittivity_model=ice_permittivity_model) # create the snowpack m = make_model("iba", "dort") #m = make_model("dmrt_qcacp_shortrange", "dort") # create the sensor radiometer = sensor.passive(Freq, Angle) # run the model res = m.run(radiometer, snowpack) # outputs return res.TbV()
def run_model(snowpack): # create the EM Model m = make_model("dmrt_qcacp_shortrange", "dort") # create the sensor radiometer = sensor.passive(37e9, 40) # test at 40° to avoid the Brewster angle # run the model res = m.run(radiometer, snowpack) return res
def test_dmrt_with_soil(): # prepare inputs density = [300, 300] temperature = [245, 245] thickness = [0.1, 0.1] radius = [200e-6, 400e-6] stickiness = [1000, 1000] soiltemperature = 270 clay = 0.3 sand = 0.4 drymatter = 1100 moisture = 0.2 roughness_rms = 1e-2 substrate = make_soil("soil_wegmuller", "dobson85", soiltemperature, moisture=moisture, roughness_rms=roughness_rms, clay=clay, sand=sand, drymatter=drymatter) snowpack = make_snowpack(thickness, "sticky_hard_spheres", density=density, temperature=temperature, radius=radius, stickiness=stickiness, substrate=substrate) # create the EM Model m = make_model("dmrt_qcacp_shortrange", "dort") # create the sensor radiometer = sensor.passive(37e9, 40) # test at 40° to avoid the Brewster angle # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) #assert (res.TbV() - 262.6214674671272) < 1e-4 assert (res.TbV() - 262.62154074526325) < 1e-4 #assert (res.TbH() - 255.88791903746) < 1e-4 assert (res.TbH() - 255.88831382514428) < 1e-4
def test_dmrt_oneconfig(): snowpack = setup_snowpack() # create the EM Model m = make_model("dmrt_qcacp_shortrange", "dort") # create the sensor radiometer = amsre("37V") # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) assert (res.TbV() - 202.1726891947754) < 1e-4 assert (res.TbH() - 187.45835882462404) < 1e-4
def test_geometrical_optics(): # prepare inputs snowpack = setup_snowpack(l=2) # create the snowpack m = make_model("iba", "dort") # create the sensor radar = sensor_list.active(13e9, 55) # run the model res = m.run(radar, snowpack) print(res.sigmaVV_dB(), res.sigmaHH_dB()) assert abs(res.sigmaVV_dB() - -27.35490756934666) < 1e-4 assert abs(res.sigmaHH_dB() - -27.727715758558222) < 1e-4
def test_geometrical_optics(): # prepare inputs snowpack = setup_snowpack(l=2) # create the snowpack m = make_model("iba", "dort") # create the sensor radar = sensor_list.active(13e9, 55) # run the model res = m.run(radar, snowpack) print(res.sigmaVV_dB(), res.sigmaHH_dB()) assert abs(res.sigmaVV_dB() - -29.098930693890576) < 1e-4 assert abs(res.sigmaHH_dB() - -28.974976041582334) < 1e-4
def test_iba_oneconfig_active(): # prepare inputs snowpack = setup_snowpack(l=2) # create the snowpack m = make_model("iba", "dort") # create the sensor radar = sensor_list.active(frequency=19e9, theta_inc=55) # run the model res = m.run(radar, snowpack) print(res.sigmaVV_dB(), res.sigmaHH_dB(), res.sigmaHV_dB()) abs(res.sigmaVV_dB() - (-24.04497237)) < 1e-4 abs(res.sigmaHH_dB() - (-24.41628343)) < 1e-4 abs(res.sigmaHV_dB() - (-51.53673914)) < 1e-4
def _do_test_kirchoff_law(pc, thickness_1): T = 265 substrate = make_soil('soil_wegmuller', permittivity_model=complex(10, 1), roughness_rms=0.001, temperature=T) snowpack = make_snowpack([0.3, thickness_1], "exponential", density=[200, 300], temperature=T, corr_length=pc, substrate=substrate) atmosphere1K = SimpleIsotropicAtmosphere(tbdown=1, tbup=0, trans=1) # create the sensor theta = range(10, 80, 5) radiometer = sensor_list.passive(37e9, theta) # create the EM Model m = make_model("iba", "dort") # run the model sresult_0 = m.run(radiometer, snowpack) sresult_1 = m.run(radiometer, snowpack, atmosphere1K) # V-pol emissivity_V = (sresult_0.TbV() + sresult_1.TbV()) / 2 / T reflectivity_V = (sresult_1.TbV() - sresult_0.TbV()) print(emissivity_V, 1 - reflectivity_V) np.testing.assert_allclose(emissivity_V, 1 - reflectivity_V, atol=0.002) # H-pol emissivity_H = (sresult_0.TbH() + sresult_1.TbH()) / 2 / T reflectivity_H = (sresult_1.TbH() - sresult_0.TbH()) print(emissivity_H, 1 - reflectivity_H) np.testing.assert_allclose(emissivity_H, 1 - reflectivity_H, atol=0.002)
def test_mixed_emmodel(): # prepare inputs l = 2 nl = l // 2 # // Forces integer division thickness = np.array([0.1, 0.1] * nl) thickness[-1] = 100 # last one is semi-infinit radius = np.array([2e-4] * l) temperature = np.array([250.0, 250.0] * nl) density = [200, 400] * nl stickiness = [0.1, 0.1] * nl emmodel = ["dmrt_qcacp_shortrange", "iba"] * nl # create the snowpack snowpack = make_snowpack(thickness, "sticky_hard_spheres", density=density, temperature=temperature, radius=radius, stickiness=stickiness) # create the EM Model m = make_model(emmodel, "dort") # create the sensor radiometer = sensor_list.amsre('37V') # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) #assert (res.TbV() - 203.84730126016882) < 1e-4 #assert (res.TbH() - 189.53130277932084) < 1e-4 #assert (res.TbV() - 203.8473395866384) < 1e-4 #assert (res.TbH() - 189.53346053779396) < 1e-4 #assert (res.TbV() - 204.6641326749464) < 1e-4 #assert (res.TbH() - 190.42438454209372) < 1e-4 assert (res.TbV() - 204.61156255625286) < 1e-4 assert (res.TbH() - 190.5085529486018) < 1e-4
def test_iba_oneconfig_passive(): # prepare inputs snowpack = setup_snowpack(l=2) # create the snowpack m = make_model("iba", "dort") # create the sensor radiometer = sensor_list.amsre('37V') # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) #absorption with effective permittivity # abs(res.TbV() - 248.08794944809972) < 1e-4 # abs(res.TbH() - 237.3056263719142) < 1e-4 assert abs(res.TbV() - 248.08744066791073) < 1e-4 assert abs(res.TbH() - 237.30720491883298) < 1e-4
def test_dmrt_twoconfig(): snowpack = setup_snowpack() # create the EM Model m = make_model("dmrt_qcacp_shortrange", "dort") # create the sensor radiometer = amsre(["19", "37"]) print(radiometer.configurations) # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) assert (res.Tb(channel="37V") - 202.1726891947754) < 1e-4 assert (res.Tb(channel="37H") - 187.45835882462404) < 1e-4 assert (res.Tb(channel="19V") - 242.550043) < 1e-4 assert (res.Tb(channel="19H") - 230.118448) < 1e-4
def test_snowpack_with_coherent_layer(): # this test is only here to avoid regression, it is not scientifically validated density = [300, 916.7, 400, 500] thickness = [0.10, 0.01, 0.20, 1000] temperature = 270 corr_length = [200e-6, 0, 200e-6, 200e-6] theta = 60 radiometer = sensor_list.passive(5e9, theta) sp = make_snowpack(thickness, "exponential", density=density, temperature=temperature, corr_length=corr_length) # create the EM Model - Equivalent DMRTML m = make_model("iba", "dort", rtsolver_options={ 'n_max_stream': 64, 'process_coherent_layers': True }) res = m.run(radiometer, sp) print(res.TbV(), res.TbH()) #assert abs(res.TbV() - 261.1994214138529) < 1e-4 #assert abs(res.TbH() - 201.1848483718344) < 1e-4 # the new values may come from the correction of the bug in dort which limited # the streams to the non-total reflection ones. This is not all clear yet... #assert abs(res.TbV() - 261.05630770071855) < 1e-4 #assert abs(res.TbH() - 196.83495992559307) < 1e-4 # the new values come form the correction of 917->916.7 assert abs(res.TbV() - 261.06421847662216) < 1e-4 assert abs(res.TbH() - 196.8660443556061) < 1e-4
def test_iba_oneconfig_active(): # prepare inputs snowpack = setup_snowpack(l=2) # create the snowpack m = make_model("iba", "dort") # create the sensor radar = sensor_list.active(frequency=19e9, theta_inc=55) # run the model res = m.run(radar, snowpack) print(res.sigmaVV_dB(), res.sigmaHH_dB(), res.sigmaHV_dB()) #assert abs(res.sigmaVV_dB() - (-24.04497237)) < 1e-4 #assert abs(res.sigmaHH_dB() - (-24.41628343)) < 1e-4 #assert abs(res.sigmaHV_dB() - (-51.53673914)) < 1e-4 assert abs(res.sigmaVV_dB() - (-25.784531777404144)) < 1e-4 assert abs(res.sigmaHH_dB() - (-25.661186004429812)) < 1e-4 assert abs(res.sigmaHV_dB() - (-32.33796852861883)) < 1e-4
def test_iba_oneconfig(): # prepare inputs l = 2 n_max_stream = 64 nl = l // 2 # // Forces integer division thickness = np.array([0.1, 0.1] * nl) thickness[-1] = 100 # last one is semi-infinit p_ex = np.array([5e-5] * l) temperature = np.array([250.0, 250.0] * nl) density = [200, 400] * nl # create the snowpack snowpack = make_snowpack(thickness=thickness, microstructure_model="exponential", density=density, temperature=temperature, corr_length=p_ex) # create the snowpack m = make_model("iba", "dort") # create the sensor radiometer = sensor_list.amsre('37V') # run the model res = m.run(radiometer, snowpack) print(res.TbV(), res.TbH()) #absorption with effective permittivity #ok_(abs(res.TbV() - 248.08807673119517) < 1e-4) #ok_(abs(res.TbH() - 237.3106696695165) < 1e-4) #original absorption (Maetzler 1998) ok_(abs(res.TbV() - 247.92402825320272) < 1e-4) ok_(abs(res.TbH() - 237.08967658310334) < 1e-4)
# prepare inputs l = 2 n_max_stream = 64 nl = l // 2 # // Forces integer division thickness = np.array([0.1, 0.1] * nl) thickness[-1] = 100 # last one is semi-infinit p_ex = np.array([5e-5] * l) temperature = np.array([250.0, 250.0] * nl) density = [200, 400] * nl # create the snowpack snowpack = make_snowpack(thickness=thickness, microstructure_model="exponential", density=density, temperature=temperature, corr_length=p_ex) # create the snowpack m = make_model("iba", "dort") # create the sensor sensor = sensor_list.amsre('37V') # run the model res = m.run(sensor, snowpack) # outputs print(res.TbV())
def run_model( snow_depth, ice_thickness, ice_salinity, ice_density, temp, snow_CL_e3, ice_CL_e3, snow_density, snow_sal, snow_roughness_rms, snow_roughness_CL, ice_roughness_rms, ice_roughness_CL, angles=np.arange(0, 51, 5), ): """Runs SMRT from geophysical variables and returns a dictionary of results""" K_u = 13.575e9 K_a = 35e9 freqs = {K_u: 'Ku', K_a: 'Ka'} snow_air_interface = IEM_Fung92_Briogoni10( roughness_rms=snow_roughness_rms * 1e-3, corr_length=snow_roughness_CL * 1e-3) snow_ice_interface = IEM_Fung92_Briogoni10( roughness_rms=ice_roughness_rms * 1e-3, corr_length=ice_roughness_CL * 1e-3) ice_column = make_ice_column( ice_type='multiyear', thickness=[ice_thickness], temperature=temp, brine_inclusion_shape='needles', corr_length=ice_CL_e3 / 1000, density=ice_density, salinity=ice_salinity * PSU, microstructure_model='exponential', add_water_substrate='ocean', ice_permittivity_model=saline_ice_permittivity_pvs_mixing, interface=snow_ice_interface, ) snowpack = make_snowpack( thickness=[snow_depth], microstructure_model="exponential", density=snow_density, temperature=temp, corr_length=snow_CL_e3 / 1000, salinity=snow_sal, # ice_permittivity_model = saline_snow_permittivity_geldsetzer09, interface=snow_air_interface, ) medium = snowpack + ice_column sensor = smrt.sensor.active([K_u, K_a], angles, polarization_inc=['H'], polarization=['V', 'H']) m = make_model("iba", "dort") res = m.run(sensor, medium) results = {} for pol_inc, pol, freq in itertools.product(['H'], ['V', 'H'], [K_a, K_u]): # Turn SMRT results object into a sliced dataframe s_res = res.sigma_dB_as_dataframe(polarization_inc=pol_inc, polarization=pol, frequency=freq) # Process slice into dictionary results[f'{freqs[freq]}_{pol_inc}{pol}'] = np.array(s_res['sigma']) return (results)
l_s = 2 #2 snow layers thickness_s = np.array([0.05, 0.2]) p_ex_s = np.array([5e-5] * l_s) temperature_s = np.linspace(273.15 - 25., 273.15 - 20, l_s) density_s = [200, 340] # create the snowpack snowpack = make_snowpack(thickness=thickness_s, microstructure_model="exponential", density=density_s, temperature=temperature_s, corr_length=p_ex_s) #add snowpack on top of ice column: medium = snowpack + ice_column # create the sensor sensor = sensor_list.passive(1.4e9, 40.) n_max_stream = 128 #TB calculation is more accurate if number of streams is increased (currently: default = 32); #needs to be increased when using > 1 snow layer on top of sea ice! m = make_model("iba", "dort", rtsolver_options={"n_max_stream": n_max_stream}) # run the model for bare sea ice: res1 = m.run(sensor, ice_column) # run the model for snow-covered sea ice: res2 = m.run(sensor, medium) # print TBs at horizontal and vertical polarization: print(res1.TbH(), res1.TbV()) print(res2.TbH(), res2.TbV())