[docs]classNoiseLevel(ScalarDimension,Serializable):"""Base class for all noise level configuration classes."""@property@abstractmethoddeflevel(self)->float:"""Scalar level of the represented noise. Raises: ValueError: If the noise level is negative. """...# pragma: no cover@level.setter@abstractmethoddeflevel(self,value:float)->None:...# pragma: no cover
[docs]@abstractmethoddefget_power(self)->float:"""Power of the noise level. Returns: Power in Watt. """...# pragma: no cover
def__lshift__(self,level:float)->None:"""Shorthand for updating the represented noise level Args: level (float): New noise level. Raises: ValueError: If the noise level is negative. """self.level=level
[docs]classN0(NoiseLevel):"""Fixed noise power configuration."""yaml_tag="N0"__power:floatdef__init__(self,power:float)->None:""" Args: power (float): Noise power in Watt. """self.power=power@propertydeflevel(self)->float:"""Power of the noise in Watt. Raises: ValueError: If the noise power is negative. """returnself.power@level.setterdeflevel(self,value:float)->None:self.power=value@propertydefpower(self)->float:"""Power of the noise level in Watt. Raises: ValueError: If the noise power is negative. """returnself.__power@power.setterdefpower(self,value:float)->None:ifvalue<0:raiseValueError("Noise power must be non-negative.")self.__power=valuedef__lshift__(self,power:float)->None:"""Shorthand for updating the represented noise power. Args: power (float): New noise power. """self.power=power
[docs]defget_power(self)->float:"""Power of the noise level. Returns: Power in Watt. """returnself.power
@propertydeftitle(self)->str:return"Noise Power"
[docs]classSNR(NoiseLevel):"""Signal-to-noise ratio configuration."""yaml_tag="SNR"__snr:float__reference:Device|Transmitter|Receiver__expected_channel_scale:floatdef__init__(self,snr:float,reference:Device|Transmitter|Receiver,channel:Channel|None=None)->None:""" Args: snr (float): Expected signal-to-noise ratio. reference (Device |Transmitter | Receiver): Reference of the noise level, i.e. with which power / energy was the signal generated. channel (Channel, optional): Channel instance over which the signal was propagated. For channel models that consider propagation losses the noise power is scaled accordingly. """# Initialize base classNoiseLevel.__init__(self)# Initialize class attributesself.snr=snrself.reference=referenceself.__expected_channel_scale=1.0ifchannelisnotNone:channel.add_sample_hook(self.__update_expected_channel_scale)def__update_expected_channel_scale(self,sample:ChannelSample)->None:"""Update the expected channel scale. Args: sample (ChannelSample): Channel sample. """self.__expected_channel_scale=sample.expected_energy_scale@propertydeflevel(self)->float:"""Linear signal power to noise power ratio. Raises: ValueError: If the ratio negative. """returnself.snr@level.setterdeflevel(self,value:float)->None:self.snr=value
@propertydeftitle(self)->str:return"SNR"@propertydefsnr(self)->float:"""Linear signal power to noise power ratio. Raises: ValueError: If the ratio negative. """returnself.__snr@snr.setterdefsnr(self,value:float)->None:ifvalue<=0.0:raiseValueError("Linear SNR must be greater than zero.")self.__snr=value@propertydefreference(self)->Device|Transmitter|Receiver:"""Reference to which the noise level is scaled. Can be either a device, transmitter or receiver. If assigned to a device, """returnself.__reference@reference.setterdefreference(self,value:Device|Transmitter|Receiver)->None:self.__reference=value