SpectrumResults
Provides methods to fetch and read the Spectrum measurement results.
- class nirfmxspecan.spectrum_results.SpectrumResults(signal_obj)[source]
Bases:
objectProvides methods to fetch and read the Spectrum measurement results.
- fetch_measurement(selector_string, timeout)[source]
Fetches the peak amplitude and frequency at which the peak occurred in the spectrum.
- Parameters:
selector_string (string) –
This parameter specifies a Selector String comprising of result name.
Example:
””
”result::r1”
You can use the
build_result_string()method to build the selector string.timeout (float) – This parameter specifies the timeout, in seconds, for fetching the specified measurement. 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:
- peak_amplitude (float):
This parameter returns the peak amplitude, of the averaged spectrum. When you set the
SPANattribute to 0, this method returns the peak amplitude in the time domain power trace.- peak_frequency (float):
This parameter returns the frequency, in Hz, at the peak amplitude of the averaged spectrum. This parameter is not valid if you set the Spectrum Span attribute to 0.
- frequency_resolution (float):
This parameter returns the frequency bin spacing, in Hz, of the spectrum acquired by the measurement. This parameter is not valid if you set the Spectrum Span attribute to 0.
- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (peak_amplitude, peak_frequency, frequency_resolution, error_code)
- fetch_power_trace(selector_string, timeout, power)[source]
Fetches the power trace for the Spectrum measurement.
- Parameters:
selector_string (string) –
This parameter specifies a Selector String comprising of result name.
Example:
””
”result::r1”
You can use the
build_result_string()method to build the selector string.timeout (float) – This parameter specifies the timeout, in seconds, for fetching the specified measurement. 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.
power (numpy.float32) – This parameter returns the measured average power, in units specified by
POWER_UNITSattribute, at each time instance.
- Returns:
- x0 (float):
This parameter returns the start time, in seconds.
- dx (float):
This parameter returns the sample duration, in seconds.
- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (x0, dx, error_code)
- fetch_spectrum(selector_string, timeout, spectrum)[source]
Fetches the spectrum used for the Spectrum measurement.
- Parameters:
selector_string (string) –
This parameter specifies a Selector String comprising of result name.
Example:
””
”result::r1”
You can use the
build_result_string()method to build the selector string.timeout (float) – This parameter specifies the timeout, in seconds, for fetching the specified measurement. 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.
spectrum (numpy.float32) – This parameter returns the averaged power, measured at each frequency bin. When you set the Spectrum Span attribute to 0, the averaged power is measured at each sample instance in time. The units of power is as specified using the
POWER_UNITSattribute.
- Returns:
- x0 (float):
This parameter returns the start frequency, in Hz. When you set the
SPANattribute to 0, x0 returns the start time, in seconds.- dx (float):
This parameter returns the frequency bin spacing, in Hz. When you set the Spectrum Span attribute to 0, dx returns the sample duration, in seconds.
- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (x0, dx, error_code)
- get_frequency_resolution(selector_string)[source]
Gets the frequency bin spacing of the spectrum acquired by the measurement. This value is expressed in Hz. This attribute is not valid if you set the
SPANattribute to 0.You do not need to use a selector string to read this result for default signal and result instance. Refer to the Selector String topic for information about the string syntax for named signals and results.
- Parameters:
selector_string (string) – Pass an empty string.
- Returns:
- attr_val (float):
Returns the frequency bin spacing of the spectrum acquired by the measurement. This value is expressed in Hz. This attribute is not valid if you set the
SPANattribute to 0.- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (attr_val, error_code)
- get_peak_amplitude(selector_string)[source]
Gets the peak amplitude, of the averaged spectrum.
When you set the
SPANattribute to 0, the measurement returns the peak amplitude in the time domain power trace.The amplitude is reported in units specified by the value of the
POWER_UNITSattribute.You do not need to use a selector string to read this result for default signal and result instance. Refer to the Selector String topic for information about the string syntax for named signals and results.
- Parameters:
selector_string (string) – Pass an empty string.
- Returns:
- attr_val (float):
Returns the peak amplitude, of the averaged spectrum.
- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (attr_val, error_code)
- get_peak_frequency(selector_string)[source]
Gets the frequency at the peak amplitude of the averaged spectrum. This value is expressed in Hz. This attribute is not valid if you set the
SPANattribute to 0.You do not need to use a selector string to read this result for default signal and result instance. Refer to the Selector String topic for information about the string syntax for named signals and results.
- Parameters:
selector_string (string) – Pass an empty string.
- Returns:
- attr_val (float):
Returns the frequency at the peak amplitude of the averaged spectrum. This value is expressed in Hz. This attribute is not valid if you set the
SPANattribute to 0.- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (attr_val, error_code)
- read(selector_string, timeout, spectrum)[source]
Configures hardware for acquisition, performs measurement on acquired data, and returns Spectrum measurement results.
- Parameters:
selector_string (string) – Pass an empty string. The signal name that is passed when creating the signal configuration is used.
timeout (float) – This parameter specifies the timeout, in seconds, for fetching the specified measurement. Set this value to an appropriate time, longer than expected for fetching the measurement. The default value is 10.
spectrum (numpy.float32) – This parameter returns the spectrum trace.
- Returns:
- x0 (float):
This parameter returns the start frequency, in Hz. When you set the %attribute{spectrum span} attribute to 0, x0 returns the start time, in seconds.
- dx (float):
This parameter returns the frequency bin spacing, in Hz. When you set the Spectrum Span attribute to 0, dx returns the sample duration, in seconds.
- error_code (int):
Returns the status code of this method. The status code either indicates success or describes a warning condition.
- Return type:
Tuple (x0, dx, error_code)