Skip to content

Commit 3d3d9b8

Browse files
authored
Merge pull request #354 from EOMYS-Public/plot
Plot
2 parents f0d852d + ceb4d9c commit 3d3d9b8

File tree

64 files changed

+309368
-274400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+309368
-274400
lines changed

Tests/Methods/Simulation/test_InCurrent_meth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from pyleecan.Classes.Simulation import Simulation
3131
from pyleecan.definitions import DATA_DIR
3232
from pyleecan.Functions.load import load
33+
from pyleecan.Functions.Plot import dict_2D
3334
from pyleecan.Methods.Simulation.Input import InputError
3435
import pytest
3536
from Tests import save_plot_path as save_path
@@ -288,7 +289,8 @@ def test_InputCurrent_DQ(self, test_dict):
288289
assert out.elec.Iq_ref == pytest.approx(test_dict["Iq"], abs=0.01)
289290

290291
# Plot 3-phase current function of time
291-
out.plot_2D_Data("elec.Is", "time", "phase", is_show_fig=False)
292+
# out.plot_2D_Data("elec.Is", "time", "phase", is_show_fig=False)
293+
out.elec.get_Is().plot_2D_Data("time", "phase", is_show_fig=False, **dict_2D)
292294

293295
# Save picture
294296
title = "Id=" + str(test_dict["Id"]) + " Iq=" + str(test_dict["Iq"])

Tests/Methods/Simulation/test_magelmer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pyleecan.Classes.Simu1 import Simu1
1010
from pyleecan.Classes.Output import Output
1111
from pyleecan.Functions.load import load
12+
from pyleecan.Functions.Plot import dict_2D
1213
from pyleecan.definitions import DATA_DIR
1314

1415
# Gather results in the same folder
@@ -100,9 +101,9 @@ def test_ipm_Elmer():
100101
# Run simulation
101102
outp = Output(simu=simu)
102103
simu.run()
103-
# outp.plot_2D_Data("mag.Tem", "time")
104-
# outp.plot_2D_Data("elec.Is", "time", "phase")
105-
# outp.plot_2D_Data("mag.Tem", "time[smallestperiod]")
104+
# outp.mag.Tem.plot_2D_Data("time", **dict_2D)
105+
# outp.elec.get_Is().plot_2D_Data("time", "phase", **dict_2D)
106+
# outp.mag.Tem.plot_2D_Data("time[smallestperiod]", **dict_2D)
106107
# outp.mag.meshsolution.plot_contour(label="B")
107108
# outp.mag.meshsolution.plot_contour(label="A")
108109
# outp.mag.meshsolution.plot_contour(label="J")
@@ -160,9 +161,9 @@ def test_spm_Elmer():
160161
# Run simulation
161162
outp = Output(simu=simu)
162163
simu.run()
163-
outp.plot_2D_Data("mag.Tem", "time")
164-
# outp.plot_2D_Data("elec.Is", "time", "phase")
165-
# outp.plot_2D_Data("mag.Tem", "time[smallestperiod]")
164+
outp.mag.Tem.plot_2D_Data("time", **dict_2D)
165+
# outp.elec.get_Is().plot_2D_Data("time", "phase", **dict_2D)
166+
# outp.mag.Tem.plot_2D_Data("time[smallestperiod]", **dict_2D)
166167
# outp.mag.meshsolution.plot_contour(label="B")
167168
# outp.mag.meshsolution.plot_contour(label="A")
168169
# outp.mag.meshsolution.plot_contour(label="J")

Tests/Methods/Slot/test_HoleUD_meth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pyleecan.Classes.SurfLine import SurfLine
88
from pyleecan.definitions import DATA_DIR
99
from pyleecan.Functions.load import load
10+
from pyleecan.Functions.Plot import dict_2D
1011
from pyleecan.Classes.Simu1 import Simu1
1112
from pyleecan.Classes.MagFEMM import MagFEMM
1213
from pyleecan.Classes.InputCurrent import InputCurrent
@@ -169,13 +170,13 @@ def test_convert_UD(self):
169170
# Plot the result by comparing the two simulation
170171
plt.close("all")
171172

172-
out.plot_2D_Data(
173-
"mag.B",
173+
out.mag.B.plot_2D_Data(
174174
"angle",
175175
data_list=[out2.mag.B],
176176
legend_list=["Normal", "User-Defined"],
177177
save_path=join(save_path, "test_HoleUD.png"),
178178
is_show_fig=False,
179+
**dict_2D,
179180
)
180181

181182

Tests/Plot/Schematics/test_plot_axis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from pyleecan.Classes.MagFEMM import MagFEMM
1818
from pyleecan.Classes.Output import Output
1919
from pyleecan.Functions.load import load
20+
from pyleecan.Functions.Plot import dict_2D
2021
from pyleecan.definitions import DATA_DIR
2122
from pyleecan.Functions.init_fig import init_subplot
2223

@@ -284,7 +285,7 @@ def test_axis_LamWind(CURVE_COLORS):
284285
simu.run()
285286

286287
plt.close("all")
287-
out.plot_2D_Data("mag.B", "angle{rad}", is_show_fig=False)
288+
out.mag.B.plot_2D_Data("angle{rad}", is_show_fig=False, **dict_2D)
288289

289290
fig = plt.gcf()
290291
Br = out.mag.B.components["radial"].get_along("time", "angle")

Tests/Plot/test_PostPlot.py

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from pyleecan.Classes.PostPlot import PostPlot
1717

1818
from pyleecan.Functions.load import load
19+
from pyleecan.Functions.Plot import dict_2D
1920
from pyleecan.definitions import DATA_DIR
2021

2122

@@ -55,31 +56,40 @@ def test_PostPlot():
5556

5657
plot_B_rad_tan_space1 = PostPlot(
5758
method="plot_2D_Data",
58-
param_list=["mag.B", "angle"],
59-
param_dict={
60-
"component_list": ["radial"],
61-
"is_show_fig": False,
62-
"save_path": None,
63-
"fig": fig1,
64-
"ax": axes1[0],
65-
},
59+
quantity="mag.B",
60+
param_list=["angle"],
61+
param_dict=dict(
62+
{
63+
"component_list": ["radial"],
64+
"is_show_fig": False,
65+
"save_path": None,
66+
"fig": fig1,
67+
"ax": axes1[0],
68+
},
69+
**dict_2D
70+
),
6671
)
6772

6873
plot_B_rad_tan_space2 = PostPlot(
6974
method="plot_2D_Data",
70-
param_list=["mag.B", "angle"],
71-
param_dict={
72-
"component_list": ["tangential"],
73-
"is_show_fig": False,
74-
"fig": fig1,
75-
"ax": axes1[1],
76-
},
75+
quantity="mag.B",
76+
param_list=["angle"],
77+
param_dict=dict(
78+
{
79+
"component_list": ["tangential"],
80+
"is_show_fig": False,
81+
"fig": fig1,
82+
"ax": axes1[1],
83+
},
84+
**dict_2D
85+
),
7786
name="plot_B_rad_tan_space",
7887
save_format="png",
7988
)
8089

8190
plot_machine_Tem_time1 = PostPlot(
82-
method="simu.machine.plot",
91+
method="plot",
92+
quantity="simu.machine",
8393
param_dict={
8494
"is_show_fig": False,
8595
"save_path": None,
@@ -90,33 +100,56 @@ def test_PostPlot():
90100

91101
plot_machine_Tem_time2 = PostPlot(
92102
method="plot_2D_Data",
93-
param_list=["mag.Tem", "time"],
94-
param_dict={
95-
"is_show_fig": False,
96-
"fig": fig2,
97-
"ax": axes2[1],
98-
},
103+
quantity="mag.Tem",
104+
param_list=["time"],
105+
param_dict=dict(
106+
{
107+
"is_show_fig": False,
108+
"fig": fig2,
109+
"ax": axes2[1],
110+
},
111+
**dict_2D
112+
),
99113
name="plot_machine_Tem_time",
100114
save_format="png",
101115
)
102116

103117
plot_P_radial_space_svg = PostPlot(
104118
method="plot_2D_Data",
105-
param_list=["force.AGSF", "angle"],
106-
param_dict={
107-
"component_list": ["radial"],
108-
"is_show_fig": False,
109-
},
119+
quantity="force.AGSF",
120+
param_list=["angle"],
121+
param_dict=dict(
122+
{
123+
"component_list": ["radial"],
124+
"is_show_fig": False,
125+
},
126+
**dict_2D
127+
),
110128
name="plot_P_radial_space",
111129
save_format="svg",
112130
)
113131

132+
plot_Is = PostPlot(
133+
method="plot_2D_Data",
134+
quantity="elec.get_Is",
135+
param_list=["time", "phase"],
136+
param_dict=dict(
137+
{
138+
"is_show_fig": False,
139+
},
140+
**dict_2D
141+
),
142+
name="plot_Is",
143+
save_format="png",
144+
)
145+
114146
simu.postproc_list = [
115147
plot_B_rad_tan_space1,
116148
plot_B_rad_tan_space2,
117149
plot_machine_Tem_time1,
118150
plot_machine_Tem_time2,
119151
plot_P_radial_space_svg,
152+
plot_Is,
120153
]
121154

122155
# Run simulations

0 commit comments

Comments
 (0)