Debian Codegraph @

pymeasure/instruments/yokogawa/aq6370series.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2024 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23
24 import logging
25
26 from pymeasure.instruments import Instrument, SCPIMixin
27 from pymeasure.instruments.validators import strict_discrete_set, strict_range
28
29 log = logging.getLogger(__name__)
30 log.addHandler(logging.NullHandler())
31
32
33 class AQ6370Series(SCPIMixin, Instrument):
34 """Represents Yokogawa AQ6370 Series of optical spectrum analyzer."""
35
36 def __init__(self, adapter, name="Yokogawa AQ3670D OSA", **kwargs):
37 super().__init__(adapter, name, **kwargs)
38
39 # Initiate and abort sweep ---------------------------------------------------------------------
40
41 def abort(self):
42 """Stop operations such as measurements and calibration."""
43 self.write(":ABORt")
44
45 def initiate_sweep(self):
46 """Initiate a sweep."""
47 self.write(":INITiate:IMMediate")
48
49 # Leveling -------------------------------------------------------------------------------------
50
51 reference_level = Instrument.control(
52 ":DISPlay:TRACe:Y1:SCALe:RLEVel?",
53 ":DISPlay:TRACe:Y1:SCALe:RLEVel %g",
54 "Control the reference level of main scale of level axis (float in dBm).",
55 validator=strict_range,
56 values=[-90, 30],
57 )
58
59 level_position = Instrument.control(
60 ":DISPlay:TRACe:Y1:RPOSition?",
61 ":DISPlay:TRACe:Y1:RPOSition %g",
62 """Control the reference level position regarding divisions
63 (int, smaller than total number of divisions which is either 8, 10 or 12).""",
64 validator=strict_range,
65 values=[0, 12],
66 dynamic=True,
67 get_process=lambda x: int(x),
68 )
69
70 def set_level_position_to_max(self):
71 """Set the reference level position to the maximum value."""
72 self.write(":CALCulate:MARKer:MAXimum:SRLevel")
73
74 # Sweep settings -------------------------------------------------------------------------------
75
76 sweep_mode = Instrument.control(
77 ":INITiate:SMODe?",
78 ":INITiate:SMODe %s",
79 "Control the sweep mode (str 'SINGLE', 'REPEAT', 'AUTO', 'SEGMENT').",
80 validator=strict_discrete_set,
81 map_values=True,
82 values={"SINGLE": 1, "REPEAT": 2, "AUTO": 3, "SEGMENT": 4},
83 )
84
85 sweep_time_interval = Instrument.control(
86 ":SENSe:SWEep:TIME:INTerval?",
87 ":SENSe:SWEep:TIME:INTerval %g",
88 "Control the sweep time interval (int from 0 to 99999 s).",
89 validator=strict_range,
90 values=[0, 99999],
91 )
92
93 automatic_sample_number = Instrument.control(
94 ":SENSe:SWEep:POINts:AUTO?",
95 ":SENSe:SWEep:POINts:AUTO %d",
96 "Control the automatic sample number (bool).",
97 validator=strict_discrete_set,
98 map_values=True,
99 values={False: 0, True: 1},
100 )
101
102 sample_number = Instrument.control(
103 ":SENSe:SWEep:POINts?",
104 ":SENSe:SWEep:POINts %d",
105 "Control the sample number (int from 51 to 50001).",
106 validator=strict_range,
107 values=[101, 50001],
108 get_process=lambda x: int(x),
109 )
110
111 # Wavelength settings (all assuming wavelength mode, not frequency mode) -----------------------
112
113 wavelength_center = Instrument.control(
114 ":SENSe:WAVelength:CENTer?",
115 ":SENSe:WAVelength:CENTer %g",
116 "Control measurement condition center wavelength (float in m).",
117 validator=strict_range,
118 values=[600e-9, 1700e-9],
119 dynamic=True,
120 )
121
122 wavelength_span = Instrument.control(
123 ":SENSe:WAVelength:SPAN?",
124 ":SENSe:WAVelength:SPAN %g",
125 "Control wavelength span (float from 0 to 1100e-9 m).",
126 validator=strict_range,
127 values=[0, 1100e-9],
128 dynamic=True,
129 )
130
131 wavelength_start = Instrument.control(
132 ":SENSe:WAVelength:STARt?",
133 ":SENSe:WAVelength:STARt %g",
134 "Control the measurement start wavelength (float from 50e-9 to 2250e-9 in m).",
135 validator=strict_range,
136 values=[50e-9, 1700 - 9],
137 dynamic=True,
138 )
139
140 wavelength_stop = Instrument.control(
141 ":SENSe:WAVelength:STOP?",
142 ":SENSe:WAVelength:STOP %g",
143 "Control the measurement stop wavelength (float from 50e-9 to 2250e-9 in m).",
144 validator=strict_range,
145 values=[600e-9, 2250e-9],
146 dynamic=True,
147 )
148
149 # Trace operations -----------------------------------------------------------------------------
150
151 active_trace = Instrument.control(
152 ":TRACe:ACTive?",
153 ":TRACe:ACTive %d",
154 "Control the active trace (str 'A', 'B', 'C', ...).",
155 )
156
157 def copy_trace(self, source, destination):
158 """
159 Copy the data of specified trace to the another trace.
160
161 :param source: Source trace (str 'A', 'B', 'C', ...).
162 :param destination: Destination trace (str 'A', 'B', 'C', ...).
163 """
164
165 self.write(f":TRACe:COPY TR{source.replace('TR', '')},TR{destination.replace('TR', '')}")
166
167 def delete_trace(self, trace):
168 """
169 Delete the specified trace.
170
171 :param trace: Trace to be deleted (str 'ALL', 'A', 'B', 'C', ...).
172 """
173
174 if trace == "ALL":
175 self.write(":TRACe:DELete:ALL")
176 else:
177 self.write(f":TRACe:DELete TR{trace.replace('TR', '')}")
178
179 def get_xdata(self, trace="TRA"):
180 """
181 Measure the x-axis data of specified trace, output wavelength in m.
182
183 :param trace: Trace to measure (str 'A', 'B', 'C', ...).
184 :return: The x-axis data of specified trace.
185 """
186
187 return self.values(f":TRACe:X? TR{trace.replace('TR', '')}")
188
189 def get_ydata(self, trace="TRA"):
190 """
191 Measure the y-axis data of specified trace, output power in dBm.
192
193 :param trace: Trace to measure (str 'A', 'B', 'C', ...).
194 :return: The y-axis data of specified trace.
195 """
196
197 return self.values(f":TRACe:Y? TR{trace.replace('TR', '')}")
198
199 # Analysis -------------------------------------------------------------------------------------
200
201 def execute_analysis(self):
202 """Execute the analysis with the current analysis settings."""
203 self.write(":CALCulate")
204
205 def get_analysis(self):
206 """
207 Query the analysis results of latest analysis. If no analysis has been
208 performed, returns query error.
209 """
210 return self.write(":CALCulate:DATA?")
211
212 # Resolution -----------------------------------------------------------------------------------
213
214 resolution_bandwidth = Instrument.control(
215 ":SENSe:BWIDth:RESolution?",
216 ":SENSe:BWIDth:RESolution %g",
217 """Control the measurement resolution
218 (float in m, discrete values: [0.02e-9, 0.05e-9, 0.1e-9, 0.2e-9, 0.5e-9, 1e-9, 2e-9] m).""",
219 validator=strict_discrete_set,
220 values=[0.02e-9, 0.05e-9, 0.1e-9, 0.2e-9, 0.5e-9, 1e-9, 2e-9],
221 dynamic=True,
222 )
223
224
225 # subclasses of specific instruments ---------------------------------------------------------------
226
227
228 class AQ6370D(AQ6370Series):
229 """Represents Yokogawa AQ6370D optical spectrum analyzer."""
230
231 sweep_speed = Instrument.control(
232 ":SENSe:SWEep:SPEed?",
233 ":SENSe:SWEep:SPEed %d",
234 "Control the sweep speed (str '1x' or '2x' for double speed).",
235 validator=strict_discrete_set,
236 map_values=True,
237 values={"1x": 0, "2x": 1},
238 )
239 pass
240
241
242 class AQ6370C(AQ6370Series):
243 """Represents Yokogawa AQ6370C optical spectrum analyzer."""
244
245 sweep_speed = Instrument.control(
246 ":SENSe:SWEep:SPEed?",
247 ":SENSe:SWEep:SPEed %d",
248 "Control the sweep speed (str '1x' or '2x' for double speed).",
249 validator=strict_discrete_set,
250 map_values=True,
251 values={"1x": 0, "2x": 1},
252 )
253 pass
254
255
256 class AQ6373(AQ6370Series):
257 """Represents Yokogawa AQ6373 optical spectrum analyzer."""
258
259 wavelength_center_values = [350e-9, 1200e-9] # 0.001 steps
260 wavelength_start_values = [1e-9, 1200e-9] # 0.001 steps
261 wavelength_stop_values = [350e-9, 1625e-9] # 0.001 steps
262 wavelength_span_values = [0, 850e-9] # 0.1 steps
263 resolution_bandwidth_values = [
264 0.01e-9,
265 0.02e-9,
266 0.05e-9,
267 0.1e-9,
268 0.2e-9,
269 0.5e-9,
270 1e-9,
271 2e-9,
272 5e-9,
273 10e-9,
274 ]
275 pass
276
277
278 class AQ6373B(AQ6373):
279 """Represents Yokogawa AQ6373B variant optical spectrum analyzer."""
280
281 sweep_speed = Instrument.control(
282 ":SENSe:SWEep:SPEed?",
283 ":SENSe:SWEep:SPEed %d",
284 "Control the sweep speed (str '1x' or '2x' for double speed).",
285 validator=strict_discrete_set,
286 map_values=True,
287 values={"1x": 0, "2x": 1},
288 )
289 pass
290
291
292 class AQ6375(AQ6370Series):
293 """Represents Yokogawa AQ6375 optical spectrum analyzer."""
294
295 wavelength_center_values = [1200e-9, 2400e-9] # 0.001 steps
296 wavelength_start_values = [600e-9, 2400e-9] # 0.001 steps
297 wavelength_stop_values = [1200e-9, 3000e-9] # 0.001 steps
298 wavelength_span_values = [0, 1200e-9] # 0.1 steps
299 resolution_bandwidth_values = [
300 0.05e-9,
301 0.1e-9,
302 0.2e-9,
303 0.5e-9,
304 1e-9,
305 2e-9,
306 ]
307 pass
308
309
310 class AQ6375B(AQ6375):
311 """Represents Yokogawa AQ6375B variant optical spectrum analyzer."""
312
313 sweep_speed = Instrument.control(
314 ":SENSe:SWEep:SPEed?",
315 ":SENSe:SWEep:SPEed %d",
316 "Control the sweep speed (str '1x' or '2x' for double speed).",
317 validator=strict_discrete_set,
318 map_values=True,
319 values={"1x": 0, "2x": 1},
320 )
321 pass