Source code for nirfmxspecan.phase_noise_results

"""Provides methods to fetch and read the PhaseNoise measurement results."""

import functools

import nirfmxspecan.attributes as attributes
import nirfmxspecan.errors as errors
import nirfmxspecan.internal._helper as _helper


def _raise_if_disposed(f):
    """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""

    @functools.wraps(f)
    def aux(*xs, **kws):
        meas_obj = xs[0]  # parameter 0 is 'self' which is the measurement object
        if meas_obj._signal_obj.is_disposed:
            raise Exception("Cannot access a disposed SpecAn signal configuration")
        return f(*xs, **kws)

    return aux


[docs] class PhaseNoiseResults(object): """Provides methods to fetch and read the PhaseNoise measurement results.""" def __init__(self, signal_obj): """Provides methods to fetch and read the PhaseNoise measurement results.""" self._signal_obj = signal_obj self._session_function_lock = signal_obj._session_function_lock self._interpreter = signal_obj._interpreter
[docs] @_raise_if_disposed def get_carrier_power(self, selector_string): r"""Gets the measured carrier power. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the measured carrier power. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_CARRIER_POWER.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_carrier_frequency(self, selector_string): r"""Gets the measured carrier frequency. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the measured carrier frequency. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_CARRIER_FREQUENCY.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_spot_phase_noise(self, selector_string): r"""Gets the phase noise corresponding to the :py:attr:`~nirfmxspecan.attributes.AttributeID.SPOT_NOISE_FREQUENCY_LIST` attribute by using the smoothed log plot trace. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the phase noise corresponding to the :py:attr:`~nirfmxspecan.attributes.AttributeID.SPOT_NOISE_FREQUENCY_LIST` attribute by using the smoothed log plot trace. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_SPOT_PHASE_NOISE.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_integrated_phase_noise(self, selector_string): r"""Gets the integrated phase noise. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the integrated phase noise. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_INTEGRATED_PHASE_NOISE.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_residual_pm_in_radian(self, selector_string): r"""Gets the residual PM in radians. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the residual PM in radians. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_INTEGRATED_NOISE_RESIDUAL_PM_IN_RADIAN.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_residual_pm_in_degree(self, selector_string): r"""Gets the residual PM in degrees. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the residual PM in degrees. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_INTEGRATED_NOISE_RESIDUAL_PM_IN_DEGREE.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_residual_fm(self, selector_string): r"""Gets the residual FM in Hz. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the residual FM in Hz. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_INTEGRATED_NOISE_RESIDUAL_FM.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def get_jitter(self, selector_string): r"""Gets the jitter in seconds. You do not need to use a selector string to read this attribute for the default signal instance. Refer to the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information about the string syntax for named signals. Args: selector_string (string): Pass an empty string. Returns: Tuple (attr_val, error_code): attr_val (float): Returns the jitter in seconds. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) attr_val, error_code = self._interpreter.get_attribute_f64_array( updated_selector_string, attributes.AttributeID.PHASENOISE_RESULTS_INTEGRATED_NOISE_JITTER.value, ) finally: self._session_function_lock.exit_read_lock() return attr_val, error_code
[docs] @_raise_if_disposed def fetch_carrier_measurement(self, selector_string, timeout): r"""Fetches the carrier measurement. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (carrier_frequency, carrier_power, error_code): carrier_frequency (float): This parameter returns the measured carrier power. This value is expressed in Hz. carrier_power (float): This parameter returns the measured carrier frequency. This value is expressed in dBm. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) carrier_frequency, carrier_power, error_code = ( self._interpreter.phase_noise_fetch_carrier_measurement( updated_selector_string, timeout ) ) finally: self._session_function_lock.exit_read_lock() return carrier_frequency, carrier_power, error_code
[docs] @_raise_if_disposed def fetch_integrated_noise(self, selector_string, timeout): r"""Fetches the integrated noise measurement. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (integrated_phase_noise, residual_pm_in_radian, residual_pm_in_degree, residual_fm, jitter, error_code): integrated_phase_noise (float): This parameter returns the integrated phase noise. This value is expressed in dBc. residual_pm_in_radian (float): This parameter returns the residual PM in radians. residual_pm_in_degree (float): This parameter returns the residual PM. This value is expressed in degrees. residual_fm (float): This parameter returns the residual FM. This value is expressed in Hz. jitter (float): This parameter returns the jitter. This value is expressed in seconds. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) ( integrated_phase_noise, residual_pm_in_radian, residual_pm_in_degree, residual_fm, jitter, error_code, ) = self._interpreter.phase_noise_fetch_integrated_noise( updated_selector_string, timeout ) finally: self._session_function_lock.exit_read_lock() return ( integrated_phase_noise, residual_pm_in_radian, residual_pm_in_degree, residual_fm, jitter, error_code, )
[docs] @_raise_if_disposed def fetch_measured_log_plot_trace(self, selector_string, timeout): r"""Fetches the log plot trace. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (frequency, measured_phase_noise, error_code): frequency (float): This parameter returns an array of the frequency offsets where phase noise has been measured. measured_phase_noise (float): This parameter returns an array of measured phase noise at the frequency offset. This value is expressed in dBc/Hz. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) frequency, measured_phase_noise, error_code = ( self._interpreter.phase_noise_fetch_measured_log_plot_trace( updated_selector_string, timeout ) ) finally: self._session_function_lock.exit_read_lock() return frequency, measured_phase_noise, error_code
[docs] @_raise_if_disposed def fetch_smoothed_log_plot_trace(self, selector_string, timeout): r"""Fetches the smoothened log plot trace. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (frequency, smoothed_phase_noise, error_code): frequency (float): This parameter returns an array of the frequency offsets where phase noise has been measured. smoothed_phase_noise (float): This parameter returns an array of smoothed phase noise at the frequency offset. This value is expressed in dBc/Hz. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) frequency, smoothed_phase_noise, error_code = ( self._interpreter.phase_noise_fetch_smoothed_log_plot_trace( updated_selector_string, timeout ) ) finally: self._session_function_lock.exit_read_lock() return frequency, smoothed_phase_noise, error_code
[docs] @_raise_if_disposed def fetch_spot_noise(self, selector_string, timeout): r"""Fetches the spot noise. Args: selector_string (string): This parameter specifies a `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result name. Example: "" "result::r1" You can use the :py:meth:`build_result_string` method to build the selector string. timeout (float): This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the method waits until the measurement is complete. The default value is 10. Returns: Tuple (spot_phase_noise, error_code): spot_phase_noise (float): This parameter returns the phase noise corresponding to the value of the :py:attr:`~nirfmxspecan.attributes.AttributeID.SPOT_NOISE_FREQUENCY_LIST` attribute, by using the smoothed log plot trace. error_code (int): Returns the status code of this method. The status code either indicates success or describes a warning condition. """ try: self._session_function_lock.enter_read_lock() _helper.validate_not_none(selector_string, "selector_string") updated_selector_string = _helper.validate_and_update_selector_string( selector_string, self._signal_obj ) spot_phase_noise, error_code = self._interpreter.phase_noise_fetch_spot_noise( updated_selector_string, timeout ) finally: self._session_function_lock.exit_read_lock() return spot_phase_noise, error_code