@@ -472,6 +472,65 @@ def export_to_file(self, filename=None,
472472 file_type = file_type ,
473473 coordinates = coordinates )
474474
475+ def export (self , coordinates = CYLINDRICAL , dimensionless_rabi_rate = True ):
476+ """ Returns a dictionary formatted for plotting using the qctrl-visualizer package.
477+
478+ Parameters
479+ ----------
480+ dimensionless_rabi_rate: boolean
481+ If True, normalizes the Rabi rate so that its largest absolute value is 1.
482+ coordinates: string
483+ Indicates whether the Rabi frequency should be plotted in terms of its
484+ 'cylindrical' or 'cartesian' components.
485+
486+ Returns
487+ -------
488+ dict
489+ Dictionary with plot data that can be used by the plot_controls
490+ method of the qctrl-visualizer package. It has keywords 'Rabi rate'
491+ and 'Detuning' for 'cylindrical' coordinates and 'X amplitude', 'Y amplitude',
492+ and 'Detuning' for 'cartesian' coordinates.
493+
494+ Raises
495+ ------
496+ ArgumentsValueError
497+ Raised when an argument is invalid.
498+ """
499+
500+ if coordinates not in [CARTESIAN , CYLINDRICAL ]:
501+ raise ArgumentsValueError (
502+ 'Unsupported coordinates provided: ' ,
503+ arguments = {'coordinates' : coordinates })
504+
505+ if dimensionless_rabi_rate :
506+ normalizer = self .maximum_rabi_rate
507+ else :
508+ normalizer = 1
509+
510+ plot_dictionary = {}
511+
512+ plot_x = self .amplitude_x / normalizer
513+ plot_y = self .amplitude_y / normalizer
514+ plot_r = self .rabi_rates / normalizer
515+ plot_theta = self .azimuthal_angles
516+ plot_durations = self .durations
517+ plot_detunings = self .detunings
518+
519+ if coordinates == CARTESIAN :
520+ plot_dictionary ["X amplitude" ] = [{'value' : v , 'duration' : t }
521+ for v , t in zip (plot_x , plot_durations ) ]
522+ plot_dictionary ["Y amplitude" ] = [{'value' : v , 'duration' : t }
523+ for v , t in zip (plot_y , plot_durations ) ]
524+
525+ if coordinates == CYLINDRICAL :
526+ plot_dictionary ["Rabi rate" ] = [{'value' : r * np .exp (1.j * theta ), 'duration' : t }
527+ for r , theta , t in zip (plot_r , plot_theta , plot_durations ) ]
528+
529+ plot_dictionary ["Detuning" ] = [{'value' : v , 'duration' : t }
530+ for v , t in zip (plot_detunings , plot_durations ) ]
531+
532+ return plot_dictionary
533+
475534 def get_plot_formatted_arrays (self , coordinates = CARTESIAN , dimensionless_rabi_rate = True ):
476535 """ Gets arrays for plotting a driven control.
477536
@@ -547,17 +606,9 @@ def get_plot_formatted_arrays(self, coordinates=CARTESIAN, dimensionless_rabi_ra
547606 'times' : plot_time }
548607
549608 if coordinates == CYLINDRICAL :
550-
551- x_plot = plot_amplitude_x
552- y_plot = plot_amplitude_y
553- x_plot [np .equal (x_plot , - 0.0 )] = 0.
554- y_plot [np .equal (y_plot , - 0.0 )] = 0.
555- azimuthal_angles_plot = np .arctan2 (y_plot , x_plot )
556- amplitudes_plot = np .sqrt (np .abs (x_plot ** 2 + y_plot ** 2 ))
557-
558609 plot_dictionary = {
559- 'rabi_rates' : amplitudes_plot ,
560- 'azimuthal_angles' : azimuthal_angles_plot ,
610+ 'rabi_rates' : plot_amplitude_x ,
611+ 'azimuthal_angles' : plot_amplitude_y ,
561612 'detunings' : plot_amplitude_z ,
562613 'times' : plot_time }
563614 return plot_dictionary
0 commit comments