Wavefront_Plotting module

The module responsible for visualisation of distributed behaviours. In general a function will either be a ‘make’ or a ‘plot’ type. ‘plot’ functions require the creation of plotting axes to be provided to the function to be ‘plotted on’. These type of functions typically are plotted on a single axis, were the format of the axis is irrelavant and flexible. ‘make’ functions on the other hand generate axes internally and can have axes passed to them, however they must be of a particualr format. Make functions oftens setup axes in a particular way and is why they handle the generation of the the axes. Internal creation of axes can potentially be problematic when doing multiple loops on a make function, in this case be sure to pass an in axes of the correct format as described per function.

Wavefront_Plotting.clear_subplot(axs)

a little loop that clears all axes of an axes object

Parameters:

axs (matplotlib Axes) – axes object array to be cleared

Wavefront_Plotting.handle_interface_to_ordered(data) Data_Output_Storage_Ordered

ensures data is ordered, extracts it if it can, else raises an error.

Parameters:

data (any) – input data to be checked

Raises:

TypeError – if ordered data cannot be extracted

Returns:

ordered data

Return type:

Data_Output_Storage_Ordered

Wavefront_Plotting.make_3d_spatial(Time_Enquriey: Decimal, interface: Data_Input_Storage, input_ax=False)

an experimanetal plot that shows spatial distribution of voltage and current at a time as a 3D bar graph. One dimension is space, one dimenstion is voltage and the final dimension is current. See make_spatial_voltage_and_current() for a less dense representation of the same data.

Parameters:
  • Time_Enquriey (Decimal) – time ate wwich the spatial information is investigated

  • interface (Data_Input_Storage) – interface simulation storage object

  • input_ax (matplotlib Axes (projection='3d')) – an optional axis to prevent plotting object to be made internally, default is False

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_3d_spatial
import matplotlib.pyplot as plt
from decimal import Decimal

# simulate interface
interface_data = Full_Cycle(L_time='12' , C_time='13')

make_3d_spatial(Decimal('53.56'),interface_data)

# or

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

make_3d_spatial(Decimal('67.07'),interface_data,ax)

plt.show()

Warning

if input_ax is provided, it must have ‘projection=’3d’ else the plot will error.

Wavefront_Plotting.make_commutative_merged_lines(interface_data: Data_Interface_Storage, which_operation: str, which_string: str)

Make 3 - magnitude fanouts with their merging regions shown. Fanout 1 is the commutative fanout before merging. Fanout 2 is the merged fanout along the L-axis. Fanout 3 is the merged fanout along the C-axis.

Parameters:
  • interface_data (Data_Interface_Storage) – the interface data to be plotted

  • which_operation (str) – the operation for fetching fanout data, options are ‘interconnect’,’sending’ or ‘returning’.

  • which_string (str) – which specific magnitude to extract in form ‘{voltage or current} {inductor or capacitor}’

Raises:

ValueError – if incorrect ‘which_operation’ or ‘which_string’ information is provided.

Wavefront_Plotting.make_fanout_crossection(input_array: ndarray, L_intercept: int, C_intercept: int, **kwargs)

Plots a magnitude fanout and corssection at a L and C intercept for a given input data array. The kwargs supplied are passed down to plot_fanout_magnitude(). Additonal key-value customiztion is included for the crossection plot below.

Parameters:
  • input_array (np.ndarray) – The fanout data to be investigated

  • L_intercept (int) – The value on the L-axis to intercept

  • C_intercept (int) – The value on the C-axis to intercept

Returns:

the matplotlib Figure and Axes objects created in this function

Return type:

tuple( fig , ax )

Kwargs for crossection:
  • ax (Dict(Axes)) - Whether to create a subpot or use exsiting subplot axes.If left blank default is ‘False’ and subplot is created internally.If axes are provided, the must be of a matplotlib.pyplot.subplot_mosaic() form.The labels for these axes must inculde:
    • ‘C’ for C-plot/ L interception

    • ‘L’ for L-plot/ C interception

    • ‘D’ for the Diagonal plot

    • ‘F’ for Fanout magnitude plot

  • fig_size (tuple of ints) - The size of the figure. Default is (10, 8).

  • Transpose_C_Plot (bool) - Whether to transpose the C plot. Default is True.

  • Transpose_L_Plot (bool) - Whether to transpose the L plot. Default is False

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_fanout_crossection
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time='6.5' , C_time='3' , L_impedance='700')

# make axes internally, intercept at L=25, C= 10
data = interface.data_output_commutative.Voltage_Interconnect_Capacitor
make_fanout_crossection(data, 25, 10, units='V')

# make axes externally, intercept at L=25, C= 10

fig, ax = plt.subplot_mosaic([['C','F'],
                              ['D','L']])

make_fanout_crossection(data, 25, 10, units='V', ax=ax)

plt.show()

Warning

if ax keyword is not provided, function will make new subplot objects each time it is called. These plots will not be closed by default, so if multiple calls are needed it is suggested you provide the appropriate subplot_mosaic Axes object.

Wavefront_Plotting.make_fanout_interconnect_all(data_output: Data_Output_Storage, contrast_voltage=True, **kwargs)

plots all the interconnect magnitude fanouts for a particular Data_Output_Storage object. A wrapper fucniton for plot_fanout_interconnect(). This is a ‘make’ type function which means that by default the function will internally create the plotting axes unless specified otherwise. The kwargs supplied are passed down to plot_fanout_interconnect(). Additonal key-value customiztion is included for the crossection plot below.

Parameters:
  • data_output (Data_Output_Storage) – The data object to be plotted

  • contrast_voltage (bool, optional) – if the voltage arrays must ignore the intial excitation point for better contrast, defaults to True

Returns:

the matplotlib Figure and Axes objects created in this function (if created)

Return type:

tuple( fig , ax )

Kwargs for figure creation:
  • ax (Dict(Axes)) - Whether to create a subpot or use exsiting subplot axes.If left blank default is ‘False’ and subplot is created internally.If axes are provided, the must be of a matplotlib.pyplot.subplot_mosaic() form.The labels for these axes must inculde:
    • ‘VL’ axis for inductor voltage

    • ‘VC’ axis for capcitor voltage

    • ‘IL’ axis for inductor current

    • ‘IC’ axis for capacitor current

  • fig_size (tuple of ints) - The size of the figure. Default is (10, 8).

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_fanout_interconnect_all
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time='12' , C_time='8')

# make figure internally, plot commutative data
fig1,ax1 = make_fanout_interconnect_all(interface.data_output_commutative)
fig1.suptitle(f"commutative Fanouts") # customize title

# make figure externally, put currents left and voltages right
fig2, ax2 = plt.subplot_mosaic([['IL','VL'],
                                ['IC','VC']])

# pass ax2 to fucniton, also, show multiplicative data this time
make_fanout_interconnect_all(interface.data_output_multiplicative, ax=ax2)
fig2.suptitle(f"multiplicative Fanouts") # customize title

plt.show()

Warning

if ax keyword is not provided, function will make new subplot objects each time it is called. These plots will not be closed by default, so if multiple calls are needed it is suggested you provide the appropriate subplot_mosaic Axes object.

Wavefront_Plotting.make_fanout_wavefronts_all(data_output: Data_Output_Storage, is_Inductor: bool, **kwargs)

plots all the sending and returning magnitude fanouts for a transmission line of a Data_Output_Storage object. A wrapper fucniton for plot_fanout_wavefronts(). This is a ‘make’ type function which means that by default the function will internally create the plotting axes unless specified otherwise. The kwargs supplied are passed down to plot_fanout_wavefronts(). Additonal key-value customiztion is included for the crossection plot below.

Parameters:
  • data_output (Data_Output_Storage) – The data object to be plotted

  • is_Inductor (bool) – if the wavefronts shown are form the inductor or the capacitor.

Returns:

the matplotlib Figure and Axes objects created in this function (if created)

Return type:

tuple( fig , ax )

Kwargs for figure creation:
  • ax (Dict(Axes)) - Whether to create a subpot or use exsiting subplot axes.If left blank default is ‘False’ and subplot is created internally.If axes are provided, the must be of a matplotlib.pyplot.subplot_mosaic() form.The labels for these axes must inculde:
    • ‘VS’ axis for sending voltage

    • ‘VR’ axis for returning voltage

    • ‘IS’ axis for sending current

    • ‘IR’ axis for returning current

  • fig_size (tuple of ints) - The size of the figure. Default is (10, 8).

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_fanout_wavefronts_all
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time='0.34' , C_time='0.12', L_impedance = '700', C_impedance = '7')

# make figure internally, 
# plot commutative inductive wavefronts
fig_ind,ax_ind = make_fanout_wavefronts_all(interface.data_output_commutative,True)

# plot commutative capacitive wavefronts
fig_cap,ax_cap = make_fanout_wavefronts_all(interface.data_output_commutative,False)

# make figure externally,
# put sending wavefronts left and returning wavefronts right
# show merged data

fig2_ind, ax2_ind = plt.subplot_mosaic([['IS','IR'],
                                        ['VS','VR']])
make_fanout_wavefronts_all(interface.data_output_multiplicative,True, ax=ax2_ind)

# put voltages in opposite corners (for fun)
fig2_cap, ax2_cap = plt.subplot_mosaic([['IS','VR'],
                                        ['VS','IR']])
make_fanout_wavefronts_all(interface.data_output_multiplicative,False, ax=ax2_cap)

plt.show()

Warning

if ax keyword is not provided, function will make new subplot objects each time it is called. These plots will not be closed by default, so if multiple calls are needed it is suggested you provide the appropriate subplot_mosaic Axes object.

Wavefront_Plotting.make_spatial_voltage_and_current(Time_Enquriey: Decimal, Interface: Data_Interface_Storage, **kwargs)

Plots the spatial distribution of voltage and current in both the inductor and capacitor.

Parameters:
  • Time_Enquriey (Decimal) – the time at which spatial distrinution of energy is shown.

  • Interface (Data_Interface_Storage) – the data storage object for the interface simulation

Returns:

interconnect values of voltage for capacitor and inductor and current for capacitor and inductor in that order if ‘return-data’ keyword set to True, default is False

Return type:

tuple ( Decimal[VC], Decimal[VL], Decimal[IC], Decimal[IL] )

Kwargs for figure creation:
  • ax (Dict(Axes)) - Whether to create a subpot or use exsiting subplot axes.If left blank default is ‘False’ and subplot is created internally.If axes are provided, the must be of a matplotlib.pyplot.subplot_mosaic() form or a 1D np.ndarray of two items. The first will be assigned voltage and the other current.The labels for these axes must inculde:
    • ‘V’ axis for voltage spatial plot

    • ‘I’ axis for current spatial plot

  • fig_size (tuple of ints) - The size of the figure. Default is (12,10).

  • quantize (str or Decimal) - the precision to round the input time shown in the title

  • return_data (bool) - if the interconnect values must be returned or not, default is False

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_spatial_voltage_and_current
import matplotlib.pyplot as plt
from decimal import Decimal

# simulate an interface
interface_data = Full_Cycle(L_time = '2.07',C_time = '3.2')

# investgate the spatial waveforms a t = 30.573
make_spatial_voltage_and_current(Decimal('30.573'),interface_data)

# this time we will pass an axes dict, put current at the top:
# notice the correct formatting of ['V'] and ['I']
fig,ax = plt.subplot_mosaic([['I'],
                            ['V']])

# investgate the spatial waveforms a t = 30.7
make_spatial_voltage_and_current(Decimal('30.7'),interface_data,ax=ax)

plt.show()

Warning

if you do not pass an axes object the function will make a new suplot at each call. This means that if you plan to run the function such that it called multiple timea, like a loop, it is advised to pass axes object to avoid uneccassary creation of supblots each interation.

Wavefront_Plotting.make_time_interconnect_all(data_output_ordered: Data_Output_Storage_Ordered, is_integrated: bool = True, **kwargs)

Plots all interconnect time waveforms of an interface/ orderd data.

Parameters:
  • data_output_ordered (Data_Output_Storage_Ordered) – data to be plotted. Can be interface or ordered data.

  • is_integrated (bool, optional) – If the wavefrom must represent the ‘change’ or ‘accumulation of changes’ of the data selected to be plotted, default is True

Returns:

the matplotlib Figure and Axes objects created in this function (if created)

Return type:

tuple( fig , ax )

Kwargs for figure creation:
  • ax (Dict(Axes)) - Whether to create a subpot or use exsiting subplot axes.If left blank default is ‘False’ and subplot is created internally.If axes are provided, the must be of a matplotlib.pyplot.subplot_mosaic() form.The labels for these axes must inculde:
    • ‘VL’ axis for inductor voltage

    • ‘VC’ axis for capcitor voltage

    • ‘IL’ axis for inductor current

    • ‘IC’ axis for capacitor current

  • fig_size (tuple of ints) - The size of the figure. Default is (10, 8).

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_time_interconnect_all
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time='8' , C_time='7', L_impedance = '500', C_impedance = '2')

# plot all interconnect time waveforms
fig,ax = make_time_interconnect_all(interface)

# plot the 'change' in those waveforms
fig2,ax2 = make_time_interconnect_all(interface,False)

plt.show()
Wavefront_Plotting.make_time_wavefronts_all(data_output_ordered: Data_Output_Storage_Ordered, is_Inductor: bool, is_integrated: bool = True, **kwargs)

Plots the wavefront time beahviour of a particualr transmission line. Both sending and returning, current and voltage wavefront time behaviour is shown

Parameters:
  • data_output_ordered (Data_Output_Storage_Ordered or Data_Interface_Storage) – data to be plotted. Can be interface or ordered data.

  • is_Inductor (bool) – if the inductor or capacitor wavefronts must be plot.

  • is_integrated (bool, optional) – if the individual wavefront value or an accumulation of these values msut be shown, defaults to True

Returns:

the matplotlib Figure and Axes objects created in this function (if created)

Return type:

tuple( fig , ax )

Kwargs for figure creation:
  • ax (Dict(Axes)) - Whether to create a subpot or use exsiting subplot axes.If left blank default is ‘False’ and subplot is created internally.If axes are provided, the must be of a matplotlib.pyplot.subplot_mosaic() form.The labels for these axes must inculde:
    • ‘VS’ axis for sending voltage

    • ‘VR’ axis for returning voltage

    • ‘IS’ axis for sending current

    • ‘IR’ axis for returning current

  • fig_size (tuple of ints) - The size of the figure. Default is (10, 8).

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import make_time_wavefronts_all
import matplotlib.pyplot as plt

# Example: the accumulated wavefront behaviour over time between the capacitor and inductor
# ==========================================================================================

# simulate interface
interface = Full_Cycle(L_time='7' , C_time='3.4', L_impedance = '654', C_impedance = '2.5')

# plot accumulation wavefront activity for inductor
fig,ax = make_time_wavefronts_all(interface,True,True)

# plot the accumulation wavefront activity for capacitor
# here we just pass the ax object as a kwarg so that it is plotted on the same axes
make_time_wavefronts_all(interface,False,True,ax=ax)

# rename the auto generated suptitle
fig.suptitle('Comparison between accumulated wavefronts over time in each transmission line')

# use the key word to set titles of each axis independantly 
ax['VS'].set_title('Sending Voltage Wavefronts')
ax['VR'].set_title('Returning Voltage Wavefronts')
ax['IS'].set_title('Sending Current Wavefronts')
ax['IR'].set_title('Returning Current Wavefronts')

# plot a legend for all axes
for ax_i in ax.values(): 
    ax_i.legend(['Inductor', 'Capacitor'])

plt.show()
Wavefront_Plotting.plot_fanout_interconnect(data_output: Data_Output_Storage, ax, which_string: str, contrast_voltage=True, **kwargs)

A wrapper function for plot_fanout_magnitude() for plotting interconnect fanouts. Takes in a Data_Output_Storage object and a string to plot and auto format the fanout. It will pass provided **kwargs to the underlying plot_fanout_magnitude function. To plot all interface interconnect fanouts at once see make_fanout_interconnect_all()

Parameters:
  • data_output (Data_Output_Storage) – The data output object that contians the interconnect arrays. Could be commutative or multiplicative data.

  • ax (matplotlib Axes object) – the matplotlib axis to plot on

  • which_string (str) – determine which interconnect value to plot. Options are “voltage inductor”, “current inductor”, “voltage capacitor”, “current capacitor”

  • contrast_voltage (bool) – determine if voltage arrays must exclude the orign point for better contrast, default is True

Raises:
  • ValueError – if incorrect ‘which_string’ is not provided.

  • warning – if ‘title=’, ‘units=’ or ‘contrast=’ keyword are included as they are auto assigned by this function

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_fanout_interconnect
import matplotlib.pyplot as plt

# simulate interface
interface_data = Full_Cycle(L_time='12' , C_time='13')

# compare commutative and multiplicative capacitor interconnect voltage
# (on the same subplot)
fig, ax = plt.subplots(1,2, figsize= (10,6))

# pass commutative data output
plot_fanout_interconnect(interface_data.data_output_commutative,
                        ax[0], 'voltage capacitor')

# pass multiplicative data output 
plot_fanout_interconnect(interface_data.data_output_multiplicative,
                        ax[1], 'voltage capacitor')

plt.show()

Warning

When providing the **kwargs, you cannot specify ‘title=’, ‘units=’ or ‘’contrast=’ as these are auto assinged. Providing these values will result in an error.

Wavefront_Plotting.plot_fanout_magnitude(array_to_plot: ndarray, ax, **input_kwargs)

the core function for plotting the fanout diagram of a 2D numpy array. Points are coloured using the ‘seismic’ colour map with red being positive and blue negative. See plot_fanout_interconnect() and plot_fanout_wavefronts() for prettier plots with more automation

Parameters:
  • array_to_plot (np.ndarray or List) – The array to be plotted, can also accept lists of numerical data

  • ax (matplotlib.Axe) – a matplotlib Axe object to plot using ‘imshow’

Input_kwargs:
  • title (str) - The title of the fanout (default = “Magnitude Fanout”)

  • show_colour_bar (bool) - if colour bar must be shown (default = True)

  • contrast (bool) - if the orign node must be ignored for the colour mapping maximum value calculation (default = False)

  • padding (int) - the amount of padding around the array, thinner arrays are easier to navigate with padding (default = 0)

  • units (str) - the units of the colour bar (default = ‘A’)

  • origin (str) - either ‘lower’ or ‘upper’, sets the postion of the origin (default = ‘lower’)

  • transpose (bool) - makes x-axis the L-axis if true (default = True)

  • show_ticks (bool) - if axis ticks are shown (default = False)

  • custom_colour_bar_limits (tuple or bool) - pass a (max_value, min_value) tuple to customize colouring extent of the fanout(default = False)

Warning

a wavefront storage array must be in their magnitude forms, these arrays can be fetched using Wavefront_Storage.Data_Output_Storage.get_sending_wavefronts_magnitudes() or Wavefront_Storage.Data_Output_Storage.get_returning_wavefronts_magnitudes(). Alternatively magnitdues from a wavefront array can be manually extracted by passing as an input parameter to Wavefront_Misc.get_voltage_array() or Wavefront_Misc.get_current_array()

simple use
from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_fanout_magnitude
import matplotlib.pyplot as plt

# simulate interface
interface_data = Full_Cycle(L_time='0.7' , C_time='3.2')

# plot the commutatiive capacitor interconnect voltage 
fig, ax = plt.subplots()
arr = interface_data.data_output_commutative.Voltage_Interconnect_Capacitor
# set units to 'V'
plot_fanout_magnitude(arr,ax, units = 'V')
plt.show()
manual wavefront fanout, see plot_fanout_wavefronts()
from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_fanout_magnitude
import matplotlib.pyplot as plt

# simulate interface
interface_data = Full_Cycle(L_time='23' , C_time='11')

# plot the multiplicative sending current capacitor wavefronts
fig, ax = plt.subplots()
arr = interface_data.data_output_multiplicative.get_sending_wavefronts_magnitudes('current capacitor')
# set units to 'V'
plot_fanout_magnitude(arr,ax, units = 'A')
plt.show()
Returns:

plots a magnitude fanout on the provided axis

Wavefront_Plotting.plot_fanout_time(input_array: ndarray, ax, **input_kwargs)

Plot a time fanout of a provided input array. Coloured in a rainbow pattern from the minimum array value to the maximum array value.

Parameters:
  • input_array (np.ndarray or List) – The array to be plotted, can also accept lists of numerical data

  • ax (matplotlib.Axe) – a matplotlib Axe object to plot using ‘imshow’

Input_kwargs:
from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_fanout_time
import matplotlib.pyplot as plt

# simulate interface
interface_data = Full_Cycle(L_time='2' , C_time='7')

# plot the time fanout
fig, ax = plt.subplots()
plot_fanout_time(interface_data.data_output_commutative.Time, ax)

plt.show()
Wavefront_Plotting.plot_fanout_wavefronts(data_output: Data_Output_Storage, ax, which_string: str, is_sending: bool = True, **kwargs)

A wrapper function for plot_fanout_magnitude() for plotting wavefront fanouts. Takes in a Data_Output_Storage object, a string and a bool are passed to plot and auto format the fanout. It will pass provided **kwargs to the underlying plot_fanout_magnitude function. To plot all wavefront fanouts at once see make_fanout_wavefronts_all()

Parameters:
  • data_output (Data_Output_Storage) – The data output object that contians the interconnect arrays. Could be commutative or multiplicative data.

  • ax (matplotlib Axes object) – the matplotlib axis to plot on

  • which_string (str) – determine which interconnect value to plot. Options are “voltage inductor”, “current inductor”, “voltage capacitor”, “current capacitor”

  • is_sending (bool, optional) – determines if sending or returning wavefronts must be plotted, defaults to True

Raises:

ValueError – if incorrect ‘which_string’ is not provided.

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_fanout_wavefronts
import matplotlib.pyplot as plt

# simulate interface
interface_data = Full_Cycle(L_time='12' , C_time='13')

# compare sending and returning capacitor current wavefronts
# (on the same subplot)
fig, ax = plt.subplots(1,2, figsize= (10,6))

# sending current wavefronts
plot_fanout_wavefronts(interface_data.data_output_commutative,
                        ax[0], 'current capacitor',True)

# returning current wavefront 
plot_fanout_wavefronts(interface_data.data_output_commutative,
                        ax[1], 'current capacitor',False)

plt.show()

Warning

When providing the **kwargs, you cannot specify ‘title=’ or ‘units=’ as these are auto assinged. Providing these values will result in an error.

Wavefront_Plotting.plot_merging_lines_on_fanout(array_to_plot: ndarray, KL: int, KC: int, ax, **kwargs)

Plots the borders of merging regions for a given array_to_plot onto an axis that is plotting a fanout.

Parameters:
  • array_to_plot (np.ndarray) – The data array contianing fanout magnitude information

  • KL (int) – Inductor LCM factor

  • KC (int) – Capacitor LCM factor

  • ax (matplotlib Axes object) – Axis with a fanout plot on it

Kwargs:
  • transpose (bool) - Whether the plot is transposed (L-axis is horizontal axis). Default is True

  • padding (int) - The padding of the plot. Default is 0

  • line_colour (str) - The color of the lines. Default is ‘k’

  • line_width (float) - The width of the lines. Default is 0.5

Wavefront_Plotting.plot_refelction_diagram(interface_data: Data_Interface_Storage, ax, is_voltage: bool, **kwargs)

plots a coloured current or voltage reflection for the inductor and capacitor of a simulated interface.

Parameters:
  • interface_data (Data_Interface_Storage) – The interface to be plotted.

  • ax (Matplotlib Axes) – axis to plot on

  • is_voltage (bool) – if the plot

Raises:

TypeError – if supplied custom_colour_bar are not a tuple

Kwargs for figure creation:
  • stop_time (float) - The simulation stop time. Default is the value of interface_data.data_input.Simulation_Stop_Time.

  • custom_colour_bar_limits (tuple) - supply a tuple in form of (Vmax,Vmin) for colourbar limits. Default is False, meaning it is calcuated of absolute maximum of wavefronts.

  • face_colour (str) - The face color of the plot. Default is ‘xkcd:grey’.

  • LS_colour (bool or str) - if supplied overides colour map colouring, The color of the sending inductor wavefronts, matplotlib colour. Default is False.

  • LR_colour (bool or str) - if supplied overides colour map colouring, The color of the returning inductor wavefronts, matplotlib colour. Default is False.

  • CS_colour (bool or str) - if supplied overides colour map colouring, The color of the sending capacitor wavefronts, matplotlib colour. Default is False.

  • CR_colour (bool or str) - if supplied overides colour map colouring, The color of the returning capacitor wavefronts, matplotlib colour. Default is False.

  • LS_style (str) - The style of the sending inductor wavefronts, matplotlib linestyle. Default is ‘-‘.

  • LR_style (str) - The style of the returning inductor wavefronts, matplotlib linestyle. Default is ‘-‘.

  • CS_style (str) - The style of the sending capacitor wavefronts, matplotlib linestyle. Default is ‘-‘.

  • CR_style (str) - The style of the returning capacitor wavefronts, matplotlib linestyle. Default is ‘-‘.

  • info_title (bool) - Whether to include a title with input information about the plot. Default is True.

Compare Voltage and Current wavefronts of the interface
from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_refelction_diagram
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time = '12',C_time = '11',Simulation_stop_time=100)

# create subplot
fig,ax = plt.subplots(1,2,figsize=(18,8))

# compare voltage and current 
plot_refelction_diagram(interface,ax[0],True)
plot_refelction_diagram(interface,ax[1],False)

plt.show()
Customizing plots to highlight sending wavefronts
from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_refelction_diagram
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time = '12',C_time = '11',Simulation_stop_time=100)

# create subplot
fig,ax = plt.subplots(1,2,figsize=(18,8))

# highlight sending wavefronts and make returning gray
c = 'dimgray'
plot_refelction_diagram(interface,ax[0],True, CR_colour=c, CR_style = '--', LR_colour=c, LR_style = '--')
plot_refelction_diagram(interface,ax[1],False, CR_colour=c, CR_style = '--', LR_colour=c, LR_style = '--')

plt.show()
Wavefront_Plotting.plot_time_interconnect(data_output_ordered: Data_Output_Storage_Ordered, ax, which_string: str, is_integrated: bool = True, **kwarg)

Plots the time waveform of one of the interconncet metrics. It must be noted that interconnect values stored in the :Data_Output_Storage_Ordered: object signify the ‘change’ in interface values due to wavefronts. To see the full time wavefrom, the changes must be accumulated. This function shows both change and accumulated quantities.

Parameters:
  • data_output_ordered (Data_Output_Storage_Ordered or (Data_Interface_Storage)) – The data object containing 1D ordered simulation data

  • ax (Matplotlib Axes object) – The axis on which the interconncet wavefrom will be plotted.

  • which_string (str) – The interconnect value to be plotted, options are “voltage inductor”, “current inductor”, “voltage capacitor” and “current capacitor”

  • is_integrated (bool) – If the wavefrom must represent the ‘change’ or ‘accumulation of changes’ of the data selected to be plotted, default is True

Raises:

ValueError – if an incorrect which_string is provided.

Returns:

(optional) if key word ‘return_data = True’ is passed, will return the plotted array, default is False

Return type:

np.ndarray[Decimal]

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_time_interconnect
import matplotlib.pyplot as plt

# simulate interface
interface = Full_Cycle(L_time='0.34' , C_time='0.12', L_impedance = '700', C_impedance = '7')

# Make axes 
fig,ax = plt.subplots(2,1,figsize=(8,8))

# make a handle for ordered data (very optional)
data = interface.data_output_ordered

# plot accumulated data on ax[0]
plot_time_interconnect(data,ax[0],'current capacitor',True)

# plot change data on ax[1], use 'interface' instead of 'data' (for fun)
plot_time_interconnect(interface,ax[1],'current capacitor',False)

plt.show()

Warning

This function accepts only Wavefront_Storage.Data_Output_Storage_Ordered as an input. The data is required to be 1D and ordered.

Wavefront_Plotting.plot_time_interconnect_and_intercepts_at_time(Time_Enquriey: Decimal, data_output_ordered: Data_Output_Storage_Ordered, **kwargs)

plots all the interconnect voltages and/or currents of the tansmission lines on two sperate axes, one axis for voltage and one for current. Shows the magnitude of the interconnect values at a particualr time intercept as horizontla lines. Combined with make_spatial_voltage_and_current() to make py:func:spatial_interconnect_investigator, which has an interactive form using ipywidgets, py:func:Wavefront_Interactive.spatial_interconnect_investigator_ui. See code-block bellow.

Parameters:
Kwargs:
  • ax_voltage (axis or bool) - the axis to plot the voltage on, leave empty to not plot. Default is False.

  • ax_current (axis or bool) - the axis to plot the current on, leave empty to not plot. Default is False.

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_time_interconnect_and_intercepts_at_time
import matplotlib.pyplot as plt
from decimal import Decimal

# simulate interface
interface_data = Full_Cycle(L_time='0.7' , C_time='3.2')

time_enquirey = Decimal('25')

# plot both voltage and current

fig_both, ax_both = plt.subplots(2,1)
# define axes with kwargs 'ax_voltage=' and 'ax_current='
plot_time_interconnect_and_intercepts_at_time(time_enquirey,interface_data,
                                            ax_voltage = ax_both[0],
                                            ax_current = ax_both[1])

# lets plot just the voltage this time, also we will progress the time enquirey
# we will leave out 'ax_current='
fig_single,ax_single = plt.subplots()
time_enquirey += Decimal('5')
plot_time_interconnect_and_intercepts_at_time(time_enquirey,interface_data,ax_voltage = ax_single)

plt.show()
Wavefront_Plotting.plot_time_wavefronts(data_output_ordered: Data_Output_Storage_Ordered, ax, which_string: str, is_sending: bool, is_integrated: bool = True)

Plots the time waveform of one of the wavefront metrics. It must be noted that interconnect values stored in the Data_Output_Storage_Ordered object signify the ‘change’ in interface values due to wavefronts. To see the full time wavefrom, the changes must be accumulated. This function shows both change and accumulated quantities.

Parameters:
  • data_output_ordered (Data_Output_Storage_Ordered or Data_Interface_Storage) – The data object containing 1D ordered simulation data, also accepts full interface data

  • ax (Matplotlib Axes object) – The axis on which the interconncet wavefrom will be plotted.

  • which_string (str) – The wavefront value to be plotted, options are “voltage inductor”, “current inductor”, “voltage capacitor” and “current capacitor”

  • is_sending (bool) – If the the wavefront data shown must be for sending or returning wavefronts.

  • is_integrated (bool) – If the wavefrom must represent the ‘change’ or ‘accumulation of changes’ of the data selected to be plotted, default is True

Raises:

ValueError – if an incorrect which_string is provided.

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_time_wavefronts
import matplotlib.pyplot as plt

# Example, comparing the sending and returning current wavefronts in the capacitor:
# =================================================================================

# simulate interface
interface = Full_Cycle(L_time='3' , C_time='7', L_impedance = '700', C_impedance = '7')
data = interface.data_output_ordered

# Make axes 
fig,ax = plt.subplots()

# plot sending wavefronts (not accumulated)
plot_time_wavefronts(data,ax,'current capacitor',True,False)

# plot returning wavefronts (not accumulated)
plot_time_wavefronts(data,ax,'current capacitor',False,False)

plt.show()

Warning

This function accepts only Wavefront_Storage.Data_Output_Storage_Ordered as an input. The data is required to be 1D and ordered.

Wavefront_Plotting.plot_trace_on_merged_fanout_axis(data_output_ordered: Data_Output_Storage_Ordered, ax, upto_time: Decimal = False, **kwargs)

Plots a path of arrows on a merged fanout diagram.

Parameters:
  • data_output_ordered (Data_Output_Storage_Ordered or Data_Interface_Storage) – the ordered data array, can also be an interface object

  • ax (Matplotlib Axes) – the axis with a fanout diagram plotted on it

  • upto_time (Decimal, optional) – the time to which the path must be plotted, defaults to False

Kwargs:
  • show_cross (bool) - If a cross must be plotted to show current arrow at ‘upto_time’. Default is False

  • padding (int) - The padding around the arrow. Default is 0.

  • length_includes_head (bool) - Whether the head is included in the arrow length. Default is True.

  • head_width (float) - The width of the arrow head. Default is 0.3.

  • head_length (float) - The length of the arrow head. Default is 0.3.

  • width (float) - The width of the arrow shaft. Default is 0.0005.

  • facecolor (str) - The face color of the arrow. Default is ‘gray’.

  • edgecolor (str) - The edge color of the arrow. Default is ‘black’.

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import plot_trace_on_merged_fanout_axis, plot_fanout_interconnect
import matplotlib.pyplot as plt

# simulate an interface
interface_data = Full_Cycle(L_time = '3.6',C_time = '3.2')

fig, ax = plt.subplots()
plot_fanout_interconnect(interface_data.data_output_multiplicative,ax,'voltage capacitor')
plot_trace_on_merged_fanout_axis(interface_data,ax)
plt.show()

Warning

the trace plotted is compatible with merged fanouts. (fanout plots of data_output_multiplicative)

Wavefront_Plotting.save_spatial_interconnect(Interface: Data_Interface_Storage, **kwargs)

a function that saves an animation of the spatial distribution of voltage and current compared to time interconncect plots. Is the combination of make_spatial_voltage_and_current() and plot_time_interconnect_and_intercepts_at_time(). It is effectively Wavefront_Interactive.spatial_interconnect_investigator_ui(), however smoother as computation is not ‘real-time’

Parameters:

Interface (Data_Interface_Storage) – the interface data to be saved.

Kwargs:
  • auto_zoom (bool) - Whether to automatically zoom the plot or to have the axes aligned. Default is False.

  • start_time (str) - The start time enquirey for the plot. Default is ‘0’.

  • end_time (float) - The end time enquirey for the plot. Default is the value of Interface.data_input.Simulation_Stop_Time.

  • fps (str) - The frames per second for the video. Default is ‘30’.

  • video_runtime (str) - The runtime of the video in seconds. Default is ‘60’.

  • dpi (str) - The dots per inch for the video. Default is ‘300’.

  • fig_size (tuple of ints) - The size of the figure. Default is (14, 8).

  • meta_data (dict) - The metadata for the video. Default is {‘title’: ‘Distributed Modelling’, ‘artist’: ‘Jonathan Meerholz’}.

  • save_name (str) - The name to save the video as. Default is a string with the values of ‘spatial_and_time_{ZL}_{ZC}ohm_{TL}_{TC}s’

Warning

the default values of 60s runtime with 30 fps will result in a computation that will often take longer than 10 mins. be sure to alter these values if you dont want to wait!

from Wavefront_Generation import Full_Cycle
from Wavefront_Plotting import save_spatial_interconnect

# simulate an interface
interface_data = Full_Cycle(L_time = '3.6',C_time = '3.2')

save_spatial_interconnect(interface_data, video_runtime = '5',
                        start_time = '0', end_time = '30')