# devices.rohdeschwarz:FSW8


The device class for the Rohde & Schwarz FSW8 spectrum analyzer.


Usage

``` python
devices.rohdeschwarz:FSW8(
    interface,
    reset=True,
    timeout=60000.0,
    **kwargs,
)
```


It can possibly be used with different models with little changes.


## Attributes

| Name | Description |
|----|----|
| [maxAverage](#maxAverage) | The maximum average setting. |

------------------------------------------------------------------------


### maxAverage


The maximum average setting.


`maxAverage=``1`


The FSW8 will trigger that many sweeps, so the averaging requirement is satisfied.


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize the device. |
| [configureSweep()](#configureSweep) | Change the sweep settings. |
| [getData()](#getData) | Transfer measurement data from the VNA. |
| [getSweepData()](#getSweepData) | Prepare, trigger, and retrieve sweep data. |
| [noise_cancellation()](#noise_cancellation) | Turn noise cancellation on and off. |
| [readSweepParams()](#readSweepParams) | Read the sweep parameters from the FSW8. |
| [reset()](#reset) | Reset the FSW8 device. |
| [setFreq()](#setFreq) | Set the center frequency and frequency span. |
| [setStartStopFreq()](#setStartStopFreq) | Set the start and stop frequencies. |
| [startSweep()](#startSweep) | Prepare the FSW8 for triggering a sweep. |
| [trigger()](#trigger) | Trigger the sweep(s). |

------------------------------------------------------------------------


### \_\_init\_\_()


Initialize the device.


Usage

``` python
__init__(
    interface,
    reset=True,
    timeout=60000.0,
    **kwargs,
)
```


#### Parameters


`interface: str`  
The ip andress and port where the device is located. e.g. TCPIP::192.168.5.52::5025::SOCKET

`reset: bool = ``True`  
If true, the PSA is reset on object creation using the reset method. Default is True.

`timeout: int = ``60000.0`  
The timeout of the ethernet connection in milliseconds. Default is 60e3 ms.

`**kwargs`  
Keyword arguments passed to the VISAdevice constructor.


------------------------------------------------------------------------


### configureSweep()


Change the sweep settings.


Usage

``` python
configureSweep(
    swePoints,
    refLev,
    resBW,
    vidBW=None,
    intpreamp=None,
    average=None,
    avgType="power",
    detector="rms",
    attAuto=True,
    attVal=0,
    sweType="fft",
    getData=False,
)
```


Frequency units are in Hz.


#### Parameters


`swePoints: int`  
Number of points per sweep.

`refLev: int`  
Reference level for a spurious emission measurement range.

`resBW: int`  
Resolution bandwidth, decoupled from the span. In the Real-Time application the resolution bandwidth is always coupled to the span.

`vidBW: int = None`  
Video bandwidth. If not None, the video bandwidth is decoupled from the resolution bandwidths.

`intpreamp: int = None`  
Turns the internal preamplifier on and off; requires the optional preamplifier hardware. An activated external preamplifier disables the internal one, and vice versa. For R&S FSW 8/13 models the preamplification is defined by INPut:GAIN\[:VALue\].

`average: int = None`  
Number of averages which make up the final values.

`avgType: (power, linear, logarithmic) = ``"power"`  
'power' converts to Watt prior averaging, 'linear' averages before converting to logarithmic values, 'logarithmic' averages logarithmic power values. Default is 'power'.

`detector: (rms, log, scalar) = ``"rms"`  
'rms' power (RMS) averaging, 'log' log-power (video) averaging, 'scalar' voltage averaging. Default is 'rms'.

`attAuto: bool = ``True`  
If True, the attenuation is coupled to the reference level and set automatically for optimal internal data processing. Default is True.

`attVal: int = ``0`  
Total attenuation for RF input. Default is 0.

`sweType: (fft, sweep, auto) = ``"fft"`  
Sweep type; 'auto' selects between sweep mode and FFT. Default is 'fft'.

`getData: bool = ``False`  
If True, trigger a sweep and return the results directly. Default is False.


#### Returns


`numpy.ndarray or None`  
The sweep data if getData is True, otherwise None.


------------------------------------------------------------------------


### getData()


Transfer measurement data from the VNA.


Usage

``` python
getData(precision="single")
```


#### Parameters


`precision: str = ``"single"`  
One of {'single', 'double', 'ascii'} 'single' and 'double' precisions are transferred as binary data, and achieve much faster transfer speeds. 'ascii' is only implemented as a fallback method, as it is much easier to debug. Default is 'single'.


#### Returns


`numpy.ndarray`  
The measured data from the device.


------------------------------------------------------------------------


### getSweepData()


Prepare, trigger, and retrieve sweep data.


Usage

``` python
getSweepData()
```


This is a convenience method to prepare and trigger the sweep and transfer the data afterwards.


#### Returns


`numpy.ndarray`  
The measured data from the specified channel.


------------------------------------------------------------------------


### noise_cancellation()


Turn noise cancellation on and off.


Usage

``` python
noise_cancellation(state=False)
```


If noise cancellation is on, the R&S FSW performs a reference measurement to determine its inherent noise and subtracts the result from the channel power measurement result (first active trace only).


#### Parameters


`state: bool = ``False`  
Whether to enable noise cancellation. Default is False.


------------------------------------------------------------------------


### readSweepParams()


Read the sweep parameters from the FSW8.


Usage

``` python
readSweepParams()
```


Frequencies are returned in Hz.


#### Returns


`tuple`  
A tuple containing (fStart, fStop, fPoints) where:

fStart : float The frequency at which the sweep starts. fStop : float The frequency at which the sweep stops. fPoints : int The number of points in the sweep.


------------------------------------------------------------------------


### reset()


Reset the FSW8 device.


Usage

``` python
reset()
```


------------------------------------------------------------------------


### setFreq()


Set the center frequency and frequency span.


Usage

``` python
setFreq(
    fCent,
    fSpan,
)
```


#### Parameters


`fCent: float`  
The center frequency in Hz.

`fSpan: float`  
The frequency span in Hz.


------------------------------------------------------------------------


### setStartStopFreq()


Set the start and stop frequencies.


Usage

``` python
setStartStopFreq(
    fStart,
    fStop,
)
```


#### Parameters


`fStart: float`  
The start frequency in Hz.

`fStop: float`  
The stop frequency in Hz.


------------------------------------------------------------------------


### startSweep()


Prepare the FSW8 for triggering a sweep.


Usage

``` python
startSweep()
```


The FSW8 disables the continuous trigger and therefore enables manual triggering. Any currently running sweeps are aborted.


------------------------------------------------------------------------


### trigger()


Trigger the sweep(s).


Usage

``` python
trigger()
```
