WrightTools.diagrams.WMEL module

WMEL diagrams.

class WrightTools.diagrams.WMEL.Artist(size, energies, state_names=None, number_of_interactions=4, virtual=[None], state_font_size=8, state_text_buffer=0.5)[source]

Bases: object

Dedicated WMEL figure artist.

__init__(size, energies, state_names=None, number_of_interactions=4, virtual=[None], state_font_size=8, state_text_buffer=0.5)[source]

Initialize.

Parameters:
  • size ([rows, collumns]) – Layout.
  • energies (list of numbers) – State energies.
  • state_names (list of strings (optional)) – State names. Default is None.
  • number_of_interactions (integer (optional)) – Number of interactions. Default is 4.
  • virtual (list of integers (optional)) – Indices of states which are virtual. Default is [None].
  • state_font_size (number (optional)) – State font size. Default is 8.
  • state_text_buffer (number (optional)) – Size of buffer around state text. Default is 0.5.
add_arrow(diagram, number, between, kind, label='', head_length=0.075, font_size=7, color='k')[source]

Add arrow.

Parameters:
  • diagram ([column, row]) – Diagram position.
  • number (integer) – Arrow position.
  • between ([start, stop]) – Arrow span.
  • kind ({'ket', 'bra', 'out'}) – Arrow style.
  • label (string (optional)) – Arrow label. Default is ‘’.
  • head_length (number (optional)) – Arrow head length. Default 0.075.
  • font_size (number (optional)) – Font size. Default is 7.
  • color (matplotlib color) – Arrow color. Default is ‘k’.
Returns:

[line, arrow_head, text]

Return type:

list

clear_diagram(diagram)[source]

Clear diagram.

Parameters:diagram ([column, row]) – Diagram to clear.
label_columns(labels, font_size=15, text_buffer=1.15)[source]

Label columns.

Parameters:
  • labels (list of strings) – Labels.
  • font_size (number (optional)) – Font size. Default is 15.
  • text_buffer (number) – Buffer around text. Default is 1.5.
label_rows(labels, font_size=15, text_buffer=1.5)[source]

Label rows.

Parameters:
  • labels (list of strings) – Labels.
  • font_size (number (optional)) – Font size. Default is 15.
  • text_buffer (number) – Buffer around text. Default is 1.5.
plot(save_path=None, close=False, bbox_inches='tight', pad_inches=1)[source]

Plot figure.

Parameters:
  • save_path (string (optional)) – Save path. Default is None.
  • close (boolean (optional)) – Toggle automatic figure closure after plotting. Default is False.
  • bbox_inches (number (optional)) – Bounding box size, in inches. Default is ‘tight’.
  • pad_inches (number (optional)) – Pad inches. Default is 1.
class WrightTools.diagrams.WMEL.Subplot(ax, energies, number_of_interactions=4, title='', title_font_size=16, state_names=None, virtual=[None], state_font_size=14, state_text_buffer=0.5, label_side='left')[source]

Bases: object

Subplot containing WMEL.

__init__(ax, energies, number_of_interactions=4, title='', title_font_size=16, state_names=None, virtual=[None], state_font_size=14, state_text_buffer=0.5, label_side='left')[source]

Subplot.

Parameters:
  • ax (matplotlib axis) – The axis.
  • energies (1D array-like) – Energies (scaled between 0 and 1)
  • number_of_interactions (integer) – Number of interactions in diagram.
  • title (string (optional)) – Title of subplot. Default is empty string.
  • state_names (list of str (optional)) – list of the names of the states
  • virtual (list of ints (optional)) – list of indexes of any vitual energy states
  • state_font_size (numtype (optional)) – font size for the state lables
  • state_text_buffer (numtype (optional)) – space between the energy level bars and the state labels
add_arrow(index, between, kind, label='', head_length=0.1, head_aspect=2, font_size=14, color='k')[source]

Add an arrow to the WMEL diagram.

Parameters:
  • index (integer) – The interaction, or start and stop interaction for the arrow.
  • between (2-element iterable of integers) – The inital and final state of the arrow
  • kind ({'ket', 'bra'}) – The kind of interaction.
  • label (string (optional)) – Interaction label. Default is empty string.
  • head_length (number (optional)) – size of arrow head
  • font_size (number (optional)) – Label font size. Default is 14.
  • color (matplotlib color (optional)) – Arrow color. Default is black.
Returns:

Return type:

[line,arrow_head,text]