def quickscat(channel=None, theta=None, polarization=None): """ Configuration for quickscat sensor. This function can be used to simulate the 4 QUICKSCAT channels i.e. incidence angles 46° and 54° and HH and VV polarizations. Alternatively a subset of these channels can be specified with 4-character identifiers with polarization first .e.g. HH46, VV54 :param channel: single channel identifier :type channel: 4-character string :returns: :py:class:`Sensor` instance """ if channel is None: if theta is None: theta = [46, 54] if polarization is None: polarization = polarization_inc = ['V', 'H'] else: polarization_inc = polarization[1] polarization = polarization[0] else: t, theta, polarization, polarization_inc = decompose_channel( channel, (0, 2, 2)) sensor = active(13.4e9, theta, polarization_inc=polarization_inc, polarization=polarization) return sensor
def smap(mode, theta=40): """Configuration for the passive (mode=P) and active (mode=A) sensor on smap This function returns either a passive sensor at 1.4 GHz (L-band) sensor or an active sensor at 1.26 GHz. The incidence angle is 40°. """ if mode == 'P': return passive( 1.4e9, theta=theta, channel_map={pola: dict(polarization=pola) for pola in 'HV'}, name='smap') elif mode == 'A': return active(1.26e9, theta=theta, theta_inc=theta, channel_map={ channel: dict(polarization=channel[1], polarization_inc=channel[0]) for channel in ['HH', 'VV', 'HV'] }, name='smap') else: raise SMRTError('mode must by A (active) or P (passive')
def ascat(theta=None): """ Configuration for ASCAT on ENVISAT sensor. This function returns a sensor at 5.255 GHz (C-band) and VV polarization. The incidence angle can be chosen or is by defaut from 25° to 65° every 5° :param theta: incidence angle (between 25 and 65° in principle) :type theta: float or sequence :returns: :py:class:`Sensor` instance """ if theta is None: theta = np.arange(25, 70, 5) channel_map = {('VV%i' % t): dict(polarization_inc='V', polarization='V', theta=t, theta_inc=t) for t in np.atleast_1d(theta)} return active(5.255e9, theta, polarization_inc='V', polarization='V', channel_map=channel_map, name='ascat')
def test_iterate(): freqs = [1e9, 2e9, 3e9] s = sensor.active(freqs, 55) freqs_bis = [sub_s.frequency for sub_s in s.iterate("frequency")] np.testing.assert_equal(freqs, freqs_bis)
def test_shallow_snowpack(): warnings.filterwarnings('error', message=".*optically shallow.*", module=".*dort") with pytest.raises(UserWarning) as e_info: sp = make_snowpack([0.5, 0.5], "homogeneous", density=[300, 250], temperature=2 * [250], interface=2 * [Transparent]) sensor = active(13e9, 45) m = Model(NonScattering, DORT) m.run(sensor, sp).sigmaVV()
def sentinel1(theta=None): """ Configuration for C-SAR on Sentinel 1. This function return a sensor at 5.405 GHz (C-band). The incidence angle can be chosen or is by defaut from 20 to 46° by step of 5° :param theta: incidence angle :type theta: float or sequence :returns: :py:class:`Sensor` instance """ if theta is None: theta = np.arange(20, 46, 5) return active(5.405e9, theta)
def ascat(theta=None): """ Configuration for ASCAT on ENVISAT sensor. This function return a sensor at 5.255 GHz (C-band) and VV polarization. The incidence angle can be chosen or is by defaut from 25° to 65° every 5° :param theta: incidence angle (between 25 and 65° in principle) :type theta: float or sequence :returns: :py:class:`Sensor` instance """ if theta is None: theta = np.arange(25, 70, 5) return active(5.255e9, theta, polarization_inc='V', polarization='V')
def quikscat(channel=None, theta=None): """ Configuration for quikscat sensor. This function can be used to simulate the 4 QUIKSCAT channels i.e. incidence angles 46° and 54° and HH and VV polarizations. Alternatively a subset of these channels can be specified with 4-character identifiers with polarization first .e.g. HH46, VV54 :param channel: single channel identifier :type channel: 4-character string :returns: :py:class:`Sensor` instance """ channel_map = { 'HH46': dict(polarization='H', polarization_inc='H', theta=46, theta_inc=46), 'VV54': dict(polarization='V', polarization_inc='V', theta=54, theta_inc=54) } if channel is None: if theta is None: theta = [46, 54] theta = np.atleast_1d(theta) channel = [] if 46 in theta: channel.append('HH46') if 54 in theta: channel.append('VV54') channel_map = filter_channel_map(channel_map, channel) if theta is None: theta = list({channel_map[ch]['theta'] for ch in channel_map}) sensor = active(13.4e9, theta, polarization_inc=['V', 'H'], polarization=['V', 'H'], channel_map=channel_map, name='quikscat') return sensor
def sentinel1(theta=None): """ Configuration for C-SAR on Sentinel 1. This function return a sensor at 5.405 GHz (C-band). The incidence angle can be chosen or is by defaut from 20 to 45° by step of 5° :param theta: incidence angle :type theta: float or sequence :returns: :py:class:`Sensor` instance """ if theta is None: theta = np.arange(20, 46, 5) return active(5.405e9, theta, channel_map={ channel: dict(polarization=channel[1], polarization_inc=channel[0]) for channel in ['HH', 'VV', 'HV', 'VH'] }, name='sentinel1')
def setup_func_active(testpack=None): if testpack is None: testpack = setup_func_sp() scatt = active(frequency=10e9, theta_inc=50) emmodel = IBA(scatt, testpack) return emmodel
def test_active_wrong_frequency_units_warning(): with pytest.raises(SMRTError): sensor.active([1e9, 35], 55)
def test_active_wrong_frequency_units_warning(): sensor.active([1e9, 35], 55)
def test_duplicate_theta_active(): sensor.active([1e9, 35], [55, 55])
def test_sensor_list(): s = sensor.SensorList([ sensor.active(f, 55, channel="%i" % (f / 1e9)) for f in [1e9, 2e9, 3e9] ]) assert len(list(s.iterate())) == 3
def test_2layer_pack(): # Will throw error if doesn't run sp = setup_2layer_snowpack() sensor = active(13e9, 45) m = Model(NonScattering, DORT) m.run(sensor, sp).sigmaVV()
def test_depth_hoar_stream_numbers(): # Will throw error if doesn't run sp = setup_snowpack_with_DH() sensor = active(13e9, 45) m = Model(NonScattering, DORT) m.run(sensor, sp).sigmaVV()
def test_active_mode(): se = sensor.active(35e9, 55) assert se.mode == 'A'
def test_duplicate_theta_active(): with pytest.raises(SMRTError): sensor.active([1e9, 35], [55, 55])