majoplot 0.1.0__py3-none-any.whl
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.
- majoplot/__init__.py +0 -0
- majoplot/__main__.py +25 -0
- majoplot/app/__init__.py +0 -0
- majoplot/app/cli.py +259 -0
- majoplot/app/gui.py +6 -0
- majoplot/config.json +11 -0
- majoplot/domain/base.py +433 -0
- majoplot/domain/importers/PPMS_Resistivity.py +128 -0
- majoplot/domain/importers/VSM.py +109 -0
- majoplot/domain/importers/XRD.py +62 -0
- majoplot/domain/muti_axes_spec.py +172 -0
- majoplot/domain/scenarios/PPMS_Resistivity/RT.py +119 -0
- majoplot/domain/scenarios/VSM/MT.py +131 -0
- majoplot/domain/scenarios/VSM/MT_insert.py +135 -0
- majoplot/domain/scenarios/VSM/MT_reliability_analysis.py +145 -0
- majoplot/domain/scenarios/XRD/Compare.py +104 -0
- majoplot/domain/utils.py +87 -0
- majoplot/gui/__init__.py +0 -0
- majoplot/gui/main.py +529 -0
- majoplot/infra/plotters/matplot.py +337 -0
- majoplot/infra/plotters/origin.py +1006 -0
- majoplot/infra/plotters/origin_utils/originlab_type_library.py +403 -0
- majoplot-0.1.0.dist-info/METADATA +81 -0
- majoplot-0.1.0.dist-info/RECORD +27 -0
- majoplot-0.1.0.dist-info/WHEEL +4 -0
- majoplot-0.1.0.dist-info/entry_points.txt +2 -0
- majoplot-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from copy import copy
|
|
3
|
+
|
|
4
|
+
from ...base import *
|
|
5
|
+
from ...muti_axes_spec import StackAxesSpec
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
FIGSIZE = (10, 10)
|
|
9
|
+
|
|
10
|
+
T = "Temperature (K)"
|
|
11
|
+
H = "Magnetic Field (Oe)"
|
|
12
|
+
|
|
13
|
+
M = "DC Moment Free Ctr (emu)"
|
|
14
|
+
Mfit = "DC Free Fit"
|
|
15
|
+
Mfix = "DC Moment Fixed Ctr (emu)"
|
|
16
|
+
SD = "DC Squid Drift"
|
|
17
|
+
CP = "Center Position (mm)"
|
|
18
|
+
DCC = "DC Calculated Center (mm)"
|
|
19
|
+
|
|
20
|
+
_headers_group = [
|
|
21
|
+
(T,M), (T,Mfix),
|
|
22
|
+
(T,Mfit),(T,SD),
|
|
23
|
+
(T,CP), (T,DCC),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
class MT_reliability_analysis:
|
|
27
|
+
data_summary_label_names = ["H","cooling_type"]
|
|
28
|
+
axes_label_names = ("material","date","raw_data", "H", "Y_axis")
|
|
29
|
+
figure_label_names = ("material","date", "raw_data","H")
|
|
30
|
+
figure_summary_label_names = ("raw_data","date")
|
|
31
|
+
max_axes_in_one_figure = 0
|
|
32
|
+
project_to_child_folder_label_names = {"material":"date","date":"material"}
|
|
33
|
+
parent_folder_name = "MT"
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def preprocess(cls, raw_datas:list[Data])->list[Data]:
|
|
37
|
+
datas = []
|
|
38
|
+
for raw_data in raw_datas:
|
|
39
|
+
raw_labels = raw_data.labels
|
|
40
|
+
raw_headers = raw_data.headers
|
|
41
|
+
raw_points = raw_data.points
|
|
42
|
+
iT = raw_headers[T]
|
|
43
|
+
iH = raw_headers[H]
|
|
44
|
+
|
|
45
|
+
check_deque = []
|
|
46
|
+
|
|
47
|
+
current_points = []
|
|
48
|
+
current_cool_type = "ZFC"
|
|
49
|
+
try:
|
|
50
|
+
current_points.append(raw_points[0])
|
|
51
|
+
H_stage = round(raw_points[0, iH])
|
|
52
|
+
except KeyError:
|
|
53
|
+
return []
|
|
54
|
+
|
|
55
|
+
def append_data():
|
|
56
|
+
nonlocal current_points, check_deque, datas
|
|
57
|
+
nonlocal current_cool_type
|
|
58
|
+
current_points.append(check_deque.pop(0))
|
|
59
|
+
labels = copy(raw_labels)
|
|
60
|
+
labels["H"] = LabelValue(H_stage, "Oe")
|
|
61
|
+
if current_points[-1][iT] < current_points[0][iT]:
|
|
62
|
+
unused = True
|
|
63
|
+
labels["cooling_type"] = "cooling"
|
|
64
|
+
else:
|
|
65
|
+
unused = False
|
|
66
|
+
if current_cool_type == "ZFC":
|
|
67
|
+
labels["cooling_type"] = "ZFC"
|
|
68
|
+
current_cool_type = "FC"
|
|
69
|
+
else:
|
|
70
|
+
labels["cooling_type"] = "FC"
|
|
71
|
+
current_cool_type = "ZFC"
|
|
72
|
+
labels["scenario"] = "MT"
|
|
73
|
+
labels.summary_names = cls.data_summary_label_names
|
|
74
|
+
current_points_array = np.array(current_points)
|
|
75
|
+
for _headers in _headers_group:
|
|
76
|
+
special_labels = copy(labels)
|
|
77
|
+
special_labels["Y_axis"] = _headers[1]
|
|
78
|
+
datas.append(
|
|
79
|
+
Data(
|
|
80
|
+
labels=special_labels,
|
|
81
|
+
_headers=_headers,
|
|
82
|
+
points=current_points_array[:,[iT,raw_headers[_headers[1]]]],
|
|
83
|
+
ignore_outliers=IgnoreOutlierSpec(
|
|
84
|
+
min_gap_base=5e-7,
|
|
85
|
+
min_gap_multiple=10
|
|
86
|
+
),
|
|
87
|
+
unused=unused,
|
|
88
|
+
))
|
|
89
|
+
|
|
90
|
+
for point in raw_points[1:]:
|
|
91
|
+
check_deque.append(point)
|
|
92
|
+
if len(check_deque) == 2:
|
|
93
|
+
# not the same H?
|
|
94
|
+
if abs(check_deque[1][iH] - H_stage) > 2:
|
|
95
|
+
append_data()
|
|
96
|
+
current_points = [check_deque.pop()]
|
|
97
|
+
H_stage = round(current_points[0][iH])
|
|
98
|
+
current_cool_type = "ZFC"
|
|
99
|
+
# not the same heating curve?
|
|
100
|
+
elif (check_deque[0][iT] - current_points[0][iT])>2 and (check_deque[0][iT] - check_deque[1][iT])>2:
|
|
101
|
+
append_data()
|
|
102
|
+
current_points = [check_deque.pop()]
|
|
103
|
+
else:
|
|
104
|
+
# the same curve
|
|
105
|
+
current_points.append(check_deque.pop(0))
|
|
106
|
+
else:
|
|
107
|
+
while check_deque:
|
|
108
|
+
append_data()
|
|
109
|
+
return datas
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@classmethod
|
|
113
|
+
def make_axes_spec(cls,axes_labels:LabelDict)->AxesSpec:
|
|
114
|
+
return AxesSpec(
|
|
115
|
+
x_axis_title=T,
|
|
116
|
+
y_axis_title=axes_labels["Y_axis"],
|
|
117
|
+
axis_title_font_size=6,
|
|
118
|
+
major_grid=None,
|
|
119
|
+
major_tick=TickSpec(),
|
|
120
|
+
legend=LegendSpec(fontsize=4),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@classmethod
|
|
125
|
+
def make_figure_spec(cls,figure_labels, axes_pool:Iterable[Axes])->FigureSpec:
|
|
126
|
+
H_stages = {}
|
|
127
|
+
for axes in axes_pool:
|
|
128
|
+
H_stages[axes.labels["H"]] = None
|
|
129
|
+
|
|
130
|
+
figure_name = f"{figure_labels.brief_summary}-{",".join(str(H_stage) for H_stage in H_stages)}"
|
|
131
|
+
|
|
132
|
+
return FigureSpec(
|
|
133
|
+
name=figure_name,
|
|
134
|
+
title=None,
|
|
135
|
+
global_fontsize=6,
|
|
136
|
+
figsize=FIGSIZE,
|
|
137
|
+
linestyle_cycle= ("-", "--"),
|
|
138
|
+
linecolor_cycle = ("black", "red"),
|
|
139
|
+
linemarker_cycle = ("o","o","s","s","^","^","v","v","d","d","*","*","x","x","+","+"),
|
|
140
|
+
alpa_cycle = (1.0,),
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
@classmethod
|
|
144
|
+
def make_muti_axes_spec(cls, axes_pool:list[Axes])->MutiAxesSpec|FAIL|None:
|
|
145
|
+
return StackAxesSpec(nrows=3, ncols=2)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from copy import deepcopy
|
|
3
|
+
|
|
4
|
+
from ...base import *
|
|
5
|
+
from ...muti_axes_spec import StackAxesSpec
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
FIGSIZE = (8, 6)
|
|
9
|
+
STACK_FIGSIZE = (8,4)
|
|
10
|
+
|
|
11
|
+
class Compare:
|
|
12
|
+
"""
|
|
13
|
+
EXP_RAW1, EXP_RAW2, CIF_RAW1, EXP_RAW3 CIF_RAW2
|
|
14
|
+
->
|
|
15
|
+
StackFigure(
|
|
16
|
+
Axes1( EXP_DATA1, CIF_DATA1 ),
|
|
17
|
+
Axes2( EXP_DATA2, CIF_DATA1 ),
|
|
18
|
+
Axes3( EXP_DATA3, CIF_DATA1 ),
|
|
19
|
+
)
|
|
20
|
+
"""
|
|
21
|
+
data_summary_label_names = ["raw_data"]
|
|
22
|
+
standard_summary_label_names = ["standard_name"]
|
|
23
|
+
axes_label_names = ("raw_data","date","standard_name")
|
|
24
|
+
figure_label_names = ("date","standard_name")
|
|
25
|
+
figure_summary_label_names = ("date","standard_name")
|
|
26
|
+
max_axes_in_one_figure = 0
|
|
27
|
+
project_to_child_folder_label_names = {"date":None}
|
|
28
|
+
parent_folder_name = "XRD"
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def preprocess(cls, raw_datas:list[Data])->list[Data]:
|
|
32
|
+
_headers = ("2θ","I")
|
|
33
|
+
standard_raw_data = None
|
|
34
|
+
raw_experiment_datas = []
|
|
35
|
+
for raw_data in raw_datas:
|
|
36
|
+
if raw_data.labels["source"] == "cif":
|
|
37
|
+
if standard_raw_data == None:
|
|
38
|
+
standard_labels = raw_data.labels
|
|
39
|
+
standard_points = raw_data.points[:,0:2]
|
|
40
|
+
standard_raw_data = Data(labels=standard_labels, _headers=_headers,points=standard_points)
|
|
41
|
+
else:
|
|
42
|
+
raw_experiment_datas.append(raw_data)
|
|
43
|
+
|
|
44
|
+
_headers = ()
|
|
45
|
+
if raw_experiment_datas:
|
|
46
|
+
com_date = raw_experiment_datas[-1].labels["date"]
|
|
47
|
+
datas = []
|
|
48
|
+
for raw_data in raw_experiment_datas:
|
|
49
|
+
labels = LabelDict()
|
|
50
|
+
labels["instrument"] = raw_data.labels["instrument"]
|
|
51
|
+
labels["raw_data"] = raw_data.labels["raw_data"]
|
|
52
|
+
labels["date"] = com_date
|
|
53
|
+
if standard_raw_data:
|
|
54
|
+
labels["standard_name"] = standard_raw_data.labels["raw_data"]
|
|
55
|
+
else:
|
|
56
|
+
labels["standard_name"] = ""
|
|
57
|
+
experiment_labels = deepcopy(labels)
|
|
58
|
+
experiment_labels.summary_names = cls.data_summary_label_names
|
|
59
|
+
datas.append(
|
|
60
|
+
Data(labels=experiment_labels, _headers=_headers, points=raw_data.points)
|
|
61
|
+
)
|
|
62
|
+
if standard_raw_data:
|
|
63
|
+
standard_labels = deepcopy(labels)
|
|
64
|
+
standard_labels.summary_names = cls.standard_summary_label_names
|
|
65
|
+
xmin, xmax = raw_data.xlim
|
|
66
|
+
mask = (standard_raw_data.points[:,0] >= xmin) & (standard_raw_data.points[:, 0] <= xmax)
|
|
67
|
+
datas.append(
|
|
68
|
+
Data(labels=standard_labels, _headers=_headers, points=standard_raw_data.points[mask])
|
|
69
|
+
)
|
|
70
|
+
return datas
|
|
71
|
+
|
|
72
|
+
@classmethod
|
|
73
|
+
def make_axes_spec(cls, axes_labels)->AxesSpec:
|
|
74
|
+
return AxesSpec(
|
|
75
|
+
x_axis_title="2θ",
|
|
76
|
+
y_axis_title="I",
|
|
77
|
+
major_grid=None,
|
|
78
|
+
major_tick=TickSpec(),
|
|
79
|
+
legend=LegendSpec(),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def make_figure_spec(cls,figure_labels, axes_pool:Iterable[Axes])->FigureSpec:
|
|
85
|
+
figure_name = figure_labels.brief_summary
|
|
86
|
+
figsize = FIGSIZE if len(axes_pool)<2 else STACK_FIGSIZE
|
|
87
|
+
|
|
88
|
+
return FigureSpec(
|
|
89
|
+
name=figure_name,
|
|
90
|
+
title=None,
|
|
91
|
+
figsize=figsize,
|
|
92
|
+
linestyle_cycle= ("-","|"),
|
|
93
|
+
linecolor_cycle = ("black","red"),
|
|
94
|
+
linemarker_cycle = (None,),
|
|
95
|
+
alpa_cycle = (1.0,),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def make_muti_axes_spec(cls, axes_pool:list[Axes])->MutiAxesSpec|FAIL|None:
|
|
100
|
+
count = len(axes_pool)
|
|
101
|
+
if count < 2:
|
|
102
|
+
return None
|
|
103
|
+
else:
|
|
104
|
+
return StackAxesSpec(nrows=count, ncols=1)
|
majoplot/domain/utils.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Iterator
|
|
3
|
+
from .base import *
|
|
4
|
+
|
|
5
|
+
# ========= Axes and Figures ========
|
|
6
|
+
def group_into_axes(all_datas:Iterable[Data], scenario:Scenario)->list[Axes]:
|
|
7
|
+
axes_label_names = scenario.axes_label_names
|
|
8
|
+
make_axes_spec = scenario.make_axes_spec
|
|
9
|
+
|
|
10
|
+
axes_labels_and_data_pools, _ = LabelDict.group(
|
|
11
|
+
((data.labels, data) for data in all_datas if not data.unused),
|
|
12
|
+
group_label_names=axes_label_names,
|
|
13
|
+
)
|
|
14
|
+
axes_pool = []
|
|
15
|
+
for axes_labels, data_pool in axes_labels_and_data_pools:
|
|
16
|
+
spec = make_axes_spec(axes_labels)
|
|
17
|
+
axes_pool.append(Axes(spec, axes_labels, data_pool))
|
|
18
|
+
return axes_pool
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def group_into_figure(all_axes:Iterable[Axes], scenario:Scenario)->list[Figure]:
|
|
22
|
+
figure_label_names = scenario.figure_label_names
|
|
23
|
+
make_figure_spec = scenario.make_figure_spec
|
|
24
|
+
make_muti_axes_spec = scenario.make_muti_axes_spec
|
|
25
|
+
summary_label_names = scenario.figure_summary_label_names
|
|
26
|
+
max_axes_in_one_figure = scenario.max_axes_in_one_figure
|
|
27
|
+
|
|
28
|
+
labels_and_axes_pools, _ = LabelDict.group(
|
|
29
|
+
((axes.labels, axes) for axes in all_axes),
|
|
30
|
+
group_label_names=figure_label_names,
|
|
31
|
+
summary_label_names= summary_label_names,
|
|
32
|
+
group_member_limit=max_axes_in_one_figure
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
figure_pool = []
|
|
36
|
+
for labels, axes_pool in labels_and_axes_pools:
|
|
37
|
+
spec = make_figure_spec(labels, axes_pool)
|
|
38
|
+
muti_axes_spec = make_muti_axes_spec(axes_pool)
|
|
39
|
+
|
|
40
|
+
proj_folder = {}
|
|
41
|
+
for proj_label_name, child_folder_label_name in scenario.project_to_child_folder_label_names.items():
|
|
42
|
+
p_name = str(labels.get(proj_label_name, ""))
|
|
43
|
+
if not p_name:
|
|
44
|
+
p_name = "UNTITLED"
|
|
45
|
+
f_name = str(labels.get(child_folder_label_name, ""))
|
|
46
|
+
proj_folder[p_name] = f"{scenario.parent_folder_name}/{f_name}"
|
|
47
|
+
|
|
48
|
+
if muti_axes_spec is fail_signal:
|
|
49
|
+
for i, axes in enumerate(axes_pool):
|
|
50
|
+
figure_pool.append(
|
|
51
|
+
Figure(
|
|
52
|
+
axes_pool=[axes],
|
|
53
|
+
spec=spec._replace(name=f"{spec.name}_{i}"),
|
|
54
|
+
muti_axes_spec=None,
|
|
55
|
+
labels=labels,
|
|
56
|
+
proj_folder= proj_folder
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
continue
|
|
60
|
+
|
|
61
|
+
figure_pool.append(
|
|
62
|
+
Figure(
|
|
63
|
+
axes_pool=axes_pool,
|
|
64
|
+
spec=spec,
|
|
65
|
+
muti_axes_spec=muti_axes_spec,
|
|
66
|
+
labels=labels,
|
|
67
|
+
proj_folder= proj_folder
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
return figure_pool
|
|
73
|
+
|
|
74
|
+
# ======== Project ========
|
|
75
|
+
def pack_into_project(all_figures:Iterable[Figure])->dict[str,Project]:
|
|
76
|
+
projs = {}
|
|
77
|
+
for figure in all_figures:
|
|
78
|
+
figure_name = figure.spec.name
|
|
79
|
+
for proj_name,folder_name in figure.proj_folder.items():
|
|
80
|
+
projs.setdefault(proj_name, Project()).setdefault(folder_name, folder())[figure_name] = figure
|
|
81
|
+
return projs
|
|
82
|
+
|
|
83
|
+
# ======== Importers ========
|
|
84
|
+
def skip_lines_then_readline(fp:TextIO, skip_lines: int)->str:
|
|
85
|
+
for _ in range(skip_lines):
|
|
86
|
+
fp.readline()
|
|
87
|
+
return fp.readline()
|
majoplot/gui/__init__.py
ADDED
|
File without changes
|