Yokogawa AQ637x — Quick Example

This example demonstrates the main usage patterns of the YokogawaAQ637x driver: connecting to the instrument, configuring measurement parameters, triggering a sweep, reading and plotting trace data, and capturing instrument state via snapshots.

Note: Replace the VISA resource string with your instrument address before running.

1) Imports and Connection

[1]:
import json
import matplotlib.pyplot as plt
from qcodes_contrib_drivers.drivers.Yokogawa.Yokogawa_AQ637x import YokogawaAQ637x

# Connect to the instrument (replace address with your instrument's VISA resource string)
inst = YokogawaAQ637x("OSA", address="TCPIP::<instrument-ip>::INSTR")

print("Connected to:", inst.get_idn())

Connected to: {'vendor': 'YOKOGAWA', 'model': 'AQ6370C', 'serial': '91MC06547', 'firmware': '04.06'}

2) Configure Measurement and Trigger a Sweep

[2]:
# Configure measurement parameters
inst.sense_wavelength_start(1.0e-6)      # Start wavelength (m)
inst.sense_wavelength_stop(1.7e-6)       # Stop wavelength (m)
inst.sense_bandwidth_resolution(1e-9)    # Resolution bandwidth (m)
inst.sense_sensitivity('NORMAL_AUTO')    # Sensitivity mode

# Select active trace and perform a single sweep
inst.TRA.active()
inst.single()

print("Sweep complete.")

Sweep complete.

3) Read and Plot Trace Data

[ ]:
# Retrieve trace data
wavelengths = inst.TRA.trace_axis()  # X-axis in metres (wavelength, per unit_x)
levels = inst.TRA.data()             # Level data (typically dBm)

print(f"Data points: {len(wavelengths)}")
print(f"Wavelength range: {1e9 * wavelengths[0]:.2f} nm to {1e9 * wavelengths[-1]:.2f} nm")

# Plot
plt.figure(figsize=(10, 6))
plt.plot(1e9 * wavelengths, levels, linewidth=1)
plt.xlabel('Wavelength (nm)')
plt.ylabel('Level (dBm)')
plt.title('Yokogawa AQ637x Trace')
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()

4) Capture Instrument State via Snapshot

Use QCoDeS snapshot feature to capture the current state of all instrument parameters. This is useful for documentation and reproducibility of measurements.

[4]:
# Take a snapshot of the instrument state
snapshot = inst.snapshot(update=True)

# Display snapshot in human-readable format
inst.print_readable_snapshot()

# Optionally, save the full snapshot to a JSON file for later reference
with open("instrument_snapshot.json", "w") as f:
    json.dump(snapshot, f, indent=2, default=str)

print("\nFull snapshot saved to 'instrument_snapshot.json'")

[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: display_trace_y2_sminimum
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: trigger_gate_time
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: trigger_gate_slope
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: trigger_gate_state
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: system_fspeed
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: system_communicate_gpib2_address
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: system_communicate_gpib2_scontroller
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: system_communicate_gpib2_tls_address
[OSA(YokogawaAQ637x)] Snapshot: Could not update parameter: dlog_elapsed_time
OSA:
        parameter                                 value
--------------------------------------------------------------------------------
IDN                                        :    {'vendor': 'YOKOGAWA', 'model': ...
calibration_bandwidth_wavelength           :    0 (m)
calibration_wavelength_external_source     :    LASER
calibration_wavelength_external_wavelength :    1.5235e-06 (m)
calibration_zero_auto                      :    False
calibration_zero_interval                  :    10
calibration_zero_status                    :    0
display_color                              :    1
display_enabled                            :    True
display_overview_position                  :    RIGHT
display_overview_size                      :    LARGE
display_split                              :    False
display_split_hold_lower                   :    False
display_split_hold_upper                   :    False
display_text_data                          :    // AQ6370C OPTICAL SPECTRUM ANAL...
display_trace_x_center                     :    3.9972e+14 (m)
display_trace_x_span                       :    1.9986e+14 (m)
display_trace_x_srange                     :    True
display_trace_x_start                      :    2.9979e+14 (m)
display_trace_x_stop                       :    4.9965e+14 (m)
display_trace_y1_blevel                    :    0 (W)
display_trace_y1_pdivision                 :    10 (dB)
display_trace_y1_rlevel                    :    -10 (dBm)
display_trace_y1_rposition                 :    8 (DIV)
display_trace_y1_spacing                   :    LOG
display_trace_y1_unit                      :    DBM
display_trace_y2_auto                      :    False
display_trace_y2_length                    :    1 (km)
display_trace_y2_olevel                    :    0 (dB)
display_trace_y2_pdivision                 :    5 (dB)
display_trace_y2_rposition                 :    5 (DIV)
display_trace_y2_sminimum                  :    None (%)
display_trace_y2_unit                      :    DB
display_trace_y_dnumber                    :    10
display_trace_y_nmask                      :    -999 (dB)
display_trace_y_nmask_type                 :    HORIZONTAL
dlog_elapsed_time                          :    None (s)
dlog_interval                              :    5
dlog_item                                  :    2
dlog_lmode                                 :    2
dlog_memory                                :    INTERNAL
dlog_mthresh                               :    1e-09
dlog_pdetect_athresh                       :    -50
dlog_pdetect_rthresh                       :    3
dlog_pdetect_ttype                         :    RELATIVE
dlog_state                                 :    STOP
dlog_tduration                             :    60
dlog_tlogging                              :    True
event_status_enable                        :    251
event_status_register                      :    16
format_data                                :    REAL64
line_marker_srange                         :    False
marker_auto                                :    False
marker_function_format                     :    OFFSET
marker_function_update                     :    False
marker_maximum_scenter_auto                :    False
marker_maximum_srlevel_auto                :    False
marker_msearch                             :    False
marker_msearch_sort                        :    WAVELENGTH
marker_msearch_threshold                   :    50 (dB)
marker_unit                                :    FREQUENCY
operation_complete                         :    1
self_test                                  :    Not available
sense_average_count                        :    1
sense_bandwidth_resolution                 :    2e+11 (m)
sense_chopper                              :    OFF
sense_correction_level_shift               :    0 (dB)
sense_correction_rvelocity_medium          :    VACUUM
sense_correction_wavelength_shift          :    0 (m)
sense_sensitivity                          :    NORMAL_AUTO
sense_setting_correction                   :    OFF
sense_setting_fconnector                   :    NORMAL
sense_setting_smoothing                    :    False
sense_sweep_points                         :    2001
sense_sweep_points_auto                    :    True
sense_sweep_segment_points                 :    1
sense_sweep_speed                          :    1X
sense_sweep_step                           :    2e-10 (m)
sense_sweep_time_0nm                       :    0 (s)
sense_sweep_time_interval                  :    0 (s)
sense_sweep_tlssync                        :    False
sense_wavelength_center                    :    3.9972e+14 (m)
sense_wavelength_span                      :    1.9986e+14 (m)
sense_wavelength_srange                    :    False
sense_wavelength_start                     :    2.9979e+14 (m)
sense_wavelength_stop                      :    4.9965e+14 (m)
service_request_enable                     :    0
status_byte                                :    128
status_operation_condition                 :    1
status_operation_enable                    :    255
status_operation_event                     :    1
status_questionable_condition              :    0
status_questionable_enable                 :    128
status_questionable_event                  :    0
sweep_mode                                 :    SINGLE
system_buzzer_click                        :    True
system_buzzer_warning                      :    True
system_communicate_gpib2_address           :    None
system_communicate_gpib2_scontroller       :    None
system_communicate_gpib2_tls_address       :    None
system_communicate_lockout                 :    False
system_communicate_rmonitor                :    False
system_date                                :    2026,7,21
system_display_transparent                 :    True
system_display_uncal                       :    True
system_error                               :    Not available
system_fspeed                              :    None
system_grid                                :    CUSTOM
system_grid_custom_spacing                 :    50 (GHz)
system_grid_custom_start                   :    1.8737e+14 (m)
system_grid_custom_stop                    :    1.9986e+14 (m)
system_grid_reference                      :    1.9341e+14 (m)
system_time                                :    14:28:45
system_version                             :    1999.0
template_gonogo                            :    False
template_level_shift                       :    0 (dB)
template_result                            :    0
template_ttype                             :    UPPER_AND_LOWER
template_wavelength_shift                  :    0 (m)
timeout                                    :    5 (s)
trigger_delay                              :    0 (s)
trigger_gate_logic                         :    POSITIVE
trigger_gate_slope                         :    None
trigger_gate_state                         :    None
trigger_gate_time                          :    None (s)
trigger_input                              :    EXTERNAL_TRIGGER
trigger_output                             :    OFF
trigger_phold_htime                        :    0.01 (s)
unit_power_digit                           :    3
unit_x                                     :    FREQUENCY

Full snapshot saved to 'instrument_snapshot.json'

5) Cleanup

[5]:
inst.close()
print("Connection closed.")
Connection closed.