itcpr 2.0.0__tar.gz → 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {itcpr-2.0.0 → itcpr-2.0.1}/PKG-INFO +1 -1
- itcpr-2.0.1/itcpr/mumax3.py +71 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/itcpr.egg-info/PKG-INFO +1 -1
- {itcpr-2.0.0 → itcpr-2.0.1}/itcpr.egg-info/SOURCES.txt +1 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/pyproject.toml +1 -1
- {itcpr-2.0.0 → itcpr-2.0.1}/LICENSE +0 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/README.md +0 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/itcpr/__init__.py +0 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/itcpr.egg-info/dependency_links.txt +0 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/itcpr.egg-info/requires.txt +0 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/itcpr.egg-info/top_level.txt +0 -0
- {itcpr-2.0.0 → itcpr-2.0.1}/setup.cfg +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from mpl_toolkits.mplot3d import Axes3D
|
|
4
|
+
|
|
5
|
+
def plot(
|
|
6
|
+
filepath,
|
|
7
|
+
components=["mx", "my", "mz"],
|
|
8
|
+
title="Magnetization vs Time",
|
|
9
|
+
xlabel="Time (s)",
|
|
10
|
+
ylabel="Magnetization",
|
|
11
|
+
colors=None,
|
|
12
|
+
labels=None,
|
|
13
|
+
grid=True,
|
|
14
|
+
figsize=(10, 6),
|
|
15
|
+
show=True,
|
|
16
|
+
three_d=False
|
|
17
|
+
):
|
|
18
|
+
try:
|
|
19
|
+
# Open file manually, read header line
|
|
20
|
+
with open(filepath, 'r') as f:
|
|
21
|
+
header_line = f.readline().lstrip("#").strip()
|
|
22
|
+
column_names = [col.strip().split()[0] for col in header_line.split('\t')]
|
|
23
|
+
|
|
24
|
+
# Load data with cleaned column names
|
|
25
|
+
df = pd.read_csv(filepath, sep=r'\s+', engine='python', skiprows=1, names=column_names)
|
|
26
|
+
print("✅ Cleaned columns:", df.columns.tolist())
|
|
27
|
+
except Exception as e:
|
|
28
|
+
raise ValueError(f"❌ Failed to load file {filepath}: {e}")
|
|
29
|
+
|
|
30
|
+
if three_d:
|
|
31
|
+
title = 'Magnetization dynamics in 3d'
|
|
32
|
+
if all(col in df.columns for col in ["mx", "my", "mz"]):
|
|
33
|
+
fig = plt.figure(figsize=figsize)
|
|
34
|
+
ax = fig.add_subplot(111, projection='3d')
|
|
35
|
+
ax.plot(df["mx"], df["my"], df["mz"], color='blue')
|
|
36
|
+
ax.set_xlabel("Mx")
|
|
37
|
+
ax.set_ylabel("My")
|
|
38
|
+
ax.set_zlabel("Mz")
|
|
39
|
+
ax.set_title(title)
|
|
40
|
+
if grid:
|
|
41
|
+
ax.grid(True)
|
|
42
|
+
if show:
|
|
43
|
+
plt.show()
|
|
44
|
+
else:
|
|
45
|
+
print("⚠️ Cannot plot in 3D. One or more of mx, my, mz not found in columns.")
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
# 2D plot path
|
|
49
|
+
time_col = "t"
|
|
50
|
+
time = df[time_col]
|
|
51
|
+
|
|
52
|
+
plt.figure(figsize=figsize)
|
|
53
|
+
|
|
54
|
+
for i, comp in enumerate(components):
|
|
55
|
+
if comp in df.columns:
|
|
56
|
+
color = colors[i] if colors and i < len(colors) else None
|
|
57
|
+
label = labels[i] if labels and i < len(labels) else comp
|
|
58
|
+
plt.plot(time, df[comp], label=str(label), color=color)
|
|
59
|
+
else:
|
|
60
|
+
print(f"⚠️ Warning: Component '{comp}' not found in columns.")
|
|
61
|
+
|
|
62
|
+
plt.xlabel(xlabel)
|
|
63
|
+
plt.ylabel(ylabel)
|
|
64
|
+
plt.title(title)
|
|
65
|
+
if grid:
|
|
66
|
+
plt.grid(True)
|
|
67
|
+
plt.legend()
|
|
68
|
+
plt.tight_layout()
|
|
69
|
+
if show:
|
|
70
|
+
plt.show()
|
|
71
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|