:py:mod:`simcats.distortions` ============================= .. py:module:: simcats.distortions .. autoapi-nested-parse:: SimCATS subpackage containing all functionalities related to the distortion simulation. Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: simcats.distortions.DistortionInterface simcats.distortions.OccupationDistortionInterface simcats.distortions.SensorPotentialDistortionInterface simcats.distortions.SensorResponseDistortionInterface simcats.distortions.OccupationTransitionBlurringGaussian simcats.distortions.OccupationTransitionBlurringFermiDirac simcats.distortions.OccupationDotJumps simcats.distortions.SensorPotentialPinkNoise simcats.distortions.RandomTelegraphNoise simcats.distortions.SensorPotentialRTN simcats.distortions.SensorResponseRTN simcats.distortions.SensorResponseWhiteNoise Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: simcats.distortions.dot_jumps_blockwise simcats.distortions.pink_gaussian_noise simcats.distortions.random_telegraph_noise simcats.distortions.white_gaussian_noise Package Implementation Details ------------------------------ .. py:class:: DistortionInterface Bases: :py:obj:`abc.ABC` .. autoapi-inheritance-diagram:: simcats.distortions.DistortionInterface :parts: 1 General interface for distortions. Explicit distortion types are derived from this. The simulation class expects to receive objects of the explicit types, which are assigned to different stages. .. py:method:: noise_function(*args, **kwargs) :abstractmethod: This function has to be implemented for adding distortions in any stage of the simulation. :param \*args: Specified in subclasses :param \*\*kwargs: Specified in subclasses :returns: distorted data .. py:class:: OccupationDistortionInterface Bases: :py:obj:`DistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.OccupationDistortionInterface :parts: 1 Interface for distortions affecting the occupations and lead transitions ("the structure") of a simulated CSD. .. py:method:: noise_function(occupations, lead_transitions, volt_limits_g1, volt_limits_g2, generate_csd = None, freeze = False) :abstractmethod: This method has to be implemented for adding distortions to the occupations and lead transitions. :param occupations: Contains the original occupations to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the occupations. :type occupations: np.ndarray :param lead_transitions: Contains the original lead transition mask to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the lead transitions. :type lead_transitions: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :param generate_csd: Function which generates data points outside the swept gate range. This is especially required for distortions, which shift the CSD structure. The generated data points also have to contain the distortions, which have already been added to the occupation and lead_transitions before. Default is None. :type generate_csd: Optional[Callable] :param freeze: Indicates if the last used noise should be reused. This is important if there are noise types which need to generate data from outside the current CSD (for example if a part of the structure is shifted). This newly generated data also has to contain the noise which already has been applied to the CSD before. :type freeze: bool :returns: Occupation numbers and lead transition mask (in our case: total charge transitions) with added distortions. The occupation numbers are stored in a 3-dimensional numpy array. The first two dimensions map to the axis of the CSD, while the third dimension indicates the dot of the corresponding occupation value. The label mask for the lead-to-dot transitions is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: Tuple[np.ndarray, np.ndarray] .. py:class:: SensorPotentialDistortionInterface Bases: :py:obj:`DistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.SensorPotentialDistortionInterface :parts: 1 Interface for distortions affecting the potential of the sensor used to measure a simulated CSD. .. py:method:: noise_function(mu_sens, volt_limits_g1, volt_limits_g2) :abstractmethod: This method has to be implemented in every object which should be used to distort the sensor potential of a CSD. :param mu_sens: Contains the sensor potential to which the distortions are added. The potential is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. If there are other types of distortions which appear first, they should already be included in the potential. :type mu_sens: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :returns: The sensor potential with added distortions. The potential is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: np.ndarray .. py:class:: SensorResponseDistortionInterface Bases: :py:obj:`DistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.SensorResponseDistortionInterface :parts: 1 Interface for distortions affecting the sensor response of a simulated CSD. This includes every effect which happens after the sensor. .. py:method:: noise_function(sensor_response, volt_limits_g1, volt_limits_g2) :abstractmethod: Method which has to be implemented by every object used to distort the sensor response of a CSD. :param sensor_response: Contains the sensor response to which the distortions are added. The sensor response is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. If there are other types of distortions which appear first, they should already be included in the response. :type sensor_response: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :returns: The sensor response with added distortions. The sensor response is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: np.ndarray .. py:class:: OccupationTransitionBlurringGaussian(sigma) Bases: :py:obj:`simcats.distortions.OccupationDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.OccupationTransitionBlurringGaussian :parts: 1 Gaussian filter blurring implementation of the OccupationDistortionsInterface. Initializes an object of the class used to blur lead transitions and occupations changes. :param sigma: The sigma of the gaussian blur, defining the strength of the blurring. If sigma is of type ParameterSampling a new sigma is sampled accordingly per call of noise_function. :type sigma: Union[float, ParameterSamplingInterface] .. py:property:: sigma :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The sigma of the gaussian blur, defining the strength of the blurring. .. py:property:: latest_sigma :type: Optional[float] The sigma that was used for the latest simulation. This is necessary because, depending on the setting, a sampler can be used instead of a fixed sigma. .. py:method:: noise_function(occupations, lead_transitions, volt_limits_g1, volt_limits_g2, generate_csd = None, freeze = False) This function is used to add blurring to the supplied occupations and lead transitions. The distortion parameter is adjusted to the resolution, as it is specified in voltage space but must be applied in pixel space. Warning: This function changes the supplied occupation and lead_transitions arrays. If you want to keep the original ones, please give a copy of them into this function. :param occupations: Contains the original occupation to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the occupations. Warning: this argument is changed during the execution of the function. :type occupations: np.ndarray :param lead_transitions: Contains the original lead transition mask to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the lead transitions. Warning: this argument is changed during the execution of the function. :type lead_transitions: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :param generate_csd: Function which generates data points outside the swept gate range. This is especially required for distortions, which shift the CSD structure. The generated data points also have to contain the distortions, which have already been added to the occupation and lead_transitions before. :type generate_csd: Optional[Callable] :param freeze: Indicates if the last used noise should be reused. This is important if there are noise types which need to generate data from outside the current CSD (for example if a part of the structure is shifted). This newly generated data also has to contain the noise which already has been applied to the CSD before. :type freeze: bool :returns: Occupation numbers and lead transition mask (in our case: total charge transitions) with added distortions. The occupation numbers are stored in a 3-dimensional numpy array. The first two dimensions map to the axis of the CSD, while the third dimension indicates the dot of the corresponding occupation value. The label mask for the lead-to-dot transitions is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: Tuple[np.ndarray, np.ndarray] .. py:class:: OccupationTransitionBlurringFermiDirac(sigma) Bases: :py:obj:`simcats.distortions.OccupationDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.OccupationTransitionBlurringFermiDirac :parts: 1 Fermi-Dirac filter blurring implementation of the OccupationDistortionsInterface. Initializes an object of the class used to blur lead transitions and occupations changes. :param sigma: The sigma of the Fermi-Dirac blur, defining the strength of the blurring. If sigma is of type ParameterSampling a new sigma is sampled accordingly per call of noise_function. :type sigma: Union[float, ParameterSamplingInterface] .. py:property:: sigma :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The sigma of the Fermi-Dirac blur, defining the strength of the blurring. .. py:property:: latest_sigma :type: Optional[float] The sigma that was used for the latest simulation. This is necessary because, depending on the setting, a sampler can be used instead of a fixed sigma. .. py:method:: noise_function(occupations, lead_transitions, volt_limits_g1, volt_limits_g2, generate_csd = None, freeze = False) This function is used to add blurring to the supplied occupations and lead transitions. The distortion parameter is adjusted to the resolution, as it is specified in voltage space but must be applied in pixel space. Warning: This function changes the supplied occupation and lead_transitions arrays. If you want to keep the original ones, please give a copy of them into this function. :param occupations: Contains the original occupation to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the occupations. Warning: this argument is changed during the execution of the function. :type occupations: np.ndarray :param lead_transitions: Contains the original lead transition mask to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the lead transitions. Warning: this argument is changed during the execution of the function. :type lead_transitions: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :param generate_csd: Function which generates data points outside the swept gate range. This is especially required for distortions, which shift the CSD structure. The generated data points also have to contain the distortions, which have already been added to the occupation and lead_transitions before. :type generate_csd: Optional[Callable] :param freeze: Indicates if the last used noise should be reused. This is important if there are noise types which need to generate data from outside the current CSD (for example if a part of the structure is shifted). This newly generated data also has to contain the noise which already has been applied to the CSD before. :type freeze: bool :returns: Occupation numbers and lead transition mask (in our case: total charge transitions) with added distortions. The occupation numbers are stored in a 3-dimensional numpy array. The first two dimensions map to the axis of the CSD, while the third dimension indicates the dot of the corresponding occupation value. The label mask for the lead-to-dot transitions is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: Tuple[np.ndarray, np.ndarray] .. py:class:: OccupationDotJumps(scale, lam, axis, ratio = 1, rng = np.random.default_rng()) Bases: :py:obj:`simcats.distortions.OccupationDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.OccupationDotJumps :parts: 1 Dot jumps implementation of the OccupationDistortionsInterface. Dot jumps are simulated by adding shifts in the occupations. Initializes an object of the class used to generate dot jumps. :param scale: Specifies the length of the shifts, gives the mathematical expectation for their length. In this case, scale specifies the width of the block in which a shift is present. Given in volt per pixel. If the scale is of type ParameterSampling a new scale is sampled accordingly per call of noise_function. :type scale: Union[float, ParameterSamplingInterface] :param lam: Lambda for the poisson distribution which specifies the height of the jumps. Given in volt per pixel. If lam is of type ParameterSampling a new lam is sampled accordingly per call of noise_function. :type lam: Union[float, ParameterSamplingInterface] :param axis: The axis along which dot jumps will be generated. That means, the values are also shifted along this axis. For axis=0 this results into shifts along the y/g2-axis and for axis=1 into shifts along the x/g1-axis. :type axis: int :param ratio: The ratio defining how often this type of distortion should be active. For each simulation a random number decides if the distortion type is active, based on the supplied ratio. Default is 1. :type ratio: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator .. py:property:: scale :type: Union[float, simcats.support_functions.ParameterSamplingInterface] Specifies the length of the shifts, gives the mathematical expectation for their length. In this case, scale specifies the width of the block in which a shift is present. Given in volt per pixel. .. py:property:: lam :type: Union[float, simcats.support_functions.ParameterSamplingInterface] Lambda for the poisson distribution which specifies the height of the jumps. Given in volt per pixel. .. py:property:: axis :type: int The axis along which dot jumps will be generated. That means, the values are also shifted along this axis. For axis=0 this results into shifts along the y/g2-axis and for axis=1 into shifts along the x/g1-axis. .. py:property:: ratio :type: float The ratio defining how often this type of distortion should be active. .. py:property:: rng :type: numpy.random.Generator The random number generator used for the simulation of random numbers. .. py:property:: activated :type: Optional[bool] This is true if the noise was activated during the last call of noise function. .. py:method:: noise_function(occupations, lead_transitions, volt_limits_g1, volt_limits_g2, generate_csd = None, freeze = False) This function is used to add dot jumps to the supplied occupations and lead transitions. The distortion parameters are adjusted to the resolution, as they are specified in voltage space but must be applied in pixel space. Warning: This function changes the supplied occupation and lead_transitions arrays. If you want to keep the original ones, please give a copy of them into this function. :param occupations: Contains the original occupations to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the occupations. Warning: this argument is changed during the execution of the function. :type occupations: np.ndarray :param lead_transitions: Contains the original lead transition mask to which the distortions are added. If there are other types of distortions which appear first, they should already be included in the lead transitions. Warning: this argument is changed during the execution of the function. :type lead_transitions: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :param generate_csd: Function which generates data points outside the swept gate range. This is especially required for distortions, which shift the CSD structure. The generated data points also have to contain the distortions, which have already been added to the occupation and lead_transitions before. Defaults to None. :type generate_csd: Optional[Callable] :param freeze: Indicates if the last used noise should be reused. This is important if there are noise types which need to generate data from outside the current CSD (for example if a part of the structure is shifted). This newly generated data also has to contain the noise which already has been applied to the CSD before. A use case for that is the application of dot jumps in vertical direction after the application in horizontal direction. Due to the jumps in vertical direction new data might have to be generated with generate_csd. In this data, the horizontal jumps also have to be applied. :type freeze: bool :returns: Occupation numbers and lead transition mask (in our case: total charge transitions) with added distortions. The occupation numbers are stored in a 3-dimensional numpy array. The first two dimensions map to the axis of the CSD, while the third dimension indicates the dot of the corresponding occupation value. The label mask for the lead-to-dot transitions is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: Tuple[np.ndarray, np.ndarray] .. py:function:: dot_jumps_blockwise(original, scale, lam, noise = None, axis = 1, rng = np.random.default_rng()) Adds dot jumps to the original image. In this case that means, that a whole block of columns can be shifted in x direction (axis=1) or a block of lines can be shifted in y direction (axis=0). When this is applied to charge stability diagrams (CSDs) it should be applied before any other distortion type directly to the occupation of the dots. It can be applied for the occupation of the first dot and after that the generated distortion which is returned can be used for the second dot. This should be done because otherwise different blocks are shifted for the occupations of the first and the second dot. :param original: Original image where the distortions should be added. Can be lead transition mask or occupations. :type original: np.ndarray :param scale: Specifies the length of the shifts, gives the mathematical expectation for their length. In this case, scale specifies the width of the block in which a shift is present. Given in pixels. :type scale: float :param lam: Lambda for the poisson distribution which specifies the height of the jumps. Given in pixels. :type lam: float :param noise: Noise which was generated with this method for a prior image and should be reapplied for this image. Default is None. :type noise: np.ndarray :param axis: The axis along which dot jumps will be generated. That means the values are shifted along this axis. :type axis: int :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator :returns: Distorted version of the original image and pure distortion which was used for this image and could be used again for the second dot of the dataset. :rtype: np.ndarray, np.ndarray .. py:class:: SensorPotentialPinkNoise(sigma, fmin = 0, rng = np.random.default_rng()) Bases: :py:obj:`simcats.distortions.SensorPotentialDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.SensorPotentialPinkNoise :parts: 1 Pink noise implementation of the SensorPotentialDistortionsInterface. Initializes an object of the class used to generate pink noise. :param sigma: The sigma for the pink noise distribution. If sigma is of type ParameterSampling a new sigma is sampled accordingly per call of noise_function. :type sigma: Union[float, ParameterSamplingInterface] :param fmin: Minimal frequency which can be present in the generated noise. The maximal possible value is 0.5 which generates white noise. The minimal value is 1/(number of pixels). The default is 0, which results in the same as 1/(number of pixels). :type fmin: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator .. py:property:: sigma :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The sigma for the pink noise distribution. .. py:property:: fmin :type: float Minimal frequency which can be present in the generated noise. .. py:property:: rng :type: numpy.random.Generator The random number generator used for the simulation of random numbers. .. py:property:: latest_sigma :type: float The sigma that was used for the latest simulation. This is necessary because, depending on the setting, a sampler can be used instead of a fixed sigma. .. py:method:: noise_function(mu_sens, volt_limits_g1, volt_limits_g2) This function is used to add pink noise to the sensor potential of a CSD. :param mu_sens: Contains the sensor potential to which the distortions are added. The potential is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. If there are other types of distortions which appear first, they should already be included in the potential. :type mu_sens: np.ndarray :param volt_limits_g1: Contains the beginning and ending of the swept range for the first (plunger) gate. :type volt_limits_g1: np.ndarray :param volt_limits_g2: Contains the beginning and ending of the swept range for the second (plunger) gate. :type volt_limits_g2: np.ndarray :returns: The sensor potential with added noise. The potential is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: np.ndarray .. py:function:: pink_gaussian_noise(original, scale, fmin, rng = np.random.default_rng()) Adds pink Gaussian noise to the original image. :param original: Original image where the noise should be added. :type original: np.ndarray :param scale: Scaling factor with which the generated noise is multiplied. This is also the standard deviation (STD) for the noise. :type scale: float :param fmin: Minimal frequency which can be present in the generated noise. The maximal possible value is 0.5 which generates white noise. The minimal value is 1/(number of pixels). :type fmin: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator :returns: Original image distorted by pink noise. :rtype: np.ndarray .. py:class:: RandomTelegraphNoise(scale, std, height, ratio = 1, rng = np.random.default_rng()) Bases: :py:obj:`simcats.distortions.DistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.RandomTelegraphNoise :parts: 1 Random telegraph noise (RTN) implementation of the (general) DistortionsInterface. This general implementation is independent of the distortion step/type (occupations, sensor potential, or sensor response). Specific implementations are derived from this generic one. Initializes an object of the class used to simulate random telegraph noise. :param scale: Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. If the scale is of type ParameterSampling a new scale is sampled accordingly per call of noise_function. :type scale: Union[float, ParameterSamplingInterface] :param std: The standard deviation of the magnitude of the jumps. If std is of type ParameterSampling a new std is sampled accordingly per call of noise_function. :type std: Union[float, ParameterSamplingInterface] :param height: The mean of the magnitude of the jumps. If the height is of type ParameterSampling a new height is sampled accordingly per call of noise_function. :type height: Union[float, ParameterSamplingInterface] :param ratio: The ratio defining how often this type of noise should be active. For each simulation a random number decides if the noise type is active, based on the supplied ratio. Default is 1. :type ratio: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator .. py:property:: scale :type: Union[float, simcats.support_functions.ParameterSamplingInterface] Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. .. py:property:: std :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The standard deviation of the magnitude of the jumps. .. py:property:: height :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The mean of the magnitude of the jumps. .. py:property:: ratio :type: float The ratio defining how often this type of noise should be active. .. py:property:: rng :type: numpy.random.Generator The random number generator used for the simulation of random numbers. .. py:property:: activated :type: Optional[bool] This is true if the noise was activated during the last call of noise function. .. py:method:: noise_function(original, volt_limits_g1, volt_limits_g2) Adds random telegraph noise to the original image. The distortion parameter `scale` is adjusted to the resolution, as it is specified in voltage space but must be applied in pixel space. :param original: Original image. Can be a sensor potential or a sensor response :type original: np.ndarray :param volt_limits_g1: Voltage sweep range of (plunger) gate 1 (second-/x-axis). Example: [min_V1, max_V1] :type volt_limits_g1: np.ndarray :param volt_limits_g2: Voltage sweep range of (plunger) gate 2 (first-/y-axis). Example: [min_V2, max_V2] :type volt_limits_g2: np.ndarray :returns: Original image distorted by random telegraph noise. :rtype: np.ndarray .. py:class:: SensorPotentialRTN(scale, std, height, ratio = 1, rng = np.random.default_rng()) Bases: :py:obj:`RandomTelegraphNoise`, :py:obj:`simcats.distortions.SensorPotentialDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.SensorPotentialRTN :parts: 1 Random telegraph noise (RTN) implementation of the SensorPotentialDistortionInterface. Initializes an object of the class used to simulate random telegraph noise affecting the sensor potential. :param scale: Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. If the scale is of type ParameterSampling a new scale is sampled accordingly per call of noise_function. :type scale: Union[float, ParameterSamplingInterface] :param std: The standard deviation of the magnitude of the jumps. If std is of type ParameterSampling a new std is sampled accordingly per call of noise_function. :type std: Union[float, ParameterSamplingInterface] :param height: The mean of the magnitude of the jumps. If the height is of type ParameterSampling a new height is sampled accordingly per call of noise_function. :type height: Union[float, ParameterSamplingInterface] :param ratio: The ratio defining how often this type of noise should be active. For each simulation a random number decides if the noise type is active, based on the supplied ratio. Default is 1. :type ratio: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator .. py:method:: noise_function(mu_sens, volt_limits_g1, volt_limits_g2) Adds random telegraph noise to the sensor potential. The distortion parameters are adjusted to the resolution, as they are specified in voltage space but must be applied in pixel space. :param mu_sens: Contains the sensor potential to which the noise is added. The potential is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. If there are other types of distortions which appear first, they should already be included in the potential. :type mu_sens: np.ndarray :param volt_limits_g1: Voltage sweep range of (plunger) gate 1 (second-/x-axis). Example: [min_V1, max_V1] :type volt_limits_g1: np.ndarray :param volt_limits_g2: Voltage sweep range of (plunger) gate 2 (first-/y-axis). Example: [min_V2, max_V2] :type volt_limits_g2: np.ndarray :returns: The sensor potential with added noise. The potential is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: np.ndarray .. py:property:: scale :type: Union[float, simcats.support_functions.ParameterSamplingInterface] Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. .. py:property:: std :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The standard deviation of the magnitude of the jumps. .. py:property:: height :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The mean of the magnitude of the jumps. .. py:property:: ratio :type: float The ratio defining how often this type of noise should be active. .. py:property:: rng :type: numpy.random.Generator The random number generator used for the simulation of random numbers. .. py:property:: activated :type: Optional[bool] This is true if the noise was activated during the last call of noise function. .. py:class:: SensorResponseRTN(scale, std, height, ratio = 1, rng = np.random.default_rng()) Bases: :py:obj:`RandomTelegraphNoise`, :py:obj:`simcats.distortions.SensorResponseDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.SensorResponseRTN :parts: 1 Random telegraph noise (RTN) implementation of the SensorResponseDistortionInterface. Initializes an object of the class used to simulate random telegraph noise affecting the sensor response. :param scale: Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. If the scale is of type ParameterSampling a new scale is sampled accordingly per call of noise_function. :type scale: Union[float, ParameterSamplingInterface] :param std: The standard deviation of the magnitude of the jumps. If std is of type ParameterSampling a new std is sampled accordingly per call of noise_function. :type std: Union[float, ParameterSamplingInterface] :param height: The mean of the magnitude of the jumps. If the height is of type ParameterSampling a new height is sampled accordingly per call of noise_function. :type height: Union[float, ParameterSamplingInterface] :param ratio: The ratio defining how often this type of noise should be active. For each simulation a random number decides if the distortions type is active, based on the supplied ratio. Default is 1. :type ratio: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator .. py:method:: noise_function(sensor_response, volt_limits_g1, volt_limits_g2) Adds random telegraph noise to the sensor response. The distortion parameters are adjusted to the resolution, as they are specified in voltage space but must be applied in pixel space. :param sensor_response: Contains the sensor response to which the noise is added. The sensor response is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. If there are other types of distortions which appear first, they should already be included in the response. :type sensor_response: np.ndarray :param volt_limits_g1: Voltage sweep range of plunger gate 1 (second-/x-axis). Example: [min_V1, max_V1] :type volt_limits_g1: np.ndarray :param volt_limits_g2: Voltage sweep range of plunger gate 2 (first-/y-axis). Example: [min_V2, max_V2] :type volt_limits_g2: np.ndarray :returns: The sensor response with added noise. The sensor response is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: np.ndarray .. py:property:: scale :type: Union[float, simcats.support_functions.ParameterSamplingInterface] Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. .. py:property:: std :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The standard deviation of the magnitude of the jumps. .. py:property:: height :type: Union[float, simcats.support_functions.ParameterSamplingInterface] The mean of the magnitude of the jumps. .. py:property:: ratio :type: float The ratio defining how often this type of noise should be active. .. py:property:: rng :type: numpy.random.Generator The random number generator used for the simulation of random numbers. .. py:property:: activated :type: Optional[bool] This is true if the noise was activated during the last call of noise function. .. py:function:: random_telegraph_noise(original, scale, std, height, rng = np.random.default_rng()) Adds random telegraph noise to the original image. :param original: Original image where the noise should be added. :type original: np.ndarray :param scale: Specifies the length of the bursts/mathematical expectation for their length and also the length of regions without bursts. :type scale: float :param std: The standard deviation of the magnitude of the jumps. :type std: float :param height: The mean of the magnitude of the jumps. :type height: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator :returns: Original image with noisy added to it. :rtype: np.ndarray .. py:class:: SensorResponseWhiteNoise(sigma, rng = np.random.default_rng()) Bases: :py:obj:`simcats.distortions.SensorResponseDistortionInterface` .. autoapi-inheritance-diagram:: simcats.distortions.SensorResponseWhiteNoise :parts: 1 White noise implementation of the SensorResponseDistortionsInterface. Initializes an object of the class used to generate white noise. :param sigma: Standard deviation for the Gaussian distribution of the noise, determines the strength of the noise. If sigma is of type ParameterSampling a new sigma is sampled accordingly per call of noise_function. :type sigma: Union[float, ParameterSamplingInterface] :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator .. py:property:: rng :type: numpy.random.Generator The random number generator used for the simulation of random numbers. .. py:property:: sigma :type: Union[float, simcats.support_functions.ParameterSamplingInterface] Standard deviation for the Gaussian distribution of the noise, determines the strength of the noise. .. py:property:: latest_sigma :type: Optional[float] The sigma that was used for the latest simulation. This is necessary because, depending on the setting, a sampler can be used instead of a fixed sigma. .. py:method:: noise_function(sensor_response, volt_limits_g1, volt_limits_g2) Adds white noise to the sensor response. :param sensor_response: Contains the sensor response to which the noise are added. The sensor response is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. If there are other types of distortions which appear first, they should already be included in the response. :type sensor_response: np.ndarray :param volt_limits_g1: Voltage sweep range of (plunger) gate 1 (second-/x-axis). Example: [min_V1, max_V1] :type volt_limits_g1: np.ndarray :param volt_limits_g2: Voltage sweep range of (plunger) gate 2 (first-/y-axis). Example: [min_V2, max_V2] :type volt_limits_g2: np.ndarray :returns: The sensor response with added noise. The sensor response is stored in a 2-dimensional numpy array with the axis mapping to the CSD axis. :rtype: np.ndarray .. py:function:: white_gaussian_noise(original, sigma, rng = np.random.default_rng()) Adds white Gaussian noise to the original image. :param original: Original image where the noise should be added. :type original: np.ndarray :param sigma: Standard deviation for the Gaussian distribution of the noise, determines the strength of the noise. For an array, the entries determine the different noise strength in x and y direction. :type sigma: float :param rng: The random number generator used for the simulation of random numbers. Default is np.random.default_rng(). :type rng: np.random.Generator :returns: Original image with added noise. :rtype: np.ndarray