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 common_amsr(sensor_name, frequency_dict, channel=None, frequency=None, polarization=None, theta=55, name=None): if frequency is None: # take default values frequency = sorted(set(frequency_dict.values())) else: # recreate the frequency dict frequency_dict = { "%02i" % (freq * 1e9): freq for freq in np.atleast_1d(frequency) } if polarization is None: polarization = ['H', 'V'] # create the channel map channel_map = { freq + pola: dict(frequency=frequency_dict[freq], polarization=pola, theta=theta) for freq in frequency_dict for pola in polarization } if channel is not None: if isinstance(channel, str): channel = [channel] # add H and V to channel's name if not present new_channel = [] for ch in channel: if ch[-1] not in 'HV': new_channel += [ch + 'H', ch + 'V'] else: new_channel += [ch] # take into account 18=19 and 36=37 for ch in new_channel: if '18' in ch: channel_map[ch] = channel_map.pop('19' + ch[-1]) if '36' in ch: channel_map[ch] = channel_map.pop('37' + ch[-1]) try: channel_map = filter_channel_map(channel_map, new_channel) except KeyError: raise SMRTError("%s channel not recognized. Expected one of: %s" % (sensor_name, ", ".join(frequency_dict.keys()))) sensor = passive(channel_map=channel_map, **extract_configuration(channel_map), name=name) return sensor
def test_noabsoprtion(): sp = setup_snowpack() sensor = passive(37e9, theta=[30, 40]) m = Model(NonScattering, DORT) res = m.run(sensor, sp) np.testing.assert_allclose(res.data, sp.layers[0].temperature)
def test_selectby_theta(): sp = setup_snowpack() theta = [30, 40] sensor = passive(37e9, theta) m = Model(NonScattering, DORT) res = m.run(sensor, sp) print(res.data.coords) res.TbV(theta=30)
def test_returned_theta(): sp = setup_snowpack() theta = [30, 40] sensor = passive(37e9, theta) m = Model(NonScattering, DORT) res = m.run(sensor, sp) res_theta = res.coords['theta'] print(res_theta) np.testing.assert_allclose(res_theta, theta)
def smos(theta=None): """ Configuration for MIRAS on SMOS. This function returns a passive sensor at 1.41 GHz (L-band). The incidence angle can be chosen or is by defaut from 0 to 60° 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(0, 61, 5) return passive(1.41e9, theta, name='smos')
def test_noabsoprtion(): temp = 250 sp = make_snowpack([100], None, density=[300], temperature=[temp], interface=[Transparent]) sensor = passive(37e9, theta=[30, 40]) m = Model(NoneScattering, DORT) res = m.run(sensor, sp) np.testing.assert_allclose(res.data, temp)
def test_passive_mode(): se = sensor.passive(35e9, 55, polarization="H") print(se.mode)
def test_duplicate_theta(): sensor.passive([1e9, 35], theta=[55, 55])
def test_passive_wrong_frequency_units_warning(): sensor.passive([1e9, 35], theta=55)
def test_no_theta(): sensor.passive(1e9, theta=None)
def test_duplicate_theta(): with pytest.raises(SMRTError): sensor.passive([1e9, 35], theta=[55, 55])
def test_passive_wrong_frequency_units_warning(): with pytest.raises(SMRTError): sensor.passive([1e9, 35], theta=55)
def test_no_theta(): with pytest.raises(SMRTError): sensor.passive(1e9, theta=None)