| Total Complexity | 48 | 
| Total Lines | 875 | 
| Duplicated Lines | 66.17 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like BasicPredefinedGenerator often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | # -*- coding: utf-8 -*-  | 
            ||
| 41 | class BasicPredefinedGenerator(PredefinedGeneratorBase):  | 
            ||
| 42 | """  | 
            ||
| 43 | |||
| 44 | """  | 
            ||
| 45 | def __init__(self, *args, **kwargs):  | 
            ||
| 46 | super().__init__(*args, **kwargs)  | 
            ||
| 47 | |||
| 48 | View Code Duplication | def generate_laser_on(self, name='laser_on', length=3.0e-6):  | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 49 | """ Generates Laser on.  | 
            ||
| 50 | |||
| 51 | @param str name: Name of the PulseBlockEnsemble  | 
            ||
| 52 | @param float length: laser duration in seconds  | 
            ||
| 53 | |||
| 54 | @return object: the generated PulseBlockEnsemble object.  | 
            ||
| 55 | """  | 
            ||
| 56 | created_blocks = list()  | 
            ||
| 57 | created_ensembles = list()  | 
            ||
| 58 | created_sequences = list()  | 
            ||
| 59 | |||
| 60 | # create the laser element  | 
            ||
| 61 | laser_element = self._get_laser_element(length=length, increment=0)  | 
            ||
| 62 | # Create block and append to created_blocks list  | 
            ||
| 63 | laser_block = PulseBlock(name=name)  | 
            ||
| 64 | laser_block.append(laser_element)  | 
            ||
| 65 | created_blocks.append(laser_block)  | 
            ||
| 66 | # Create block ensemble and append to created_ensembles list  | 
            ||
| 67 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=False)  | 
            ||
| 68 | block_ensemble.append((laser_block.name, 0))  | 
            ||
| 69 | created_ensembles.append(block_ensemble)  | 
            ||
| 70 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 71 | |||
| 72 | def generate_laser_mw_on(self, name='laser_mw_on', length=3.0e-6):  | 
            ||
| 73 | """ General generation method for laser on and microwave on generation.  | 
            ||
| 74 | |||
| 75 | @param string name: Name of the PulseBlockEnsemble to be generated  | 
            ||
| 76 | @param float length: Length of the PulseBlockEnsemble in seconds  | 
            ||
| 77 | |||
| 78 | @return object: the generated PulseBlockEnsemble object.  | 
            ||
| 79 | """  | 
            ||
| 80 | created_blocks = list()  | 
            ||
| 81 | created_ensembles = list()  | 
            ||
| 82 | created_sequences = list()  | 
            ||
| 83 | |||
| 84 | # create the laser_mw element  | 
            ||
| 85 | laser_mw_element = self._get_mw_laser_element(length=length,  | 
            ||
| 86 | increment=0,  | 
            ||
| 87 | amp=self.microwave_amplitude,  | 
            ||
| 88 | freq=self.microwave_frequency,  | 
            ||
| 89 | phase=0)  | 
            ||
| 90 | # Create block and append to created_blocks list  | 
            ||
| 91 | laser_mw_block = PulseBlock(name=name)  | 
            ||
| 92 | laser_mw_block.append(laser_mw_element)  | 
            ||
| 93 | created_blocks.append(laser_mw_block)  | 
            ||
| 94 | # Create block ensemble and append to created_ensembles list  | 
            ||
| 95 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=False)  | 
            ||
| 96 | block_ensemble.append((laser_mw_block.name, 0))  | 
            ||
| 97 | created_ensembles.append(block_ensemble)  | 
            ||
| 98 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 99 | |||
| 100 | View Code Duplication | def generate_idle(self, name='idle', length=3.0e-6):  | 
            |
| 101 | """ Generate just a simple idle ensemble.  | 
            ||
| 102 | |||
| 103 | @param str name: Name of the PulseBlockEnsemble to be generated  | 
            ||
| 104 | @param float length: Length of the PulseBlockEnsemble in seconds  | 
            ||
| 105 | |||
| 106 | @return object: the generated PulseBlockEnsemble object.  | 
            ||
| 107 | """  | 
            ||
| 108 | created_blocks = list()  | 
            ||
| 109 | created_ensembles = list()  | 
            ||
| 110 | created_sequences = list()  | 
            ||
| 111 | |||
| 112 | # create the laser_mw element  | 
            ||
| 113 | idle_element = self._get_idle_element(length=length, increment=0)  | 
            ||
| 114 | # Create block and append to created_blocks list  | 
            ||
| 115 | idle_block = PulseBlock(name=name)  | 
            ||
| 116 | idle_block.append(idle_element)  | 
            ||
| 117 | created_blocks.append(idle_block)  | 
            ||
| 118 | # Create block ensemble and append to created_ensembles list  | 
            ||
| 119 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=False)  | 
            ||
| 120 | block_ensemble.append((idle_block.name, 0))  | 
            ||
| 121 | created_ensembles.append(block_ensemble)  | 
            ||
| 122 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 123 | |||
| 124 | View Code Duplication | def generate_rabi(self, name='rabi', tau_start=10.0e-9, tau_step=10.0e-9, number_of_taus=50):  | 
            |
| 125 | """  | 
            ||
| 126 | |||
| 127 | """  | 
            ||
| 128 | created_blocks = list()  | 
            ||
| 129 | created_ensembles = list()  | 
            ||
| 130 | created_sequences = list()  | 
            ||
| 131 | |||
| 132 | # get tau array for measurement ticks  | 
            ||
| 133 | tau_array = tau_start + np.arange(number_of_taus) * tau_step  | 
            ||
| 134 | |||
| 135 | # create the laser_mw element  | 
            ||
| 136 | mw_element = self._get_mw_element(length=tau_start,  | 
            ||
| 137 | increment=tau_step,  | 
            ||
| 138 | amp=self.microwave_amplitude,  | 
            ||
| 139 | freq=self.microwave_frequency,  | 
            ||
| 140 | phase=0)  | 
            ||
| 141 | waiting_element = self._get_idle_element(length=self.wait_time,  | 
            ||
| 142 | increment=0)  | 
            ||
| 143 | laser_element = self._get_laser_gate_element(length=self.laser_length,  | 
            ||
| 144 | increment=0)  | 
            ||
| 145 | delay_element = self._get_delay_gate_element()  | 
            ||
| 146 | |||
| 147 | # Create block and append to created_blocks list  | 
            ||
| 148 | rabi_block = PulseBlock(name=name)  | 
            ||
| 149 | rabi_block.append(mw_element)  | 
            ||
| 150 | rabi_block.append(laser_element)  | 
            ||
| 151 | rabi_block.append(delay_element)  | 
            ||
| 152 | rabi_block.append(waiting_element)  | 
            ||
| 153 | created_blocks.append(rabi_block)  | 
            ||
| 154 | |||
| 155 | # Create block ensemble  | 
            ||
| 156 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=False)  | 
            ||
| 157 | block_ensemble.append((rabi_block.name, number_of_taus - 1))  | 
            ||
| 158 | |||
| 159 | # Create and append sync trigger block if needed  | 
            ||
| 160 | if self.sync_channel:  | 
            ||
| 161 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 162 | sync_block.append(self._get_sync_element())  | 
            ||
| 163 | created_blocks.append(sync_block)  | 
            ||
| 164 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 165 | |||
| 166 | # add metadata to invoke settings later on  | 
            ||
| 167 | block_ensemble.measurement_information['alternating'] = False  | 
            ||
| 168 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 169 | block_ensemble.measurement_information['controlled_variable'] = tau_array  | 
            ||
| 170 |         block_ensemble.measurement_information['units'] = ('s', '') | 
            ||
| 171 | block_ensemble.measurement_information['number_of_lasers'] = number_of_taus  | 
            ||
| 172 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 173 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 174 | |||
| 175 | # Append ensemble to created_ensembles list  | 
            ||
| 176 | created_ensembles.append(block_ensemble)  | 
            ||
| 177 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 178 | |||
| 179 | View Code Duplication | def generate_pulsedodmr(self, name='pulsedODMR', freq_start=2870.0e6, freq_step=0.2e6,  | 
            |
| 180 | num_of_points=50):  | 
            ||
| 181 | """  | 
            ||
| 182 | |||
| 183 | """  | 
            ||
| 184 | created_blocks = list()  | 
            ||
| 185 | created_ensembles = list()  | 
            ||
| 186 | created_sequences = list()  | 
            ||
| 187 | |||
| 188 | # Create frequency array  | 
            ||
| 189 | freq_array = freq_start + np.arange(num_of_points) * freq_step  | 
            ||
| 190 | |||
| 191 | # create the elements  | 
            ||
| 192 | waiting_element = self._get_idle_element(length=self.wait_time,  | 
            ||
| 193 | increment=0)  | 
            ||
| 194 | laser_element = self._get_laser_gate_element(length=self.laser_length,  | 
            ||
| 195 | increment=0)  | 
            ||
| 196 | delay_element = self._get_delay_gate_element()  | 
            ||
| 197 | |||
| 198 | # Create block and append to created_blocks list  | 
            ||
| 199 | pulsedodmr_block = PulseBlock(name=name)  | 
            ||
| 200 | for mw_freq in freq_array:  | 
            ||
| 201 | mw_element = self._get_mw_element(length=self.rabi_period / 2,  | 
            ||
| 202 | increment=0,  | 
            ||
| 203 | amp=self.microwave_amplitude,  | 
            ||
| 204 | freq=mw_freq,  | 
            ||
| 205 | phase=0)  | 
            ||
| 206 | pulsedodmr_block.append(mw_element)  | 
            ||
| 207 | pulsedodmr_block.append(laser_element)  | 
            ||
| 208 | pulsedodmr_block.append(delay_element)  | 
            ||
| 209 | pulsedodmr_block.append(waiting_element)  | 
            ||
| 210 | created_blocks.append(pulsedodmr_block)  | 
            ||
| 211 | |||
| 212 | # Create block ensemble  | 
            ||
| 213 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=False)  | 
            ||
| 214 | block_ensemble.append((pulsedodmr_block.name, 0))  | 
            ||
| 215 | |||
| 216 | # Create and append sync trigger block if needed  | 
            ||
| 217 | if self.sync_channel:  | 
            ||
| 218 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 219 | sync_block.append(self._get_sync_element())  | 
            ||
| 220 | created_blocks.append(sync_block)  | 
            ||
| 221 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 222 | |||
| 223 | # add metadata to invoke settings later on  | 
            ||
| 224 | block_ensemble.measurement_information['alternating'] = False  | 
            ||
| 225 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 226 | block_ensemble.measurement_information['controlled_variable'] = freq_array  | 
            ||
| 227 |         block_ensemble.measurement_information['units'] = ('Hz', '') | 
            ||
| 228 | block_ensemble.measurement_information['number_of_lasers'] = num_of_points  | 
            ||
| 229 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 230 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 231 | |||
| 232 | # append ensemble to created ensembles  | 
            ||
| 233 | created_ensembles.append(block_ensemble)  | 
            ||
| 234 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 235 | |||
| 236 | def generate_ramsey(self, name='ramsey', tau_start=1.0e-6, tau_step=1.0e-6, num_of_points=50,  | 
            ||
| 237 | alternating=True):  | 
            ||
| 238 | """  | 
            ||
| 239 | |||
| 240 | """  | 
            ||
| 241 | created_blocks = list()  | 
            ||
| 242 | created_ensembles = list()  | 
            ||
| 243 | created_sequences = list()  | 
            ||
| 244 | |||
| 245 | # get tau array for measurement ticks  | 
            ||
| 246 | tau_array = tau_start + np.arange(num_of_points) * tau_step  | 
            ||
| 247 | |||
| 248 | # create the elements  | 
            ||
| 249 | waiting_element = self._get_idle_element(length=self.wait_time,  | 
            ||
| 250 | increment=0)  | 
            ||
| 251 | laser_element = self._get_laser_gate_element(length=self.laser_length,  | 
            ||
| 252 | increment=0)  | 
            ||
| 253 | delay_element = self._get_delay_gate_element()  | 
            ||
| 254 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 255 | increment=0,  | 
            ||
| 256 | amp=self.microwave_amplitude,  | 
            ||
| 257 | freq=self.microwave_frequency,  | 
            ||
| 258 | phase=0)  | 
            ||
| 259 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 260 |         if self.microwave_channel.startswith('a'): | 
            ||
| 261 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 262 | increment=0,  | 
            ||
| 263 | amp=self.microwave_amplitude,  | 
            ||
| 264 | freq=self.microwave_frequency,  | 
            ||
| 265 | phase=180)  | 
            ||
| 266 | else:  | 
            ||
| 267 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 268 | increment=0,  | 
            ||
| 269 | amp=self.microwave_amplitude,  | 
            ||
| 270 | freq=self.microwave_frequency,  | 
            ||
| 271 | phase=0)  | 
            ||
| 272 | tau_element = self._get_idle_element(length=tau_start, increment=tau_step)  | 
            ||
| 273 | |||
| 274 | # Create block and append to created_blocks list  | 
            ||
| 275 | ramsey_block = PulseBlock(name=name)  | 
            ||
| 276 | ramsey_block.append(pihalf_element)  | 
            ||
| 277 | ramsey_block.append(tau_element)  | 
            ||
| 278 | ramsey_block.append(pihalf_element)  | 
            ||
| 279 | ramsey_block.append(laser_element)  | 
            ||
| 280 | ramsey_block.append(delay_element)  | 
            ||
| 281 | ramsey_block.append(waiting_element)  | 
            ||
| 282 | if alternating:  | 
            ||
| 283 | ramsey_block.append(pihalf_element)  | 
            ||
| 284 | ramsey_block.append(tau_element)  | 
            ||
| 285 | ramsey_block.append(pi3half_element)  | 
            ||
| 286 | ramsey_block.append(laser_element)  | 
            ||
| 287 | ramsey_block.append(delay_element)  | 
            ||
| 288 | ramsey_block.append(waiting_element)  | 
            ||
| 289 | created_blocks.append(ramsey_block)  | 
            ||
| 290 | |||
| 291 | # Create block ensemble  | 
            ||
| 292 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 293 | block_ensemble.append((ramsey_block.name, num_of_points - 1))  | 
            ||
| 294 | |||
| 295 | # Create and append sync trigger block if needed  | 
            ||
| 296 | if self.sync_channel:  | 
            ||
| 297 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 298 | sync_block.append(self._get_sync_element())  | 
            ||
| 299 | created_blocks.append(sync_block)  | 
            ||
| 300 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 301 | |||
| 302 | # add metadata to invoke settings later on  | 
            ||
| 303 | number_of_lasers = 2 * num_of_points if alternating else num_of_points  | 
            ||
| 304 | block_ensemble.measurement_information['alternating'] = alternating  | 
            ||
| 305 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 306 | block_ensemble.measurement_information['controlled_variable'] = tau_array  | 
            ||
| 307 |         block_ensemble.measurement_information['units'] = ('s', '') | 
            ||
| 308 | block_ensemble.measurement_information['number_of_lasers'] = number_of_lasers  | 
            ||
| 309 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 310 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 311 | |||
| 312 | # append ensemble to created ensembles  | 
            ||
| 313 | created_ensembles.append(block_ensemble)  | 
            ||
| 314 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 315 | |||
| 316 | def generate_hahnecho(self, name='hahn_echo', tau_start=1.0e-6, tau_step=1.0e-6,  | 
            ||
| 317 | num_of_points=50, alternating=True):  | 
            ||
| 318 | """  | 
            ||
| 319 | |||
| 320 | """  | 
            ||
| 321 | created_blocks = list()  | 
            ||
| 322 | created_ensembles = list()  | 
            ||
| 323 | created_sequences = list()  | 
            ||
| 324 | |||
| 325 | # get tau array for measurement ticks  | 
            ||
| 326 | tau_array = tau_start + np.arange(num_of_points) * tau_step  | 
            ||
| 327 | |||
| 328 | # create the elements  | 
            ||
| 329 | waiting_element = self._get_idle_element(length=self.wait_time,  | 
            ||
| 330 | increment=0)  | 
            ||
| 331 | laser_element = self._get_laser_gate_element(length=self.laser_length,  | 
            ||
| 332 | increment=0)  | 
            ||
| 333 | delay_element = self._get_delay_gate_element()  | 
            ||
| 334 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 335 | increment=0,  | 
            ||
| 336 | amp=self.microwave_amplitude,  | 
            ||
| 337 | freq=self.microwave_frequency,  | 
            ||
| 338 | phase=0)  | 
            ||
| 339 | pi_element = self._get_mw_element(length=self.rabi_period / 2,  | 
            ||
| 340 | increment=0,  | 
            ||
| 341 | amp=self.microwave_amplitude,  | 
            ||
| 342 | freq=self.microwave_frequency,  | 
            ||
| 343 | phase=0)  | 
            ||
| 344 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 345 |         if self.microwave_channel.startswith('a'): | 
            ||
| 346 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 347 | increment=0,  | 
            ||
| 348 | amp=self.microwave_amplitude,  | 
            ||
| 349 | freq=self.microwave_frequency,  | 
            ||
| 350 | phase=180)  | 
            ||
| 351 | else:  | 
            ||
| 352 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 353 | increment=0,  | 
            ||
| 354 | amp=self.microwave_amplitude,  | 
            ||
| 355 | freq=self.microwave_frequency,  | 
            ||
| 356 | phase=0)  | 
            ||
| 357 | tau_element = self._get_idle_element(length=tau_start, increment=tau_step)  | 
            ||
| 358 | |||
| 359 | # Create block and append to created_blocks list  | 
            ||
| 360 | hahn_block = PulseBlock(name=name)  | 
            ||
| 361 | hahn_block.append(pihalf_element)  | 
            ||
| 362 | hahn_block.append(tau_element)  | 
            ||
| 363 | hahn_block.append(pi_element)  | 
            ||
| 364 | hahn_block.append(tau_element)  | 
            ||
| 365 | hahn_block.append(pihalf_element)  | 
            ||
| 366 | hahn_block.append(laser_element)  | 
            ||
| 367 | hahn_block.append(delay_element)  | 
            ||
| 368 | hahn_block.append(waiting_element)  | 
            ||
| 369 | if alternating:  | 
            ||
| 370 | hahn_block.append(pihalf_element)  | 
            ||
| 371 | hahn_block.append(tau_element)  | 
            ||
| 372 | hahn_block.append(pi_element)  | 
            ||
| 373 | hahn_block.append(tau_element)  | 
            ||
| 374 | hahn_block.append(pi3half_element)  | 
            ||
| 375 | hahn_block.append(laser_element)  | 
            ||
| 376 | hahn_block.append(delay_element)  | 
            ||
| 377 | hahn_block.append(waiting_element)  | 
            ||
| 378 | created_blocks.append(hahn_block)  | 
            ||
| 379 | |||
| 380 | # Create block ensemble  | 
            ||
| 381 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 382 | block_ensemble.append((hahn_block.name, num_of_points - 1))  | 
            ||
| 383 | |||
| 384 | # Create and append sync trigger block if needed  | 
            ||
| 385 | if self.sync_channel:  | 
            ||
| 386 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 387 | sync_block.append(self._get_sync_element())  | 
            ||
| 388 | created_blocks.append(sync_block)  | 
            ||
| 389 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 390 | |||
| 391 | # add metadata to invoke settings later on  | 
            ||
| 392 | number_of_lasers = 2 * num_of_points if alternating else num_of_points  | 
            ||
| 393 | block_ensemble.measurement_information['alternating'] = alternating  | 
            ||
| 394 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 395 | block_ensemble.measurement_information['controlled_variable'] = tau_array  | 
            ||
| 396 |         block_ensemble.measurement_information['units'] = ('s', '') | 
            ||
| 397 | block_ensemble.measurement_information['number_of_lasers'] = number_of_lasers  | 
            ||
| 398 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 399 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 400 | |||
| 401 | # append ensemble to created ensembles  | 
            ||
| 402 | created_ensembles.append(block_ensemble)  | 
            ||
| 403 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 404 | |||
| 405 | View Code Duplication | def generate_HHamp(self, name='hh_amp', spinlock_length=20e-6, amp_start=0.05, amp_step=0.01,  | 
            |
| 406 | num_of_points=50):  | 
            ||
| 407 | """  | 
            ||
| 408 | |||
| 409 | """  | 
            ||
| 410 | created_blocks = list()  | 
            ||
| 411 | created_ensembles = list()  | 
            ||
| 412 | created_sequences = list()  | 
            ||
| 413 | |||
| 414 | # get amplitude array for measurement ticks  | 
            ||
| 415 | amp_array = amp_start + np.arange(num_of_points) * amp_step  | 
            ||
| 416 | |||
| 417 | # create the elements  | 
            ||
| 418 | waiting_element = self._get_idle_element(length=self.wait_time, increment=0)  | 
            ||
| 419 | laser_element = self._get_laser_gate_element(length=self.laser_length, increment=0)  | 
            ||
| 420 | delay_element = self._get_delay_gate_element()  | 
            ||
| 421 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 422 | increment=0,  | 
            ||
| 423 | amp=self.microwave_amplitude,  | 
            ||
| 424 | freq=self.microwave_frequency,  | 
            ||
| 425 | phase=0)  | 
            ||
| 426 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 427 |         if self.microwave_channel.startswith('a'): | 
            ||
| 428 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 429 | increment=0,  | 
            ||
| 430 | amp=self.microwave_amplitude,  | 
            ||
| 431 | freq=self.microwave_frequency,  | 
            ||
| 432 | phase=180)  | 
            ||
| 433 | else:  | 
            ||
| 434 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 435 | increment=0,  | 
            ||
| 436 | amp=self.microwave_amplitude,  | 
            ||
| 437 | freq=self.microwave_frequency,  | 
            ||
| 438 | phase=0)  | 
            ||
| 439 | |||
| 440 | # Create block and append to created_blocks list  | 
            ||
| 441 | hhamp_block = PulseBlock(name=name)  | 
            ||
| 442 | for sl_amp in amp_array:  | 
            ||
| 443 | sl_element = self._get_mw_element(length=spinlock_length,  | 
            ||
| 444 | increment=0,  | 
            ||
| 445 | amp=sl_amp,  | 
            ||
| 446 | freq=self.microwave_frequency,  | 
            ||
| 447 | phase=90)  | 
            ||
| 448 | hhamp_block.append(pihalf_element)  | 
            ||
| 449 | hhamp_block.append(sl_element)  | 
            ||
| 450 | hhamp_block.append(pihalf_element)  | 
            ||
| 451 | hhamp_block.append(laser_element)  | 
            ||
| 452 | hhamp_block.append(delay_element)  | 
            ||
| 453 | hhamp_block.append(waiting_element)  | 
            ||
| 454 | |||
| 455 | hhamp_block.append(pi3half_element)  | 
            ||
| 456 | hhamp_block.append(sl_element)  | 
            ||
| 457 | hhamp_block.append(pihalf_element)  | 
            ||
| 458 | hhamp_block.append(laser_element)  | 
            ||
| 459 | hhamp_block.append(delay_element)  | 
            ||
| 460 | hhamp_block.append(waiting_element)  | 
            ||
| 461 | created_blocks.append(hhamp_block)  | 
            ||
| 462 | |||
| 463 | # Create block ensemble  | 
            ||
| 464 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 465 | block_ensemble.append((hhamp_block.name, 0))  | 
            ||
| 466 | |||
| 467 | # Create and append sync trigger block if needed  | 
            ||
| 468 | if self.sync_channel:  | 
            ||
| 469 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 470 | sync_block.append(self._get_sync_element())  | 
            ||
| 471 | created_blocks.append(sync_block)  | 
            ||
| 472 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 473 | |||
| 474 | # add metadata to invoke settings later on  | 
            ||
| 475 | block_ensemble.measurement_information['alternating'] = True  | 
            ||
| 476 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 477 | block_ensemble.measurement_information['controlled_variable'] = amp_array  | 
            ||
| 478 |         block_ensemble.measurement_information['units'] = ('V', '') | 
            ||
| 479 | block_ensemble.measurement_information['number_of_lasers'] = 2 * num_of_points  | 
            ||
| 480 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 481 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 482 | |||
| 483 | # append ensemble to created ensembles  | 
            ||
| 484 | created_ensembles.append(block_ensemble)  | 
            ||
| 485 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 486 | |||
| 487 | View Code Duplication | def generate_HHtau(self, name='hh_tau', spinlock_amp=0.1, tau_start=1e-6, tau_step=1e-6,  | 
            |
| 488 | num_of_points=50):  | 
            ||
| 489 | """  | 
            ||
| 490 | |||
| 491 | """  | 
            ||
| 492 | created_blocks = list()  | 
            ||
| 493 | created_ensembles = list()  | 
            ||
| 494 | created_sequences = list()  | 
            ||
| 495 | |||
| 496 | # get tau array for measurement ticks  | 
            ||
| 497 | tau_array = tau_start + np.arange(num_of_points) * tau_step  | 
            ||
| 498 | |||
| 499 | # create the elements  | 
            ||
| 500 | waiting_element = self._get_idle_element(length=self.wait_time, increment=0)  | 
            ||
| 501 | laser_element = self._get_laser_gate_element(length=self.laser_length, increment=0)  | 
            ||
| 502 | delay_element = self._get_delay_gate_element()  | 
            ||
| 503 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 504 | increment=0,  | 
            ||
| 505 | amp=self.microwave_amplitude,  | 
            ||
| 506 | freq=self.microwave_frequency,  | 
            ||
| 507 | phase=0)  | 
            ||
| 508 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 509 |         if self.microwave_channel.startswith('a'): | 
            ||
| 510 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 511 | increment=0,  | 
            ||
| 512 | amp=self.microwave_amplitude,  | 
            ||
| 513 | freq=self.microwave_frequency,  | 
            ||
| 514 | phase=180)  | 
            ||
| 515 | else:  | 
            ||
| 516 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 517 | increment=0,  | 
            ||
| 518 | amp=self.microwave_amplitude,  | 
            ||
| 519 | freq=self.microwave_frequency,  | 
            ||
| 520 | phase=0)  | 
            ||
| 521 | sl_element = self._get_mw_element(length=tau_start,  | 
            ||
| 522 | increment=tau_step,  | 
            ||
| 523 | amp=spinlock_amp,  | 
            ||
| 524 | freq=self.microwave_frequency,  | 
            ||
| 525 | phase=90)  | 
            ||
| 526 | |||
| 527 | # Create block and append to created_blocks list  | 
            ||
| 528 | hhtau_block = PulseBlock(name=name)  | 
            ||
| 529 | hhtau_block.append(pihalf_element)  | 
            ||
| 530 | hhtau_block.append(sl_element)  | 
            ||
| 531 | hhtau_block.append(pihalf_element)  | 
            ||
| 532 | hhtau_block.append(laser_element)  | 
            ||
| 533 | hhtau_block.append(delay_element)  | 
            ||
| 534 | hhtau_block.append(waiting_element)  | 
            ||
| 535 | |||
| 536 | hhtau_block.append(pi3half_element)  | 
            ||
| 537 | hhtau_block.append(sl_element)  | 
            ||
| 538 | hhtau_block.append(pihalf_element)  | 
            ||
| 539 | hhtau_block.append(laser_element)  | 
            ||
| 540 | hhtau_block.append(delay_element)  | 
            ||
| 541 | hhtau_block.append(waiting_element)  | 
            ||
| 542 | created_blocks.append(hhtau_block)  | 
            ||
| 543 | |||
| 544 | # Create block ensemble  | 
            ||
| 545 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 546 | block_ensemble.append((hhtau_block.name, num_of_points - 1))  | 
            ||
| 547 | |||
| 548 | # Create and append sync trigger block if needed  | 
            ||
| 549 | if self.sync_channel:  | 
            ||
| 550 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 551 | sync_block.append(self._get_sync_element())  | 
            ||
| 552 | created_blocks.append(sync_block)  | 
            ||
| 553 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 554 | |||
| 555 | # add metadata to invoke settings later on  | 
            ||
| 556 | block_ensemble.measurement_information['alternating'] = True  | 
            ||
| 557 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 558 | block_ensemble.measurement_information['controlled_variable'] = tau_array  | 
            ||
| 559 |         block_ensemble.measurement_information['units'] = ('s', '') | 
            ||
| 560 | block_ensemble.measurement_information['number_of_lasers'] = 2 * num_of_points  | 
            ||
| 561 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 562 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 563 | |||
| 564 | # append ensemble to created ensembles  | 
            ||
| 565 | created_ensembles.append(block_ensemble)  | 
            ||
| 566 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 567 | |||
| 568 | def generate_HHpol(self, name='hh_pol', spinlock_length=20.0e-6, spinlock_amp=0.1,  | 
            ||
| 569 | polarization_steps=50):  | 
            ||
| 570 | """  | 
            ||
| 571 | |||
| 572 | """  | 
            ||
| 573 | created_blocks = list()  | 
            ||
| 574 | created_ensembles = list()  | 
            ||
| 575 | created_sequences = list()  | 
            ||
| 576 | |||
| 577 | # get steps array for measurement ticks  | 
            ||
| 578 | steps_array = np.arange(2 * polarization_steps)  | 
            ||
| 579 | |||
| 580 | # create the elements  | 
            ||
| 581 | waiting_element = self._get_idle_element(length=self.wait_time, increment=0)  | 
            ||
| 582 | laser_element = self._get_laser_gate_element(length=self.laser_length, increment=0)  | 
            ||
| 583 | delay_element = self._get_delay_gate_element()  | 
            ||
| 584 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 585 | increment=0,  | 
            ||
| 586 | amp=self.microwave_amplitude,  | 
            ||
| 587 | freq=self.microwave_frequency,  | 
            ||
| 588 | phase=0)  | 
            ||
| 589 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 590 |         if self.microwave_channel.startswith('a'): | 
            ||
| 591 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 592 | increment=0,  | 
            ||
| 593 | amp=self.microwave_amplitude,  | 
            ||
| 594 | freq=self.microwave_frequency,  | 
            ||
| 595 | phase=180)  | 
            ||
| 596 | else:  | 
            ||
| 597 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 598 | increment=0,  | 
            ||
| 599 | amp=self.microwave_amplitude,  | 
            ||
| 600 | freq=self.microwave_frequency,  | 
            ||
| 601 | phase=0)  | 
            ||
| 602 | sl_element = self._get_mw_element(length=spinlock_length,  | 
            ||
| 603 | increment=0,  | 
            ||
| 604 | amp=spinlock_amp,  | 
            ||
| 605 | freq=self.microwave_frequency,  | 
            ||
| 606 | phase=90)  | 
            ||
| 607 | |||
| 608 | # Create block for "up"-polarization and append to created_blocks list  | 
            ||
| 609 | up_block = PulseBlock(name=name + '_up')  | 
            ||
| 610 | up_block.append(pihalf_element)  | 
            ||
| 611 | up_block.append(sl_element)  | 
            ||
| 612 | up_block.append(pihalf_element)  | 
            ||
| 613 | up_block.append(laser_element)  | 
            ||
| 614 | up_block.append(delay_element)  | 
            ||
| 615 | up_block.append(waiting_element)  | 
            ||
| 616 | created_blocks.append(up_block)  | 
            ||
| 617 | |||
| 618 | # Create block for "down"-polarization and append to created_blocks list  | 
            ||
| 619 | down_block = PulseBlock(name=name + '_down')  | 
            ||
| 620 | down_block.append(pi3half_element)  | 
            ||
| 621 | down_block.append(sl_element)  | 
            ||
| 622 | down_block.append(pi3half_element)  | 
            ||
| 623 | down_block.append(laser_element)  | 
            ||
| 624 | down_block.append(delay_element)  | 
            ||
| 625 | down_block.append(waiting_element)  | 
            ||
| 626 | created_blocks.append(down_block)  | 
            ||
| 627 | |||
| 628 | # Create block ensemble  | 
            ||
| 629 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 630 | block_ensemble.append((up_block.name, polarization_steps - 1))  | 
            ||
| 631 | block_ensemble.append((down_block.name, polarization_steps - 1))  | 
            ||
| 632 | |||
| 633 | # Create and append sync trigger block if needed  | 
            ||
| 634 | if self.sync_channel:  | 
            ||
| 635 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 636 | sync_block.append(self._get_sync_element())  | 
            ||
| 637 | created_blocks.append(sync_block)  | 
            ||
| 638 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 639 | |||
| 640 | # add metadata to invoke settings later on  | 
            ||
| 641 | block_ensemble.measurement_information['alternating'] = False  | 
            ||
| 642 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 643 | block_ensemble.measurement_information['controlled_variable'] = steps_array  | 
            ||
| 644 |         block_ensemble.measurement_information['units'] = ('#', '') | 
            ||
| 645 | block_ensemble.measurement_information['number_of_lasers'] = 2 * polarization_steps  | 
            ||
| 646 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 647 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 648 | |||
| 649 | # append ensemble to created ensembles  | 
            ||
| 650 | created_ensembles.append(block_ensemble)  | 
            ||
| 651 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 652 | |||
| 653 | View Code Duplication | def generate_xy8_tau(self, name='xy8_tau', tau_start=0.5e-6, tau_step=0.01e-6, num_of_points=50,  | 
            |
| 654 | xy8_order=4, alternating=True):  | 
            ||
| 655 | """  | 
            ||
| 656 | |||
| 657 | """  | 
            ||
| 658 | created_blocks = list()  | 
            ||
| 659 | created_ensembles = list()  | 
            ||
| 660 | created_sequences = list()  | 
            ||
| 661 | |||
| 662 | # get tau array for measurement ticks  | 
            ||
| 663 | tau_array = tau_start + np.arange(num_of_points) * tau_step  | 
            ||
| 664 | # calculate "real" start length of tau due to finite pi-pulse length  | 
            ||
| 665 | real_start_tau = max(0, tau_start - self.rabi_period / 2)  | 
            ||
| 666 | |||
| 667 | # create the elements  | 
            ||
| 668 | waiting_element = self._get_idle_element(length=self.wait_time, increment=0)  | 
            ||
| 669 | laser_element = self._get_laser_gate_element(length=self.laser_length, increment=0)  | 
            ||
| 670 | delay_element = self._get_delay_gate_element()  | 
            ||
| 671 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 672 | increment=0,  | 
            ||
| 673 | amp=self.microwave_amplitude,  | 
            ||
| 674 | freq=self.microwave_frequency,  | 
            ||
| 675 | phase=0)  | 
            ||
| 676 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 677 |         if self.microwave_channel.startswith('a'): | 
            ||
| 678 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 679 | increment=0,  | 
            ||
| 680 | amp=self.microwave_amplitude,  | 
            ||
| 681 | freq=self.microwave_frequency,  | 
            ||
| 682 | phase=180)  | 
            ||
| 683 | else:  | 
            ||
| 684 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 685 | increment=0,  | 
            ||
| 686 | amp=self.microwave_amplitude,  | 
            ||
| 687 | freq=self.microwave_frequency,  | 
            ||
| 688 | phase=0)  | 
            ||
| 689 | pix_element = self._get_mw_element(length=self.rabi_period / 2,  | 
            ||
| 690 | increment=0,  | 
            ||
| 691 | amp=self.microwave_amplitude,  | 
            ||
| 692 | freq=self.microwave_frequency,  | 
            ||
| 693 | phase=0)  | 
            ||
| 694 | piy_element = self._get_mw_element(length=self.rabi_period / 2,  | 
            ||
| 695 | increment=0,  | 
            ||
| 696 | amp=self.microwave_amplitude,  | 
            ||
| 697 | freq=self.microwave_frequency,  | 
            ||
| 698 | phase=90)  | 
            ||
| 699 | tauhalf_element = self._get_idle_element(length=real_start_tau / 2, increment=tau_step / 2)  | 
            ||
| 700 | tau_element = self._get_idle_element(length=real_start_tau, increment=tau_step)  | 
            ||
| 701 | |||
| 702 | # Create block and append to created_blocks list  | 
            ||
| 703 | xy8_block = PulseBlock(name=name)  | 
            ||
| 704 | xy8_block.append(pihalf_element)  | 
            ||
| 705 | xy8_block.append(tauhalf_element)  | 
            ||
| 706 | for n in range(xy8_order):  | 
            ||
| 707 | xy8_block.append(pix_element)  | 
            ||
| 708 | xy8_block.append(tau_element)  | 
            ||
| 709 | xy8_block.append(piy_element)  | 
            ||
| 710 | xy8_block.append(tau_element)  | 
            ||
| 711 | xy8_block.append(pix_element)  | 
            ||
| 712 | xy8_block.append(tau_element)  | 
            ||
| 713 | xy8_block.append(piy_element)  | 
            ||
| 714 | xy8_block.append(tau_element)  | 
            ||
| 715 | xy8_block.append(piy_element)  | 
            ||
| 716 | xy8_block.append(tau_element)  | 
            ||
| 717 | xy8_block.append(pix_element)  | 
            ||
| 718 | xy8_block.append(tau_element)  | 
            ||
| 719 | xy8_block.append(piy_element)  | 
            ||
| 720 | xy8_block.append(tau_element)  | 
            ||
| 721 | xy8_block.append(pix_element)  | 
            ||
| 722 | if n != xy8_order - 1:  | 
            ||
| 723 | xy8_block.append(tau_element)  | 
            ||
| 724 | xy8_block.append(tauhalf_element)  | 
            ||
| 725 | xy8_block.append(pihalf_element)  | 
            ||
| 726 | xy8_block.append(laser_element)  | 
            ||
| 727 | xy8_block.append(delay_element)  | 
            ||
| 728 | xy8_block.append(waiting_element)  | 
            ||
| 729 | if alternating:  | 
            ||
| 730 | xy8_block.append(pihalf_element)  | 
            ||
| 731 | xy8_block.append(tauhalf_element)  | 
            ||
| 732 | for n in range(xy8_order):  | 
            ||
| 733 | xy8_block.append(pix_element)  | 
            ||
| 734 | xy8_block.append(tau_element)  | 
            ||
| 735 | xy8_block.append(piy_element)  | 
            ||
| 736 | xy8_block.append(tau_element)  | 
            ||
| 737 | xy8_block.append(pix_element)  | 
            ||
| 738 | xy8_block.append(tau_element)  | 
            ||
| 739 | xy8_block.append(piy_element)  | 
            ||
| 740 | xy8_block.append(tau_element)  | 
            ||
| 741 | xy8_block.append(piy_element)  | 
            ||
| 742 | xy8_block.append(tau_element)  | 
            ||
| 743 | xy8_block.append(pix_element)  | 
            ||
| 744 | xy8_block.append(tau_element)  | 
            ||
| 745 | xy8_block.append(piy_element)  | 
            ||
| 746 | xy8_block.append(tau_element)  | 
            ||
| 747 | xy8_block.append(pix_element)  | 
            ||
| 748 | if n != xy8_order - 1:  | 
            ||
| 749 | xy8_block.append(tau_element)  | 
            ||
| 750 | xy8_block.append(tauhalf_element)  | 
            ||
| 751 | xy8_block.append(pi3half_element)  | 
            ||
| 752 | xy8_block.append(laser_element)  | 
            ||
| 753 | xy8_block.append(delay_element)  | 
            ||
| 754 | xy8_block.append(waiting_element)  | 
            ||
| 755 | created_blocks.append(xy8_block)  | 
            ||
| 756 | |||
| 757 | # Create block ensemble  | 
            ||
| 758 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 759 | block_ensemble.append((xy8_block.name, num_of_points - 1))  | 
            ||
| 760 | |||
| 761 | # Create and append sync trigger block if needed  | 
            ||
| 762 | if self.sync_channel:  | 
            ||
| 763 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 764 | sync_block.append(self._get_sync_element())  | 
            ||
| 765 | created_blocks.append(sync_block)  | 
            ||
| 766 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 767 | |||
| 768 | # add metadata to invoke settings later on  | 
            ||
| 769 | number_of_lasers = num_of_points * 2 if alternating else num_of_points  | 
            ||
| 770 | block_ensemble.measurement_information['alternating'] = alternating  | 
            ||
| 771 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 772 | block_ensemble.measurement_information['controlled_variable'] = tau_array  | 
            ||
| 773 |         block_ensemble.measurement_information['units'] = ('s', '') | 
            ||
| 774 | block_ensemble.measurement_information['number_of_lasers'] = number_of_lasers  | 
            ||
| 775 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 776 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 777 | |||
| 778 | # append ensemble to created ensembles  | 
            ||
| 779 | created_ensembles.append(block_ensemble)  | 
            ||
| 780 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 781 | |||
| 782 | View Code Duplication | def generate_xy8_freq(self, name='xy8_freq', freq_start=0.1e6, freq_step=0.01e6,  | 
            |
| 783 | num_of_points=50, xy8_order=4, alternating=True):  | 
            ||
| 784 | """  | 
            ||
| 785 | |||
| 786 | """  | 
            ||
| 787 | created_blocks = list()  | 
            ||
| 788 | created_ensembles = list()  | 
            ||
| 789 | created_sequences = list()  | 
            ||
| 790 | |||
| 791 | # get frequency array for measurement ticks  | 
            ||
| 792 | freq_array = freq_start + np.arange(num_of_points) * freq_step  | 
            ||
| 793 | # get tau array from freq array  | 
            ||
| 794 | tau_array = 1 / (2 * freq_array)  | 
            ||
| 795 | # calculate "real" tau array (finite pi-pulse length)  | 
            ||
| 796 | real_tau_array = tau_array - self.rabi_period / 2  | 
            ||
| 797 | np.clip(real_tau_array, 0, None, real_tau_array)  | 
            ||
| 798 | # Convert back to frequency in order to account for clipped values  | 
            ||
| 799 | freq_array = 1 / (2 * (real_tau_array + self.rabi_period / 2))  | 
            ||
| 800 | |||
| 801 | # create the elements  | 
            ||
| 802 | waiting_element = self._get_idle_element(length=self.wait_time, increment=0)  | 
            ||
| 803 | laser_element = self._get_laser_gate_element(length=self.laser_length, increment=0)  | 
            ||
| 804 | delay_element = self._get_delay_gate_element()  | 
            ||
| 805 | pihalf_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 806 | increment=0,  | 
            ||
| 807 | amp=self.microwave_amplitude,  | 
            ||
| 808 | freq=self.microwave_frequency,  | 
            ||
| 809 | phase=0)  | 
            ||
| 810 | # Use a 180 deg phase shiftet pulse as 3pihalf pulse if microwave channel is analog  | 
            ||
| 811 |         if self.microwave_channel.startswith('a'): | 
            ||
| 812 | pi3half_element = self._get_mw_element(length=self.rabi_period / 4,  | 
            ||
| 813 | increment=0,  | 
            ||
| 814 | amp=self.microwave_amplitude,  | 
            ||
| 815 | freq=self.microwave_frequency,  | 
            ||
| 816 | phase=180)  | 
            ||
| 817 | else:  | 
            ||
| 818 | pi3half_element = self._get_mw_element(length=3 * self.rabi_period / 4,  | 
            ||
| 819 | increment=0,  | 
            ||
| 820 | amp=self.microwave_amplitude,  | 
            ||
| 821 | freq=self.microwave_frequency,  | 
            ||
| 822 | phase=0)  | 
            ||
| 823 | pix_element = self._get_mw_element(length=self.rabi_period / 2,  | 
            ||
| 824 | increment=0,  | 
            ||
| 825 | amp=self.microwave_amplitude,  | 
            ||
| 826 | freq=self.microwave_frequency,  | 
            ||
| 827 | phase=0)  | 
            ||
| 828 | piy_element = self._get_mw_element(length=self.rabi_period / 2,  | 
            ||
| 829 | increment=0,  | 
            ||
| 830 | amp=self.microwave_amplitude,  | 
            ||
| 831 | freq=self.microwave_frequency,  | 
            ||
| 832 | phase=90)  | 
            ||
| 833 | |||
| 834 | # Create block and append to created_blocks list  | 
            ||
| 835 | xy8_block = PulseBlock(name=name)  | 
            ||
| 836 | for ii, tau in enumerate(real_tau_array):  | 
            ||
| 837 | tauhalf_element = self._get_idle_element(length=tau / 2, increment=0)  | 
            ||
| 838 | tau_element = self._get_idle_element(length=tau, increment=0)  | 
            ||
| 839 | xy8_block.append(pihalf_element)  | 
            ||
| 840 | xy8_block.append(tauhalf_element)  | 
            ||
| 841 | for n in range(xy8_order):  | 
            ||
| 842 | xy8_block.append(pix_element)  | 
            ||
| 843 | xy8_block.append(tau_element)  | 
            ||
| 844 | xy8_block.append(piy_element)  | 
            ||
| 845 | xy8_block.append(tau_element)  | 
            ||
| 846 | xy8_block.append(pix_element)  | 
            ||
| 847 | xy8_block.append(tau_element)  | 
            ||
| 848 | xy8_block.append(piy_element)  | 
            ||
| 849 | xy8_block.append(tau_element)  | 
            ||
| 850 | xy8_block.append(piy_element)  | 
            ||
| 851 | xy8_block.append(tau_element)  | 
            ||
| 852 | xy8_block.append(pix_element)  | 
            ||
| 853 | xy8_block.append(tau_element)  | 
            ||
| 854 | xy8_block.append(piy_element)  | 
            ||
| 855 | xy8_block.append(tau_element)  | 
            ||
| 856 | xy8_block.append(pix_element)  | 
            ||
| 857 | if n != xy8_order - 1:  | 
            ||
| 858 | xy8_block.append(tau_element)  | 
            ||
| 859 | xy8_block.append(tauhalf_element)  | 
            ||
| 860 | xy8_block.append(pihalf_element)  | 
            ||
| 861 | xy8_block.append(laser_element)  | 
            ||
| 862 | xy8_block.append(delay_element)  | 
            ||
| 863 | xy8_block.append(waiting_element)  | 
            ||
| 864 | if alternating:  | 
            ||
| 865 | xy8_block.append(pihalf_element)  | 
            ||
| 866 | xy8_block.append(tauhalf_element)  | 
            ||
| 867 | for n in range(xy8_order):  | 
            ||
| 868 | xy8_block.append(pix_element)  | 
            ||
| 869 | xy8_block.append(tau_element)  | 
            ||
| 870 | xy8_block.append(piy_element)  | 
            ||
| 871 | xy8_block.append(tau_element)  | 
            ||
| 872 | xy8_block.append(pix_element)  | 
            ||
| 873 | xy8_block.append(tau_element)  | 
            ||
| 874 | xy8_block.append(piy_element)  | 
            ||
| 875 | xy8_block.append(tau_element)  | 
            ||
| 876 | xy8_block.append(piy_element)  | 
            ||
| 877 | xy8_block.append(tau_element)  | 
            ||
| 878 | xy8_block.append(pix_element)  | 
            ||
| 879 | xy8_block.append(tau_element)  | 
            ||
| 880 | xy8_block.append(piy_element)  | 
            ||
| 881 | xy8_block.append(tau_element)  | 
            ||
| 882 | xy8_block.append(pix_element)  | 
            ||
| 883 | if n != xy8_order - 1:  | 
            ||
| 884 | xy8_block.append(tau_element)  | 
            ||
| 885 | xy8_block.append(tauhalf_element)  | 
            ||
| 886 | xy8_block.append(pi3half_element)  | 
            ||
| 887 | xy8_block.append(laser_element)  | 
            ||
| 888 | xy8_block.append(delay_element)  | 
            ||
| 889 | xy8_block.append(waiting_element)  | 
            ||
| 890 | created_blocks.append(xy8_block)  | 
            ||
| 891 | |||
| 892 | # Create block ensemble  | 
            ||
| 893 | block_ensemble = PulseBlockEnsemble(name=name, rotating_frame=True)  | 
            ||
| 894 | block_ensemble.append((xy8_block.name, 0))  | 
            ||
| 895 | |||
| 896 | # Create and append sync trigger block if needed  | 
            ||
| 897 | if self.sync_channel:  | 
            ||
| 898 | sync_block = PulseBlock(name='sync_trigger')  | 
            ||
| 899 | sync_block.append(self._get_sync_element())  | 
            ||
| 900 | created_blocks.append(sync_block)  | 
            ||
| 901 | block_ensemble.append((sync_block.name, 0))  | 
            ||
| 902 | |||
| 903 | # add metadata to invoke settings later on  | 
            ||
| 904 | number_of_lasers = num_of_points * 2 if alternating else num_of_points  | 
            ||
| 905 | block_ensemble.measurement_information['alternating'] = alternating  | 
            ||
| 906 | block_ensemble.measurement_information['laser_ignore_list'] = list()  | 
            ||
| 907 | block_ensemble.measurement_information['controlled_variable'] = freq_array  | 
            ||
| 908 |         block_ensemble.measurement_information['units'] = ('Hz', '') | 
            ||
| 909 | block_ensemble.measurement_information['number_of_lasers'] = number_of_lasers  | 
            ||
| 910 | block_ensemble.measurement_information['counting_length'] = self._get_ensemble_count_length(  | 
            ||
| 911 | ensemble=block_ensemble, created_blocks=created_blocks)  | 
            ||
| 912 | |||
| 913 | # append ensemble to created ensembles  | 
            ||
| 914 | created_ensembles.append(block_ensemble)  | 
            ||
| 915 | return created_blocks, created_ensembles, created_sequences  | 
            ||
| 916 |