# R&S FSL spectrum analyzer

## Connecting to the instrument via network

Once connected to the network, the instrument’s IP address can be found by clicking the “Setup” button and navigating to “General Settings” -> “Network Address”.

It can then be connected like this:

    from pymeasure.instruments.rohdeschwarz import FSL
    fsl = FSL("TCPIP::192.168.1.123::INSTR")

## Getting and setting parameters

Most parameters are implemented as properties, which means they can be read and written (getting and setting) in a consistent and simple way. If numerical values are provided, base units are used (s, Hz, dB, …). Alternatively, the values can also be provided with a unit, e.g. `"1.5 GHz"` or `"1.5GHz"`. Return values are always numerical.

    # Getting the current center frequency
    fsl.freq_center

    9000000000.0

    # Changing it to 10 MHz by providing the numerical value
    fsl.freq_center = 10e6

    # Verifying:
    fsl.freq_center

    10000000.0

    # Changing it to 9 GHz by providing a string and verifying the result
    fsl.freq_center = '9GHz'
    fsl.freq_center

    9000000000.0

    # Setting the span to maximum
    fsl.freq_span = '7 GHz'

## Reading a trace

We will read the current trace

    x, y = fsl.read_trace()

## Markers

Markers are implemented as their own class. You can create them like this:

    m1 = fsl.create_marker()

Set peak exursion:

    m1.peak_excursion = 3

Set marker to a specific position:

    m1.x = 10e9

Find the next peak to the left and get the level:

    m1.to_next_peak('left')
    m1.y

    -34.9349060059

### Delta markers

Delta markers can be created by setting the appropriate keyword.

    d2 = fsl.create_marker(is_delta_marker=True)
    d2.name

    'DELT2'

## Example program

Here is an example of a simple script for recording the peak of a signal.

    m1 = fsl.create_marker() # create marker 1

    # Set standard settings, set to full span
    fsl.continuous_sweep = False
    fsl.freq_span = '18 GHz'
    fsl.res_bandwidth = "AUTO"
    fsl.video_bandwidth = "AUTO"
    fsl.sweep_time = "AUTO"

    # Perform a sweep on full span, set the marker to the peak and some to that marker
    fsl.single_sweep()
    m1.to_peak()
    m1.zoom('20 MHz')

    # take data from the zoomed-in region
    fsl.single_sweep()
    x, y = fsl.read_trace()

class pymeasure.instruments.rohdeschwarz.fsl.FSL(adapter, name='Rohde&Schwarz FSL', **kwargs)

  Bases: `SCPIMixin`, `Instrument`

  Represents a Rohde&Schwarz FSL spectrum analyzer.

  All physical values that can be set can either be as a string of a value and a unit (e.g. “1.2 GHz”) or as a float value in the base units (Hz, dBm, etc.).

  property attenuation

    Attenuation in dB.

  continue_single_sweep()

    Continue with single sweep with synchronization.

  property continuous_sweep

    Continuous (True) or single sweep (False)

  create_marker(num=1, is_delta_marker=False)

    Create a marker.

    Parameters:

      - num – The marker number (1-4)

      - is_delta_marker – True if the marker is a delta marker, default is False.

    Returns:

      The marker object.

  property freq_center

    Center frequency in Hz.

  property freq_span

    Frequency span in Hz.

  property freq_start

    Start frequency in Hz.

  property freq_stop

    Stop frequency in Hz.

  read_trace(n_trace=1)

    Read trace data.

    Parameters:

      n_trace – The trace number (1-6). Default is 1.

    Returns:

      2d numpy array of the trace data, [[frequency], [amplitude]].

  property res_bandwidth

    Resolution bandwidth in Hz. Can be set to ‘AUTO’

  single_sweep()

    Perform a single sweep with synchronization.

  property sweep_time

    Sweep time in s. Can be set to ‘AUTO’.

  property trace_mode

    Trace mode (‘WRIT’, ‘MAXH’, ‘MINH’, ‘AVER’ or ‘VIEW’)

  property video_bandwidth

    Video bandwidth in Hz. Can be set to ‘AUTO’