Wavefront_Misc module
- Wavefront_Misc.Steady_State_Analysis(TL: Decimal, TC: Decimal)
Prints out the steady-state analysis of an interface described by two time delays. Returns when each of the two criteria for steady-state to be reach will occur.
- Parameters:
TL (Decimal) – inductive time delay
TC (Decimal) – capacitive time delay
- Returns:
(time_before_regular_GCF, time_before_regular_Steady_State)
- Return type:
Tuple
- Wavefront_Misc.closest_event_to_time(data_ordered_time: list, time_enquirey: Decimal, can_be_after_enquirey: bool = True)
Finds the closest event and time to a praticular time enquirey.
- Parameters:
data_ordered_time (list[Decimal]) – time list, must be chronologically ordered. Typically from
Wavefront_Storage:Data_Output_Storage_Orderedtime_enquirey (Decimal) – The time to wich the returned event will be closest
can_be_after_enquirey (bool, optional) – if the event is allowed to occur after the enquirey, defaults to True
- Returns:
the index in time list and the closest time retuned as a tuple
- Return type:
tuple ( index[int] , time[Decimal])
from Wavefront_Generation import Full_Cycle from Wavefront_Misc import closest_event_to_time from decimal import Decimal # simulate random interface interface = Full_Cycle(L_time='7' , C_time='3.4',show_about = False) # handle for ordered time list Time_arr = interface.data_output_ordered.Time time_enquirey = Decimal('10.3') # find closest event, can be after enquirey i_after, t_after = closest_event_to_time(Time_arr,time_enquirey,True) # find closest event, event must be before enquirey i_before, t_before = closest_event_to_time(Time_arr,time_enquirey,False) # the two closest times are 10.4 and 10.2 and time enquirey is 10.3 # 10.2 <--- 10.3 -> 10.4 print(f" time enquirey is {time_enquirey}") print(f" best time if can be after {t_after} ") # returns 10.4 print(f" best time if must be before {t_before} ") # returns 10.2 # We can get the [ L , C ] coordiante by refernecing the 'Indexes' array coord_after = interface.data_output_ordered.Indexes[ i_after ] coord_before = interface.data_output_ordered.Indexes[ i_before ] print(f" [L , C] after {coord_after} ") # returns [1, 1] print(f" [L , C] before {coord_before} ") # returns [0, 3]
Warning
time_enquirey must should be a Decimal number to be compatible with the storage array. The enquirey will be auto converted into a decimal but can produce errors.
- Wavefront_Misc.convert_to_image_array(array)
Takes an input array, and if it is a 1-dimensional list, it will convert it into a suitable format for matplotlib “imshow” used by fanout plotters.
- Parameters:
array (np.ndarray or List) – np.ndarray or List to be processed if neccessary
- Returns:
an output array that can be shown using “imshow”
- Return type:
np.ndarray
- Wavefront_Misc.default_input_values: dict = {'C_impedance': '1', 'C_length': '1', 'C_time': '1', 'L_impedance': '100', 'L_length': '1', 'L_time': '1', 'Load_impedance': 'inf', 'Simulation_stop_time': '0', 'V_source': '1', 'number_periods': '1', 'show_about': True}
The default values used in the simulation if not specified otherwise
- Wavefront_Misc.get_array_absolute_maximum(array: ndarray)
Get the maximum absolute value of a data_output array. Used for normalising the colour bars of fanout plots.
- Parameters:
array (np.ndarray[Decimal]) – array to get the absoulute maximum
- Returns:
the absolute maximum of the array
- Return type:
Decimal
- Wavefront_Misc.get_current_array = <numpy.vectorize object>
The vectorized function that extracts the currents from an np.ndarray[Wavefronts] array and returns an np.ndarray[Decimal] current array.
- Wavefront_Misc.get_current_from_wavefront(wavefront)
get the voltage of a wavefront. Used as a dummy fucntion to be vectorized, see
get_current_array().- Parameters:
wavefront (Wavefront) – a wavefront
- Returns:
current magnitude of wavefront
- Return type:
Decimal
- Wavefront_Misc.get_voltage_array = <numpy.vectorize object>
The vectorized function that extracts the voltages from an np.ndarray[Wavefronts] array and returns an np.ndarray[Decimal] voltage array.
- Wavefront_Misc.get_voltage_from_wavefront(wavefront)
get the voltage of a wavefront. Used as a dummy fucntion to be vectorized, see
get_voltage_array().- Parameters:
wavefront (Wavefront) – a wavefront
- Returns:
voltage magnitude of wavefront
- Return type:
Decimal
- Wavefront_Misc.handle_default_kwargs(input_kwargs: dict, default_kwargs: dict, copy_default=True)
handles default values for key-word arguments. Alters or creates a copy of the defualt_kwargs to represent the new values provided by the input.
- Parameters:
input_kwargs (dict) – kwargs given by user.
default_kwargs (dict) – default values that kwargs must be one of.
copy_default (bool) – determines if the the defaults array must be copied or not default is True
- Raises:
Exception – ValueError if a kwarg is provided that is not one of the default values.
- Returns:
returns a modfied version of the default_kwargs that includes input changes
- Return type:
dict
- Wavefront_Misc.lcm_gcd_euclid(TL: Decimal, TC: Decimal)
Gets the LCM, GCD and two co-factors KL and KC for time delays TL and TC.
This function makes use of the Euclidean algorithm, which is typically only defined for the integers. In this implementation the functionallity is extended to the rational numbers.
- Parameters:
TL (Decimal) – any rational number, Typically the inductive time delay
TC (Decimal) – any rational number, Typically the capacitve time delay
- Returns:
A dictionary that contains the LCM, GCD and two co-factors.
- Return type:
Dict
- Wavefront_Misc.split_and_translate_to_L_axis(input_array: ndarray, C_value: int)
The first step in the recursive merging process. Seperates the input array into two arrays along the line C = C_value, this line is parallel to the L-axis. Both arrays are padded with ‘zeros’ such that the shape of the input array is maintained. The split array touching the origin and the L-axis will be padded such that it is ‘stationary’, The other array will be shifted to the origin along the L-axis with the padding is ‘ontop’.
- Parameters:
input_array (np.ndarray) – array to be split.
C_value (int) – The value on the C-axis in which the array is split in two. Typically this is C = KC such as to divide along multiplicative merging region boundary.
- Returns:
Stationary and Translated arrays in that order.
- Return type:
tuple( np.ndarray , np.ndarray )
- Wavefront_Misc.split_outer_inner_default_kwargs(input_kwargs: dict, outer_defaults: dict, inner_defaults: dict, handle_kwargs: bool = True, copy_default: bool = True)
Splits input_kwargs into two seperate dictionaries, One for outer function kwargs and one for an inner function kwargs.
- Parameters:
input_kwargs (dict) – kwargs passed to outer function
outer_defaults (dict) – default kwargs for the outer function
inner_defaults (dict) – default kwargs for the inner function
handle_kwargs (bool, optional) – if
handle_default_kwargs()must be called, decides if default values must be populated for return dicts, defaults to True.copy_default (bool, optional) – if provided defaults must be coppeid or passed by reference, defaults to True
- Raises:
ValueError – if keywords are not found in either of the defaults
- Returns:
dictionaries for inner and outer functions (outer_function_dict, inner_function_dict)
- Return type:
tuple( Dict , Dict )
- Wavefront_Misc.translate_along_L_axis(input_array: ndarray, L_value: int)
The second step in the recursive merigng process. Shifts an array L_value units along the L-axis, and pads it with zeros so that the input shape is maintained.
- Parameters:
input_array (np.ndarray) – array to be translated.
L_value (int) – the extent to which the array is shifted.
- Returns:
the shifted array.
- Return type:
np.ndarray