Commit 8d025dcc authored by mohamedadelnaguib's avatar mohamedadelnaguib
Browse files

Adding input_indices and output_inices to bode_plot to enable seleection of a specific input-output

parent 1ec87437
......@@ -323,6 +323,78 @@ class TransferFunction(CacheableObject, ParametricObject):
fig.suptitle('Bode plot')
return artists
def _calc_plot_size_and_input_output_indics(self, input_indices=None, output_indices=None):
"""Calculate the figure size in case of selecting a specific inputs/outputs pairs along with
calculating the indices for the desired inputs and outputs
Parameters
----------
input_indices
List of integers,If not None will show the plots for the inputs
associated with the given indices.
output_indices
List of integers,If not None will show the plots for the
outputs associated with the given indices.
Returns
-------
number_rows
Number of rows in the bode plot.
number_columns
Number of columns in the bode plot.
list_input_indices
List of specific input indices.
list_output_indices
LList of specific output indices.
"""
match(input_indices, output_indices):
case(None, None):
number_rows = 2 * self.dim_output
number_columns = self.dim_input
list_input_indices = [*range(self.dim_input)]
list_output_indices = [*range(self.dim_output)]
case (None, list()):
assert all([isinstance(item, int) for item in output_indices])
assert all([output_indices[i] in range(-self.dim_output+1, self.dim_output)
for i in range(len(output_indices))]), \
f'Output indices should be any integer value between {-self.dim_output +1} and { self.dim_output-1}'
number_rows = 2 * len(output_indices)
number_columns = self.dim_input
list_input_indices = [*range(self.dim_input)]
list_output_indices = output_indices
case (list(), None):
assert all([isinstance(item, int) for item in input_indices])
assert all([input_indices[i] in range(- self.dim_input+1, self.dim_input)
for i in range(len(input_indices))]), \
f'Input indecies should be any integer value between {-self.dim_input +1} and {self.dim_input-1}'
number_rows = 2 * self.dim_output
number_columns = len(input_indices)
list_input_indices = input_indices
list_output_indices = [*range(self.dim_output)]
case(list(), list()):
assert all([isinstance(item, int) for item in output_indices])
assert all([isinstance(item, int) for item in input_indices])
assert all([output_indices[i] in range(- self.dim_output+1, self.dim_output)
for i in range(len(output_indices))]), \
f'Output indices should be any integer value between {-self.dim_output+1} and {self.dim_output-1}'
assert all([input_indices[i] in range(- self.dim_input+1, self.dim_input)
for i in range(len(input_indices))]), \
f'Input indecies should be any integer value between {-self.dim_input +1} and {self.dim_input-1}'
number_rows = 2 * len(output_indices)
number_columns = len(input_indices)
list_input_indices = input_indices
list_output_indices = output_indices
return number_rows, number_columns, list_input_indices, list_output_indices
def mag_plot(self, w, mu=None, ax=None, ord=None, Hz=False, dB=False, adaptive_opts=None, **mpl_kwargs):
"""Draw the magnitude plot.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment