11import matplotlib .pyplot as plt
2- from numpy import min as np_min , max as np_max
32
4- from PySide2 .QtCore import *
5- from PySide2 .QtGui import *
6- from PySide2 .QtWidgets import *
7-
8- from ....Functions .Plot .set_plot_gui_icon import set_plot_gui_icon
93from ....Functions .Plot import dict_2D
104from ....definitions import config_dict
115
126
13- def plot_mmf_unit (self , is_create_appli = True , save_path = None ):
7+ def plot_mmf_unit (self , r_max = 100 , fig = None , is_show_fig = True ):
148 """Plot the winding unit mmf as a function of space
159 Parameters
1610 ----------
17-
1811 self : LamSlotWind
1912 an LamSlotWind object
20- is_create_appli : bool
21- True to create an QApplication (required if not already created by another GUI)
13+ Na : int
14+ Space discretization
15+ fig : Matplotlib.figure.Figure
16+ existing figure to use if None create a new one
17+ is_show_fig : bool
18+ To call show at the end of the method
2219 """
2320
2421 name = ""
@@ -30,55 +27,36 @@ def plot_mmf_unit(self, is_create_appli=True, save_path=None):
3027 name += "Rotor "
3128
3229 # Compute the winding function and mmf
33- wf = self .comp_wind_function (per_a = 1 )
3430 qs = self .winding .qs
35- MMF_U , WF = self .comp_mmf_unit (Nt = 1 , Na = wf .shape [1 ])
31+ p = self .get_pole_pair_number ()
32+ MMF_U , WF = self .comp_mmf_unit (Nt = 1 , Na = 400 * p )
3633
3734 color_list = config_dict ["PLOT" ]["COLOR_DICT" ]["COLOR_LIST" ][:qs ]
3835
39- plot_arg_dict = dict_2D .copy ()
40- plot_arg_dict ["color_list" ] = color_list + ["k" ]
41- plot_arg_dict ["data_list" ] = [MMF_U ]
42-
43- if save_path is not None :
44- WF .plot_2D_Data (
45- "angle{°}" ,
46- "phase[]" ,
47- unit = "A" ,
48- y_min = np_min (MMF_U .values ) * 1.1 ,
49- y_max = np_max (MMF_U .values ) * 1.1 ,
50- is_show_fig = False ,
51- save_path = save_path ,
52- ** plot_arg_dict ,
53- )
54-
55- elif is_create_appli :
56- WF .plot (
57- "angle{°}" ,
58- "phase[]" ,
59- unit = "A" ,
60- z_min = np_min (MMF_U .values ) * 1.1 ,
61- z_max = np_max (MMF_U .values ) * 1.1 ,
62- plot_arg_dict = plot_arg_dict ,
63- is_create_appli = is_create_appli ,
64- frozen_type = 2 ,
65- )
66- else :
67- wid = WF .plot (
68- "angle{°}" ,
69- "phase[]" ,
70- unit = "A" ,
71- z_min = np_min (MMF_U .values ) * 1.1 ,
72- z_max = np_max (MMF_U .values ) * 1.1 ,
73- plot_arg_dict = plot_arg_dict ,
74- is_create_appli = is_create_appli ,
75- frozen_type = 2 ,
76- )
77-
78- wid .setWindowTitle (name + "Phase MMF plot" )
79- set_plot_gui_icon ()
80- # Change default file name
81- wid .canvas .get_default_filename = (
82- lambda : wid .windowTitle ().replace (" " , "_" ).replace (":" , "" ) + ".png"
83- )
84- return wid
36+ fig , axs = plt .subplots (2 , 1 , tight_layout = True , figsize = (8 , 8 ))
37+
38+ dict_2D_0 = dict_2D .copy ()
39+ dict_2D_0 ["color_list" ] = color_list + ["k" ]
40+
41+ WF .plot_2D_Data (
42+ "angle{°}" ,
43+ "phase[]" ,
44+ data_list = [MMF_U ],
45+ fig = fig ,
46+ ax = axs [0 ],
47+ is_show_fig = is_show_fig ,
48+ win_title = name + "phase MMF" ,
49+ ** dict_2D_0 ,
50+ )
51+
52+ dict_2D_0 ["color_list" ] = [color_list [0 ], "k" ]
53+
54+ WF .plot_2D_Data (
55+ "wavenumber=[0," + str (r_max ) + "]" ,
56+ data_list = [MMF_U ],
57+ fig = fig ,
58+ ax = axs [1 ],
59+ is_show_fig = is_show_fig ,
60+ win_title = name + "phase MMF FFT" ,
61+ ** dict_2D_0 ,
62+ )
0 commit comments