def test_iem_fung92_brogioni10(): eps_r = 3 + 0.1j iem_fung = IEM_Fung92_Briogoni10(roughness_rms=0.429e-2, corr_length=30e-2) frequency = 2.2e9 mu = np.cos(np.deg2rad([30, 50, 60])) R = iem_fung.diffuse_reflection_matrix(frequency, 1, eps_r, mu, mu, np.pi, 2, debug=True) sigma_vv = dB(4 * np.pi * mu * R[0]) sigma_hh = dB(4 * np.pi * mu * R[1]) print(sigma_vv) print(sigma_hh) assert np.all( np.abs(sigma_vv - [-25.8475821, -28.09794986, -27.1320767]) < 1e-2) assert np.all( np.abs(sigma_hh - [-31.30415086, -40.67474292, -29.06341978]) < 1e-2)
def test_iem_fung92(): eps_r = 3 + 0.1j iem_fung = IEM_Fung92(roughness_rms=0.429e-2, corr_length=3e-2) frequency = 2.2e9 mu = np.cos(np.deg2rad([30, 50, 60])) R = iem_fung.diffuse_reflection_matrix(frequency, 1, eps_r, mu, mu, np.pi, 2, debug=True) sigma_vv = dB(4*np.pi * mu * R[0]) sigma_hh = dB(4*np.pi * mu * R[1]) print(sigma_vv) print(sigma_hh) assert np.all(np.abs(sigma_vv - [-20.25297061, -24.35232625, -26.74346526]) < 1e-2) assert np.all(np.abs(sigma_hh - [-22.10327899, -28.69367149, -32.53013663]) < 1e-2)
def sel_data(self, channel=None, return_backscatter=False, **kwargs): # this function allows selection as xarray.DataArray.sel and in addition by channel if a channel_map is defined. # ffilter the variables of channel_map[channel] that are effectively in self.data.dims # and apply them to the selector sel in addition to kwargs if channel is not None: kwargs.update({ k: v for k, v in self.channel_map[channel].items() if k in self.data.dims }) if return_backscatter: # get theta theta = kwargs.pop('theta', None) theta_inc = kwargs.pop('theta_inc', None) if theta is not None and theta_inc is not None: if not np.all(theta_inc == theta): raise SMRTError( 'theta and theta_inc must be the same when returning backscatter' ) if theta is None: theta = theta_inc if theta is None: theta = self.data.theta_inc def select_theta(x, theta, **kwargs): # select by theta and deal with cases where theta is in the coords or not if 'theta' in x.coords: return x.sel(theta=theta, theta_inc=theta, **kwargs) else: return x.sel(theta_inc=theta, **kwargs) if lib.is_sequence(theta): # now select all the theta if it is a sequence x = xr.concat([ select_theta(self.data, t, drop=True, **kwargs) for t in theta ], pd.Index(theta, 'theta_inc')) else: x = select_theta(self.data, theta, drop=True, **kwargs) else: x = self.data.sel(drop=True, **kwargs) if return_backscatter: x = (4 * np.pi * np.cos(np.deg2rad(theta))) * x return dB(x) if return_backscatter == "dB" else x else: return x
def test_iem_fung92_biogoni10_continuty(): eps_r = 3 + 0.1j iem_fung = IEM_Fung92(roughness_rms=0.429e-2, corr_length=3e-2) iem_fung_brogioni = IEM_Fung92_Briogoni10(roughness_rms=0.429e-2, corr_length=3e-2) frequency = 2.2e9 mu = np.cos(np.deg2rad([30, 50, 60])) R = iem_fung.diffuse_reflection_matrix(frequency, 1, eps_r, mu, mu, np.pi, 2, debug=True) R2 = iem_fung_brogioni.diffuse_reflection_matrix(frequency, 1, eps_r, mu, mu, np.pi, 2, debug=True) sigma_vv = dB(4 * np.pi * mu * R[0]) sigma_hh = dB(4 * np.pi * mu * R[1]) sigma_vv2 = dB(4 * np.pi * mu * R2[0]) sigma_hh2 = dB(4 * np.pi * mu * R2[1]) assert np.allclose(sigma_vv, sigma_vv2) assert np.allclose(sigma_hh, sigma_hh2)
def sigmaVH_dB(self, **kwargs): """Return VH backscattering coefficient in dB. Any parameter can be added to slice the results (e.g. frequency=37e9). See xarray slicing with sel method (to document)""" return dB(self.sigmaVH(**kwargs))
def sigma_dB(self, **kwargs): """Return backscattering coefficient. Any parameter can be added to slice the results (e.g. frequency=37e9, polarization_inc='V', polarization='V'). See xarray slicing with sel method (to document)""" return dB(self.sigma(**kwargs))