1
1
import numpy as np
2
2
import matplotlib .pyplot as plt
3
3
from scipy .optimize import curve_fit
4
- from tkinter import *
5
- from tkinter import filedialog
4
+ from tkinter import filedialog , Tk , Button , Text
5
+
6
+ import matplotlib
7
+ matplotlib .use ('TkAgg' ) # replace the GUI backend
6
8
7
9
8
10
root = Tk () #call tkinter function
@@ -15,7 +17,6 @@ def Main():
15
17
16
18
# Open file
17
19
file_path = filedialog .askopenfilename (initialdir = "/" ) # get the file path
18
- #print(file_path)
19
20
20
21
# Read in raw data from VSM measurement
21
22
raw_data = np .loadtxt (file_path )
@@ -55,24 +56,15 @@ def anisotropy_model(theta, k1, k2):
55
56
txt_output = Text (root , height = 17 , width = 43 )
56
57
txt_output .place (x = 25 ,y = 220 )# place
57
58
58
- txt_output .insert (END , ' Key Parameters ' + "\n \n " )
59
- txt_output .insert (END , ' Saturation moment: {:.3f} Am^2' .format (saturation_moment ) + "\n " )
60
- txt_output .insert (END , ' Coercivity: {:.3f} T' .format (coercivity ) + "\n " )
61
- txt_output .insert (END , ' Remanence: {:.3f} Am^2' .format (remanence ) + "\n " )
62
- txt_output .insert (END , ' Magnetic moment: {:.3f} Am^2' .format (magnetic_moment ) + "\n " )
63
- txt_output .insert (END , ' Anisotropy constants: k1={:.3e} J/m^3, k2={:.3e} J/m^3' .format (k1 , k2 ) + "\n \n " )
64
- txt_output .insert (END , ' Magnetic susceptibility: {:.3e} m^3/kg' .format (np .mean (magnetic_susceptibility )) + "\n " )
65
-
66
- """ Print out key parameters
67
- print('\n Key Parameters \n \n ')
68
- print(' Saturation moment: {:.3f} Am^2'.format(saturation_moment))
69
- print(' Coercivity: {:.3f} T'.format(coercivity))
70
- print(' Remanence: {:.3f} Am^2'.format(remanence))
71
- print(' Magnetic moment: {:.3f} Am^2'.format(magnetic_moment))
72
- print(' Anisotropy constants: k1={:.3e} J/m^3, k2={:.3e} J/m^3'.format(k1, k2))
73
- print(' Magnetic susceptibility: {:.3e} m^3/kg'.format(np.mean(magnetic_susceptibility)))
59
+ txt_output .insert ("end" , " Key Parameters " + "\n \n " )
60
+ txt_output .insert ("end" , " Saturation moment: {:.3f} Am^2" .format (saturation_moment ) + "\n " )
61
+ txt_output .insert ("end" , " Coercivity: {:.3f} T" .format (coercivity ) + "\n " )
62
+ txt_output .insert ("end" , " Remanence: {:.3f} Am^2" .format (remanence ) + "\n " )
63
+ txt_output .insert ("end" , " Magnetic moment: {:.3f} Am^2" .format (magnetic_moment ) + "\n " )
64
+ txt_output .insert ("end" , " Anisotropy constants: k1={:.3e} J/m^3, k2={:.3e} J/m^3" .format (k1 , k2 ) + "\n \n " )
65
+ txt_output .insert ("end" , " Magnetic susceptibility: {:.3e} m^3/kg" .format (np .mean (magnetic_susceptibility )) + "\n " )
74
66
75
- """
67
+
76
68
plt .show () # show graph window
77
69
78
70
0 commit comments