-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdodo.py
More file actions
203 lines (180 loc) · 7.17 KB
/
dodo.py
File metadata and controls
203 lines (180 loc) · 7.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env python3
from __future__ import annotations
from pathlib import Path
RAW_DATA_DIR = Path("research/lab_data")
SCRIPTS_DIR = Path("research/scripts")
PROCESSED_DIR = Path("research/processed_data")
FIGURES_DIR = Path("research/figures")
PAPER_FIGURES_DIR = Path("doc/figs")
DOC_DIR = Path("doc")
def task_svg_to_pdf():
for fig in ["circuit"]:
figfile = str(PAPER_FIGURES_DIR / fig)
yield {
"name": fig,
"actions": [f"inkscape {figfile+'.svg'} --export-pdf={figfile+'.pdf'} -z"],
"file_dep": [figfile + ".svg"],
"targets": [figfile + ".pdf"],
}
def task_plot_figures():
gitt_data = str(
RAW_DATA_DIR
/ "2133Parameterisation_25degLGM50LT_HOT_1_END_14_11_2025_07_47_08.csv"
)
utils = str(SCRIPTS_DIR / "utils.py")
for name in [
"gitt_ocv",
"gitt_soc",
"nominal_capacity",
"pulse_windows",
"gitt_hyperparameters",
"interpolations",
"transient_fitting",
]:
script = str(SCRIPTS_DIR / ("plot_" + name + ".py"))
figname = FIGURES_DIR / (name + ".pgf")
yield {
"name": name,
"actions": ["python3 " + " ".join((script, gitt_data, "5", str(figname)))],
"file_dep": [script, utils, gitt_data],
"targets": [figname],
}
def task_plot_fitting_errors():
script = str(SCRIPTS_DIR / "plot_multiple_fitting_losses.py")
utils = str(SCRIPTS_DIR / "utils.py")
loss_data_1 = str(PROCESSED_DIR / "mlp001_fitting_errors_25degC.csv")
loss_data_2 = str(PROCESSED_DIR / "mlp001_full_pulse_fitting_errors_25degC.csv")
figname = FIGURES_DIR / "fitting_loss.pgf"
return {
"actions": ["python3 " + " ".join((script, loss_data_1, loss_data_2, str(figname)))],
"file_dep": [script, utils, loss_data_1, loss_data_2],
"targets": [figname],
}
def task_plot_wltp_validation():
script = str(SCRIPTS_DIR / "plot_wltp_validation.py")
utils = str(SCRIPTS_DIR / "utils.py")
model = str(SCRIPTS_DIR / "model.py")
param_file = str(PROCESSED_DIR / "mlp001_parameters_25degC.csv")
ocv_file = str(PROCESSED_DIR / "mlp001_ocv_25degC.csv")
cycler_file = str(RAW_DATA_DIR / "MLP001_wltp_25degC.xlsx")
figname = FIGURES_DIR / "wltp_validation.pgf"
return {
"actions": [
"python3 "
+ " ".join(
(script, cycler_file, ocv_file, param_file, "2.132", str(figname))
)
],
"file_dep": [script, utils, model, param_file, ocv_file, cycler_file],
"targets": [figname],
}
def task_plot_parameters():
script = str(SCRIPTS_DIR / "plot_parameters.py")
param_file = str(PROCESSED_DIR / "MLP001_params.csv")
ocv_file = str(PROCESSED_DIR / "MLP001_ocv.csv")
figname = FIGURES_DIR / "parameters.pgf"
return {
"actions": [
"python3 "
+ " ".join(
(script, param_file, ocv_file, str(figname))
)
],
"file_dep": [script, param_file, ocv_file],
"targets": [figname],
}
def task_sync_figures_to_paper():
fig_files = [action["targets"][0] for action in task_plot_figures()]
fig_files.append(task_plot_fitting_errors()["targets"][0])
fig_files.append(task_plot_wltp_validation()["targets"][0])
fig_files.append(task_plot_parameters()["targets"][0])
return {
"actions": [f"rsync -avh {FIGURES_DIR}/ {PAPER_FIGURES_DIR}/"],
"file_dep": fig_files,
"targets": [PAPER_FIGURES_DIR / f.name for f in fig_files],
"verbosity": 2,
}
def task_pgf_to_pdf():
all_synced_figs = task_sync_figures_to_paper()["targets"]
pgf_targets = [fig for fig in all_synced_figs if fig.suffix == ".pgf"]
for pgffile in pgf_targets:
ret = {
"name": pgffile.name,
"actions": [f"{PAPER_FIGURES_DIR/'pgf2svg.sh'} {pgffile.stem}"],
"file_dep": [pgffile, PAPER_FIGURES_DIR / "pgf2svg.sh"],
"targets": [str(pgffile)[:-4] + ".svg"],
}
yield ret
def task_run_parameteriser_on_full_pulse():
data_file = RAW_DATA_DIR / "MLP001_25degC.xlsx"
par_file = PROCESSED_DIR / "mlp001_full_pulse_fitting_parameters_25degC.csv"
ocv_file = PROCESSED_DIR / "mlp001_full_pulse_fitting_ocv_25degC.csv"
mse_file = PROCESSED_DIR / "mlp001_full_pulse_fitting_errors_25degC.csv"
return {
"file_dep": [
data_file,
SCRIPTS_DIR / "fitter.py",
SCRIPTS_DIR / "run_parameteriser_full_pulse.py",
],
"targets": [par_file, ocv_file, mse_file],
"actions": [
f"python3 {SCRIPTS_DIR / 'run_parameteriser_full_pulse.py'} {data_file} -o {ocv_file} -p {par_file} -e {mse_file} -t 25"
],
"verbosity": 2,
}
def task_run_parameteriser():
for temperature in [5, 10, 15, 25, 40]:
data_file = RAW_DATA_DIR / f"MLP001_{temperature}degC.xlsx"
par_file = PROCESSED_DIR / f"mlp001_parameters_{temperature}degC.csv"
ocv_file = PROCESSED_DIR / f"mlp001_ocv_{temperature}degC.csv"
mse_file = PROCESSED_DIR / f"mlp001_fitting_errors_{temperature}degC.csv"
yield {
"name": data_file.stem,
"file_dep": [
data_file,
SCRIPTS_DIR / "fitter.py",
SCRIPTS_DIR / "run_parameteriser.py",
],
"targets": [par_file, ocv_file, mse_file],
"actions": [
f"python3 {SCRIPTS_DIR / 'run_parameteriser.py'} {data_file} -o {ocv_file} -p {par_file} -e {mse_file} -t {temperature}"
],
"verbosity": 2,
}
def task_combine_parameter_files():
paramfiles = [str(task["targets"][0]) for task in task_run_parameteriser()]
outfile = PROCESSED_DIR / "MLP001_params.csv"
return {
"file_dep": paramfiles + [SCRIPTS_DIR / "combine_paramfiles.sh"],
"targets": [outfile],
"actions": [f"bash {str(SCRIPTS_DIR / 'combine_paramfiles.sh')} {' '.join(paramfiles)} > {str(outfile)}"]
}
def task_combine_ocv_files():
paramfiles = [str(task["targets"][1]) for task in task_run_parameteriser()]
outfile = PROCESSED_DIR / "MLP001_ocv.csv"
return {
"file_dep": paramfiles + [SCRIPTS_DIR / "combine_paramfiles.sh"],
"targets": [outfile],
"actions": [f"bash {str(SCRIPTS_DIR / 'combine_paramfiles.sh')} {' '.join(paramfiles)} > {str(outfile)}"]
}
# def task_compile_doc():
# fig_deps = task_sync_figures_to_paper()["targets"]
# fig_deps += [task["targets"][0] for task in task_svg_to_pdf()]
# return {
# "actions": [
# f"cd {DOC_DIR} && pdflatex -shell-escape main.tex && bibtex main && pdflatex main.tex && pdflatex main.tex && cd .."
# ],
# "file_dep": [
# DOC_DIR / "main.tex",
# DOC_DIR / "method.tex",
# DOC_DIR / "details.tex",
# DOC_DIR / "validation.tex",
# DOC_DIR / "limitations.tex",
# DOC_DIR / "background.tex",
# DOC_DIR / "conclusions.tex",
# DOC_DIR / "references.bib",
# ]
# + fig_deps,
# "targets": [DOC_DIR / "main.pdf"],
# "verbosity": 2,
# }