def __init__(self, frequency, interfaces, substrate, permittivity, streams, m_max, npol): self.streams = streams nlayer = len(interfaces) self.Rtop_coh = dict() self.Ttop_coh = dict() self.Rbottom_coh = dict() self.Rbottom_diff = dict() self.Tbottom_coh = dict() self.full_weight = dict() for l in range(nlayer): eps_lm1 = permittivity[l-1] if l > 0 else 1 eps_l = permittivity[l] if l < nlayer - 1: eps_lp1 = permittivity[l+1] nsl = streams.n[l] # number of streams in layer l nslm1 = streams.n[l-1] if l > 0 else streams.n_air # number of streams * npol in the layer l-1 (lm1) nslp1 = streams.n[l+1] if l < nlayer-1 else streams.n_substrate # number of streams * npol in the layer l+1 (lp1) # compute reflection coefficient between l and l-1 UP self.Rtop_coh[l] = interfaces[l].specular_reflection_matrix(frequency, eps_l, eps_lm1, streams.mu[l], npol) # snow-snow UP # compute transmission coefficient between l and l-1 UP ns_common_top = min(nsl, nslm1) self.Ttop_coh[l] = interfaces[l].coherent_transmission_matrix(frequency, eps_l, eps_lm1, streams.mu[l][0:ns_common_top], npol) # snow-snow or air UP # compute transmission coefficient between l and l+1 DOWN if l < nlayer - 1: ns_common_bottom = min(nsl, nslp1) self.Tbottom_coh[l] = interfaces[l].coherent_transmission_matrix(frequency, eps_l, eps_lp1, streams.mu[l][0:ns_common_bottom], npol) # snow-snow DOWN elif substrate is not None: self.Tbottom_coh[nlayer -1] = substrate.emissivity_matrix(frequency, eps_l, streams.mu[l], npol) # sub-snow # compute reflection coefficient between l and l+1 DOWN if l < nlayer - 1: self.Rbottom_coh[l] = interfaces[l].specular_reflection_matrix(frequency, eps_l, eps_lp1, streams.mu[l], npol) # snow-snow DOWN self.Rbottom_diff[l] = 0 elif substrate is not None: self.Rbottom_coh[l] = substrate.specular_reflection_matrix(frequency, eps_l, streams.mu[l], npol) # snow-substrate if hasattr(substrate, "ft_even_diffuse_reflection_matrix"): self.Rbottom_diff[l] = substrate.ft_even_diffuse_reflection_matrix(frequency, eps_l, streams.mu[l], streams.mu[l], m_max, npol) # snow-sub else: self.Rbottom_diff[l] = smrt_matrix(0) else: self.Rbottom_coh[l] = smrt_matrix(0) # fully absorbant substrate self.Rbottom_diff[l] = 0 #self.full_weight[l] = np.repeat(streams.weight[l], npol) self.Tbottom_coh[-1] = interfaces[0].coherent_transmission_matrix(frequency, 1, permittivity[0], streams.outmu, npol) # air-snow DOWN self.Rbottom_coh[-1] = interfaces[0].specular_reflection_matrix(frequency, 1, permittivity[0], streams.outmu, npol) # air-snow DOWN self.Rbottom_diff[-1] = 0
def ft_even_diffuse_reflection_matrix(self, frequency, eps_1, mu_s, mu_i, m_max, npol): assert mu_s is mu_i if isinstance(self.backscattering_coefficient, dict): # we have a dictionary with polarization diffuse_refl_coeff = smrt_matrix.zeros( (npol, m_max + 1, len(mu_i))) for m in range(m_max + 1): if m == 0: coef = 0.5 elif (m % 2) == 1: coef = -1.0 else: coef = 1.0 coef /= 4 * np.pi * mu_i # SMRT requires scattering coefficient / 4 * pi coef /= m_max + 0.5 # ad hoc normalization to get the right backscatter. This is a trick to deal with the dirac. diffuse_refl_coeff[0, m, :] += coef * self._get_refl( self.backscattering_coefficient['VV'], mu_i) diffuse_refl_coeff[1, m, :] += coef * self._get_refl( self.backscattering_coefficient['HH'], mu_i) elif self.backscattering_coefficient is not None: raise SMRTError( "backscattering_coefficient must be a dictionary with keys VV and HH" ) else: return smrt_matrix(0) return diffuse_refl_coeff
def specular_reflection_matrix(self, frequency, eps_1, eps_2, mu1, npol): """compute the reflection coefficients for an array of incidence angles (given by their cosine) in medium 1. Medium 2 is where the beam is transmitted. :param eps_1: permittivity of the medium where the incident beam is propagating. :param eps_2: permittivity of the other medium :param mu1: array of cosine of incident angles :param npol: number of polarization :return: the reflection matrix """ return smrt_matrix(0)
def __init__(self, ke, ks, ft_even_phase_function, mu, weight, m_max, normalization): # :param Ke: extinction coefficient of the layer for mode m # :param ft_even_phase: ft_even_phase function of the layer for mode m # :param mu: cosines # :param weight: weights self.ke = ke self.ks = ks self.mu = mu self.weight = weight self.normalization = normalization self.norm_0 = None self.norm_m = None if ft_even_phase_function is not None: mu = np.concatenate((self.mu, -self.mu)) self.ft_even_phase = ft_even_phase_function(mu, mu, m_max) else: self.ft_even_phase = smrt_matrix(0)
def diffuse_reflection_matrix(self, frequency, eps_1, eps_2, mu_s, mu_i, dphi, npol): return smrt_matrix(0)
def diffuse_transmission_matrix(self, frequency, eps_1, eps_2, mu_s, mu_i, dphi, npol): return smrt_matrix(0)
def coherent_transmission_matrix(self, frequency, eps_1, eps_2, mu1, npol): return smrt_matrix(0)
def specular_reflection_matrix(self, frequency, eps_1, eps_2, mu1, npol): return smrt_matrix(0)
def __init__(self, frequency, interfaces, substrate, permittivity, streams, m_max, npol): self.streams = streams nlayer = len(interfaces) self.Rtop_coh = dict() self.Rtop_diff = dict() self.Ttop_coh = dict() self.Ttop_diff = dict() self.Rbottom_coh = dict() self.Rbottom_diff = dict() self.Tbottom_coh = dict() self.Tbottom_diff = dict() self.full_weight = dict() for l in range(nlayer): eps_lm1 = permittivity[l - 1] if l > 0 else 1 eps_l = permittivity[l] if l < nlayer - 1: eps_lp1 = permittivity[l + 1] else: eps_lp1 = None nsl = streams.n[l] # number of streams in layer l nslm1 = streams.n[l - 1] if l > 0 else streams.n_air # number of streams * npol in the layer l - 1 (lm1) nslp1 = streams.n[l + 1] if l < nlayer - 1 else streams.n_substrate # number of streams * npol in the layer l + 1 (lp1) # compute reflection coefficient between layer l and l - 1 UP # snow-snow UP self.Rtop_coh[l] = interfaces[l].specular_reflection_matrix(frequency, eps_l, eps_lm1, streams.mu[l], npol) self.Rtop_diff[l] = interfaces[l].ft_even_diffuse_reflection_matrix(frequency, eps_l, eps_lm1, streams.mu[l], streams.mu[l], m_max, npol) \ if hasattr(interfaces[l], "ft_even_diffuse_reflection_matrix") else smrt_matrix(0) self.Rtop_diff[l] = normalize_diffuse_matrix(self.Rtop_diff[l], streams.mu[l], streams.mu[l], streams.weight[l]) # compute transmission coefficient between l and l - 1 UP # snow-snow or air UP self.Ttop_coh[l] = interfaces[l].coherent_transmission_matrix(frequency, eps_l, eps_lm1, streams.mu[l], npol) mu_t = streams.mu[l - 1] if l > 1 else streams.outmu self.Ttop_diff[l] = interfaces[l].ft_even_diffuse_transmission_matrix(frequency, eps_l, eps_lm1, mu_t, streams.mu[l], m_max, npol) * (eps_l.real / eps_lm1.real) \ if hasattr(interfaces[l], "ft_even_diffuse_transmission_matrix") else smrt_matrix(0) self.Ttop_diff[l] = normalize_diffuse_matrix(self.Ttop_diff[l], mu_t, streams.mu[l], streams.weight[l]) # compute transmission coefficient between l and l + 1 DOWN if l < nlayer - 1: # snow-snow DOWN self.Tbottom_coh[l] = interfaces[l + 1].coherent_transmission_matrix(frequency, eps_l, eps_lp1, streams.mu[l], npol) self.Tbottom_diff[l] = interfaces[l + 1].ft_even_diffuse_transmission_matrix(frequency, eps_l, eps_lp1, streams.mu[l + 1], streams.mu[l], m_max, npol) * (eps_l.real / eps_lp1.real) \ if hasattr(interfaces[l + 1], "ft_even_diffuse_transmission_matrix") else smrt_matrix(0) self.Tbottom_diff[l] = normalize_diffuse_matrix(self.Tbottom_diff[l], streams.mu[l + 1], streams.mu[l], streams.weight[l]) elif substrate is not None: # sub-snow self.Tbottom_coh[nlayer - 1] = substrate.emissivity_matrix(frequency, eps_l, streams.mu[l], npol) self.Tbottom_diff[l] = 0 # compute reflection coefficient between l and l + 1 DOWN if l < nlayer - 1: # snow-snow DOWN self.Rbottom_coh[l] = interfaces[l + 1].specular_reflection_matrix(frequency, eps_l, eps_lp1, streams.mu[l], npol) self.Rbottom_diff[l] = interfaces[l + 1].ft_even_diffuse_reflection_matrix(frequency, eps_l, eps_lp1, streams.mu[l], streams.mu[l], m_max, npol) \ if hasattr(interfaces[l + 1], "ft_even_diffuse_reflection_matrix") else smrt_matrix(0) self.Rbottom_diff[l] = normalize_diffuse_matrix(self.Rbottom_diff[l], streams.mu[l], streams.mu[l], streams.weight[l]) elif substrate is not None: # snow-substrate self.Rbottom_coh[l] = substrate.specular_reflection_matrix(frequency, eps_l, streams.mu[l], npol) self.Rbottom_diff[l] = substrate.ft_even_diffuse_reflection_matrix(frequency, eps_l, streams.mu[l], streams.mu[l], m_max, npol) \ if hasattr(substrate, "ft_even_diffuse_reflection_matrix") else smrt_matrix(0) self.Rbottom_diff[l] = normalize_diffuse_matrix(self.Rbottom_diff[l], streams.mu[l], streams.mu[l], streams.weight[l]) else: self.Rbottom_coh[l] = smrt_matrix(0) # fully absorbant substrate self.Rbottom_diff[l] = smrt_matrix(0) # air-snow DOWN self.Tbottom_coh[-1] = interfaces[0].coherent_transmission_matrix(frequency, 1, permittivity[0], streams.outmu, npol) self.Tbottom_diff[-1] = interfaces[0].ft_even_diffuse_transmission_matrix(frequency, 1, permittivity[0], streams.mu[0], streams.outmu, m_max, npol) / permittivity[0].real \ if hasattr(interfaces[0], "ft_even_diffuse_transmission_matrix") else smrt_matrix(0) self.Tbottom_diff[-1] = normalize_diffuse_matrix(self.Tbottom_diff[-1], streams.mu[0], streams.outmu, streams.outweight) # air-snow DOWN self.Rbottom_coh[-1] = interfaces[0].specular_reflection_matrix(frequency, 1, permittivity[0], streams.outmu, npol) self.Rbottom_diff[-1] = interfaces[0].ft_even_diffuse_reflection_matrix(frequency, 1, permittivity[0], streams.outmu, streams.outmu, m_max, npol) \ if hasattr(interfaces[0], "ft_even_diffuse_reflection_matrix") else smrt_matrix(0) self.Rbottom_diff[-1] = normalize_diffuse_matrix(self.Rbottom_diff[-1], streams.outmu, streams.outmu, streams.outweight)