def solve_fun(coef): # stype = 'turbid_rayleigh' stype = 'turbid_isotropic' models = {'surface': 'Oh92', 'canopy': stype} ke = coef * lai_508.values.flatten() # soil = Soil(eps=eps, f=freq, s=s) soil = Soil(mv=sm_508.values.flatten(), f=freq, s=s, clay=0.3, sand=0.4, bulk=1.65) can = OneLayer(ke_h=ke, ke_v=ke, d=d, ks_h=omega * ke, ks_v=omega * ke) S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=theta, freq=freq) S.sigma0() return S.__dict__['stot']['vv'][0]
def solve_fun(VALS): for i in range(len(var_opt)): dic[var_opt[i]] = VALS[i] # ke = dic['coef'] * np.sqrt(dic['lai']) # ke = dic['coef'] * np.sqrt(dic['vwc']) ke = 1 dic['ke'] = ke # surface soil = Soil(mv=dic['mv'], C_hh=dic['C_hh'], C_vv=dic['C_vv'], D_hh=dic['D_hh'], D_vv=dic['D_vv'], C_hv=dic['C_hv'], D_hv=dic['D_hv'], V2=dic['V2'], s=dic['s'], clay=dic['clay'], sand=dic['sand'], f=dic['f'], bulk=dic['bulk'], l=dic['l']) # canopy can = OneLayer(canopy=dic['canopy'], ke_h=dic['ke'], ke_v=dic['ke'], d=dic['d'], ks_h=dic['omega'] * dic['ke'], ks_v=dic['omega'] * dic['ke'], V1=dic['V1'], V2=dic['V2'], A_hh=dic['A_hh'], B_hh=dic['B_hh'], A_vv=dic['A_vv'], B_vv=dic['B_vv'], A_hv=dic['A_hv'], B_hv=dic['B_hv']) S = model.RTModel(surface=soil, canopy=can, models=models, theta=dic['theta'], freq=dic['f']) S.sigma0() return S.__dict__['stot'][pol[::-1]]
def test_scat_isotropic(self): # some dummy variables stype='turbid_isotropic' models = {'surface': 'Oh92', 'canopy': stype} eps = 5. -3.j soil = Soil(eps=eps, f=5., s=0.02) can = OneLayer(ke_h=0.05, ke_v=0.05, d=3., ks_h = 0.02, ks_v = 0.02) S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=self.theta, freq=self.freq) S.sigma0() models = {'surface': 'Dubois95', 'canopy': stype} eps = 5. -3.j S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=self.theta, freq=self.freq) S.sigma0()
def solve_fun_SSRT(coef): # ke = coef * np.sqrt(lai) ke = coef * np.sqrt(vwc) # initialize surface #-------------------- soil = Soil(mv=sm, C_hh=C_hh, C_vv=C_vv, D_hh=D_hh, D_vv=D_vv, C_hv=C_hv, D_hv=D_hv, V2=lai, s=s, clay=clay, sand=sand, f=freq, bulk=bulk) # initialize canopy #------------------- can = OneLayer(canopy=canopy, ke_h=ke, ke_v=ke, d=d, ks_h = omega*ke, ks_v = omega*ke, V1=lai, V2=lai, A_hh=A_hh, B_hh=B_hh, A_vv=A_vv, B_vv=B_vv, A_hv=A_hv, B_hv=B_hv) # run SenSe module #------------------ S = model.RTModel(surface=soil, canopy=can, models=models, theta=theta, freq=freq) S.sigma0() return S.__dict__['stot'][pol2]
#guessed from figure in chapter 4 for the time being eps = 15. - 4.0j models = {'surface': 'Oh92', 'canopy': 'turbid_rayleigh'} pol = 'vv' # short alfalfa d = 0.17 tau = 2.5 ke = tau / d omega = 0.27 ks = omega * ke S = Soil(f=f, s=s, l=l, eps=eps) C = OneLayer(ke_h=ke, ke_v=ke, d=d, ks_v=ks, ks_h=ks, canopy=models['canopy']) RT = RTModel(theta=theta, models=models, surface=S, canopy=C, freq=f) RT.sigma0() fig = plt.figure() ax = fig.add_subplot(111) ax.plot(theta_deg, 10. * np.log10(RT.stot[pol][0]), label='short', color='b') # tall alfalfa d = 0.55 tau = 0.45 ke = tau / d omega = 0.175 ks = omega * ke S = Soil(f=f, s=s, l=l, eps=eps) C = OneLayer(ke_h=ke, ke_v=ke, d=d, ks_v=ks, ks_h=ks, canopy=models['canopy'])
ke = coef * np.sqrt(vwc_field.values.flatten()) # ke = 1.3 # A_vv = np.array(aaa) # B_vv = np.array(bbb) # C_vv = np.array(ccc) # D_vv = np.array(ddd) # pdb.set_trace() # initialize surface #-------------------- soil = Soil(mv=sm_field.values.flatten(), C_hh=C_hh, C_vv=C_vv, D_hh=D_hh, D_vv=D_vv, C_hv=C_hv, D_hv=D_hv, V2=lai_field.values.flatten(), s=s, clay=clay, sand=sand, f=freq, bulk=bulk) # initialize canopy #------------------- can = OneLayer(canopy=canopy, ke_h=ke, ke_v=ke, d=height_field.values.flatten(), ks_h = omega*ke, ks_v = omega*ke, V1=lai_field.values.flatten(), V2=lai_field.values.flatten(), A_hh=A_hh, B_hh=B_hh, A_vv=A_vv, B_vv=B_vv, A_hv=A_hv, B_hv=B_hv) can = OneLayer(canopy=canopy, ke_h=ke, ke_v=ke, d=height_field.values.flatten(), ks_h = omega*ke, ks_v = omega*ke) # run SenSe module #------------------ S = model.RTModel(surface=soil, canopy=can, models=models, theta=theta_field.values.flatten(), freq=freq) S.sigma0() # pdb.set_trace() # Scatterplot #------------ plt.plot(10*np.log10(pol_field.values.flatten()),10*np.log10(S.__dict__['stot'][pol2]), 'ks')
A_vv = 0.01 B_vv = 0.03623961 C_hh = -14.8465 C_vv = -19.99992029 D_hh = 15.907 D_vv = 11.06995661 A_vv = 3.40631410e-03 B_vv = 2.00000000e+00 C_vv = 1.99999999e+01 D_vv = 1.00000000e+01 # soil = Soil(eps=eps, f=freq, s=s) soil = Soil(mv=mv, f=freq, s=s, clay=0.3, sand=0.4) # soil = Soil(mv=mv, C_hh=C_hh, C_vv=C_vv, D_hh=D_hh, D_vv=D_vv, V2=V2, s=s, clay=0.3, sand=0.4, f=freq) can = OneLayer(ke_h=ke, ke_v=ke, d=d, ks_h = omega*ke, ks_v = omega*ke) # can = OneLayer(V1=V1, V2=V2, A_hh=A_hh, B_hh=B_hh, A_vv=A_vv, B_vv=B_vv) S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=theta, freq=freq) # S = model.WaterCloud(surface=soil, canopy=can, models=models, theta=theta, freq=freq) S.sigma0() pdb.set_trace() f = plt.figure() ax = f.add_subplot(111) ax.plot(np.rad2deg(S.__dict__['theta']), 10*np.log10(S.__dict__['s0g']['vv']), color='red', linestyle='-', label='vv s0g') ax.plot(np.rad2deg(S.__dict__['theta']), 10*np.log10(S.__dict__['s0c']['vv']), color='blue', linestyle='-', label='vv s0c') ax.plot(np.rad2deg(S.__dict__['theta']), 10*np.log10(S.__dict__['s0cgt']['vv']), color='green', linestyle='-', label='vv s0cgt') # ax.plot(np.rad2deg(S.__dict__['theta']), 10*np.log10(S.__dict__['stot']['vv']), color='black', linestyle='-', label='vv stot') ax.plot(np.rad2deg(S.__dict__['theta']), 10*np.log10(S.__dict__['s0gcg']['vv']), color='green', linestyle='--', label='vv s0gcg') # ax.plot(np.rad2deg(S.__dict__['theta']), 10*np.log10(S.__dict__['stot']['hh']), color='orange', linestyle='--', label='hh stot')
soil = Soil(surface=surface, mv=sm_field.values.flatten(), C_hh=C_hh, C_vv=C_vv, D_hh=D_hh, D_vv=D_vv, C_hv=C_hv, D_hv=D_hv, V2=lai_field.values.flatten()) can = OneLayer(canopy=canopy, V1=lai_field.values.flatten(), V2=lai_field.values.flatten(), A_hh=A_hh, B_hh=B_hh, A_vv=A_vv, B_vv=B_vv, A_hv=A_hv, B_hv=B_hv) S = model.RTModel(surface=soil, canopy=can, models=models, theta=theta_field.values.flatten(), freq=freq) S.sigma0() #----------------------------------------------------------------- ### Plotting #-----------------------------------------------------------------
def test_scat_rayleigh(self): theta = self.theta*1. #theta = np.array([np.deg2rad(90.)]) stype = 'turbid_rayleigh' models = {'surface': 'Oh92', 'canopy': stype} eps = 15. -3.j d = 2. ke = 0.05 omega=0.5 soil = Soil(eps=eps, f=5., s=0.02) can = OneLayer(ke_h=ke, ke_v=ke, d=d, ks_h = omega*ke, ks_v = omega*ke) S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=theta, freq=self.freq) S.sigma0() models = {'surface': 'Dubois95', 'canopy': stype} S = model.SingleScatRT(surface=soil, canopy=can, models=models, theta=theta, freq=self.freq) S.sigma0() # compare results against results obtained through Eq. 11.23 (analytic way) SMODEL = Dubois95(eps, soil.ks, theta, lam=f2lam(soil.f)) s_hh_surf = SMODEL.hh s_vv_surf = SMODEL.vv trans = np.exp(-d*ke/np.cos(theta)) n=2. # 2== coherent RHO_h = S.G.rho_h RHO_v = S.G.rho_v ref_hh = trans**2. * s_hh_surf + (0.75*omega)*np.cos(theta)*(1.-trans**2.)*(1.+RHO_h**2.*trans**2.)+3.*n*omega*ke*d*RHO_h*trans**2. ref_vv = trans**2. * s_vv_surf + (0.75*omega)*np.cos(theta)*(1.-trans**2.)*(1.+RHO_v**2.*trans**2.)+3.*n*omega*ke*d*RHO_v*trans**2. pol = 'hh' self.assertEqual(len(ref_hh), len(S.stot[pol])) for i in xrange(len(ref_hh)): #print np.rad2deg(theta[i]), ref_hh[i] if np.isnan(ref_hh[i]): self.assertTrue(np.isnan(S.stot[pol][i])) else: # check components first self.assertAlmostEqual(S.s0g[pol][i], s_hh_surf[i]*trans[i]**2.) # attenuated ground self.assertAlmostEqual(S.s0c[pol][i]+S.s0gcg[pol][i], 0.75*omega*np.cos(theta[i])*(1.-trans[i]**2.)*(1.+RHO_h[i]**2.*trans[i]**2.)) # gcg xx=3.*n*omega*ke*d*RHO_h[i]*trans[i]**2. print np.rad2deg(theta[i]), S.s0gcg[pol][i],xx, S.s0gcg[pol][i]/xx self.assertAlmostEqual(S.s0cgt[pol][i],xx) db1=db(ref_hh[i]) db2=db(S.stot[pol][i]) self.assertAlmostEqual(db1,db2) pol = 'vv' self.assertEqual(len(ref_vv), len(S.stot[pol])) for i in xrange(len(ref_vv)): #print theta[i], ref_vv[i] if np.isnan(ref_vv[i]): self.assertTrue(np.isnan(S.stot[pol][i])) else: self.assertAlmostEqual(db(ref_vv[i]), db(S.stot[pol][i]))