batplot 1.8.27__tar.gz → 1.8.29__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.
- batplot-1.8.29/PKG-INFO +361 -0
- batplot-1.8.29/README.md +310 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/__init__.py +1 -1
- {batplot-1.8.27 → batplot-1.8.29}/batplot/args.py +197 -156
- {batplot-1.8.27 → batplot-1.8.29}/batplot/batch.py +9 -6
- {batplot-1.8.27 → batplot-1.8.29}/batplot/batplot.py +120 -26
- {batplot-1.8.27 → batplot-1.8.29}/batplot/cli.py +0 -14
- {batplot-1.8.27 → batplot-1.8.29}/batplot/converters.py +114 -6
- {batplot-1.8.27 → batplot-1.8.29}/batplot/cpc_interactive.py +45 -26
- {batplot-1.8.27 → batplot-1.8.29}/batplot/data/CHANGELOG.md +42 -49
- {batplot-1.8.27 → batplot-1.8.29}/batplot/data/USER_MANUAL.md +39 -18
- {batplot-1.8.27 → batplot-1.8.29}/batplot/electrochem_interactive.py +142 -101
- {batplot-1.8.27 → batplot-1.8.29}/batplot/interactive.py +111 -75
- {batplot-1.8.27 → batplot-1.8.29}/batplot/manual.py +1 -1
- {batplot-1.8.27 → batplot-1.8.29}/batplot/modes.py +6 -6
- {batplot-1.8.27 → batplot-1.8.29}/batplot/operando.py +9 -9
- {batplot-1.8.27 → batplot-1.8.29}/batplot/operando_ec_interactive.py +108 -57
- {batplot-1.8.27 → batplot-1.8.29}/batplot/plotting.py +21 -7
- {batplot-1.8.27 → batplot-1.8.29}/batplot/readers.py +18 -18
- {batplot-1.8.27 → batplot-1.8.29}/batplot/session.py +19 -4
- {batplot-1.8.27 → batplot-1.8.29}/batplot/style.py +36 -11
- {batplot-1.8.27 → batplot-1.8.29}/batplot/version_check.py +7 -6
- batplot-1.8.29/batplot.egg-info/PKG-INFO +361 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot.egg-info/SOURCES.txt +0 -1
- {batplot-1.8.27 → batplot-1.8.29}/pyproject.toml +1 -1
- batplot-1.8.27/PKG-INFO +0 -204
- batplot-1.8.27/README.md +0 -153
- batplot-1.8.27/USER_MANUAL.md +0 -568
- batplot-1.8.27/batplot.egg-info/PKG-INFO +0 -204
- {batplot-1.8.27 → batplot-1.8.29}/LICENSE +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/MANIFEST.in +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/NOTICE +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/cif.py +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/color_utils.py +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/config.py +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/dev_upgrade.py +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/ui.py +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot/utils.py +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot.egg-info/dependency_links.txt +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot.egg-info/entry_points.txt +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot.egg-info/requires.txt +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/batplot.egg-info/top_level.txt +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/setup.cfg +0 -0
- {batplot-1.8.27 → batplot-1.8.29}/setup.py +0 -0
batplot-1.8.29/PKG-INFO
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: batplot
|
|
3
|
+
Version: 1.8.29
|
|
4
|
+
Summary: Interactive plotting tool for material science (1D plot) and electrochemistry (GC, CV, dQ/dV, CPC, operando) with batch processing
|
|
5
|
+
Author-email: Tian Dai <tianda@uio.no>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Tian Dai
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/chem-plot/batplot
|
|
29
|
+
Project-URL: Repository, https://github.com/chem-plot/batplot
|
|
30
|
+
Project-URL: Issues, https://github.com/chem-plot/batplot/issues
|
|
31
|
+
Classifier: Programming Language :: Python
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Classifier: Operating System :: OS Independent
|
|
40
|
+
Classifier: Intended Audience :: Science/Research
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
42
|
+
Requires-Python: >=3.9
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
License-File: NOTICE
|
|
46
|
+
Requires-Dist: numpy>=1.21.0
|
|
47
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
48
|
+
Requires-Dist: rich>=10.0.0
|
|
49
|
+
Requires-Dist: openpyxl>=3.0.0
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# batplot
|
|
53
|
+
|
|
54
|
+
**Interactive plotting tool for battery and materials characterization data**
|
|
55
|
+
|
|
56
|
+
`batplot` is a Python CLI tool for visualizing and analyzing electrochemical and structural characterization data with interactive styling and session management. The electrochemistry and operando plots were inspired from Amalie Skurtveit's python scripts (https://github.com/piieceofcake?tab=repositories).
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Electrochemistry Modes**: Galvanostatic cycling (GC), cyclic voltammetry (CV), differential capacity (dQdV), capacity per cycle (CPC) with multi-file support
|
|
61
|
+
- **Normal xy plot**: Designed for XRD, PDF, XAS (XANES/EXAFS) but also support other types
|
|
62
|
+
- **Operando Analysis**: Correlate in-situ characterizations (XRD/PDF/XAS) with electrochemical data
|
|
63
|
+
- **Interactive plotting**: Real-time editing customized for each type of plottings
|
|
64
|
+
- **Session Persistence**: Save and reload complete plot states with `.pkl` files
|
|
65
|
+
- **Style Management**: Import/export plot styles as `.bps`/`.bpsg` files
|
|
66
|
+
- **Batch Processing**: Export each file separately with `--all`
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install batplot
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Quick Start
|
|
75
|
+
|
|
76
|
+
Tutorial: https://drive.google.com/file/d/1NTFJWNBbWW4mgz0H5ZelGjuOBWxoFgkr/view
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 1D (XY) Mode — XRD, PDF, XAS and much more
|
|
81
|
+
|
|
82
|
+
In batplot, --xaxis is frequently used to indicate the data type.
|
|
83
|
+
|
|
84
|
+
### Basic plotting
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
|
|
88
|
+
# Specify X-axis type (Q, 2theta, r, k, energy, time or any user defined names)
|
|
89
|
+
# By defauly, batplot will skip the header lines, plot the first and second columns as x and y
|
|
90
|
+
# Q and q are equivalent (case-insensitive)
|
|
91
|
+
batplot pattern.xye --xaxis 2theta
|
|
92
|
+
batplot data.qye --xaxis q
|
|
93
|
+
batplot data.txt --xaxis whatever
|
|
94
|
+
|
|
95
|
+
# Set X-axis range
|
|
96
|
+
batplot pattern.xye --xaxis 2theta --xrange 10 80
|
|
97
|
+
|
|
98
|
+
# Save to file (default .svg if no extension)
|
|
99
|
+
batplot pattern.xye --xaxis 2theta --out figure
|
|
100
|
+
batplot pattern.txt --xaxis Energy --out figure.png
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Wavelength and Q conversion for XRD data
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Convert 2θ to Q using wavelength (Å), --xaxis is no longer needed as providing wavelength is implying that user wants to convert and plot the data in Q space
|
|
107
|
+
batplot data.raw --wl 1.5406
|
|
108
|
+
|
|
109
|
+
# Per-file wavelength: file.xye:1.54, in this case --xaxis is also not needed and files will be plotted in Q space
|
|
110
|
+
batplot scan1.brml:1.5406 scan2.xye:0.7093
|
|
111
|
+
|
|
112
|
+
# Convert and export to converted/ subfolder (q and Q equivalent)
|
|
113
|
+
batplot data.xye --convert 1.54 q
|
|
114
|
+
batplot data.qye --convert q 1.54
|
|
115
|
+
|
|
116
|
+
# With --readcol for custom column layout (e.g. 2θ in col 3, intensity in col 4)
|
|
117
|
+
batplot data.csv --readcol 3 4 --convert 1.54 q
|
|
118
|
+
batplot f1.txt --readcol 2 3 f2.txt --readcol 5 6 --convert 1.54 q
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Stacking and normalization
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Stack curves vertically (auto-normalizes)
|
|
125
|
+
batplot file1.xy file2.xy --stack
|
|
126
|
+
|
|
127
|
+
# Control spacing between stacked curves
|
|
128
|
+
batplot file1.xy file2.xy --stack --delta 0.15
|
|
129
|
+
|
|
130
|
+
# Normalize intensity to 0–1 (without stacking)
|
|
131
|
+
batplot file.xy --norm
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Dual y-axis (right y-axis)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Plot selected files on the right y-axis (--ry disables --stack)
|
|
138
|
+
batplot file1.xy --ry file2.xy --ry file3.xy file4.xy --ry --interactive
|
|
139
|
+
# Files 1, 2, 4 use right y-axis; file 3 uses left y-axis
|
|
140
|
+
|
|
141
|
+
# With --txaxis: right y-axis curves use the top x-axis (default: shared bottom x)
|
|
142
|
+
batplot file1.xy --ry file2.xy --txaxis --interactive
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Column selection and multi-curve
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Read columns 2 and 3 as X, Y (1-indexed)
|
|
149
|
+
batplot data.xy --readcol 2 3
|
|
150
|
+
|
|
151
|
+
# Per-file columns
|
|
152
|
+
batplot file1.xy --readcol 2 3 file2.xy --readcol 4 5
|
|
153
|
+
|
|
154
|
+
# Multiple curves from same file (cols 1,2 and 1,3)
|
|
155
|
+
batplot data.xy --readcol 1 2 1 3
|
|
156
|
+
|
|
157
|
+
# Range: col 1 as x, cols 2–20 as 19 y-curves
|
|
158
|
+
batplot file.txt --readcol 1 2-20
|
|
159
|
+
|
|
160
|
+
# With --convert: use custom columns when converting XRD data
|
|
161
|
+
batplot data.csv --readcol 3 4 --convert 1.54 q
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Derivatives and EXAFS
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Plot first derivative (dy/dx)
|
|
168
|
+
batplot file.xy --1d --stack
|
|
169
|
+
|
|
170
|
+
# EXAFS k-weighting
|
|
171
|
+
batplot data.chik --chik # χ(k)
|
|
172
|
+
batplot data.chik --k2chik # k²χ(k), most common
|
|
173
|
+
batplot data.chik --k3chik --xrange 2 12
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Interactive menu
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Open interactive menu for styling, ranges, export, session save
|
|
180
|
+
batplot pattern.xye --interactive
|
|
181
|
+
batplot file1.xy file2.xy --stack --interactive
|
|
182
|
+
batplot allfiles --xaxis 2theta --xrange 15 75 --interactive
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Electrochemistry Mode
|
|
188
|
+
|
|
189
|
+
### Data export requirements from instruments
|
|
190
|
+
|
|
191
|
+
- **Neware**: Customized report — check all boxes
|
|
192
|
+
- **Biologic**: Export all info to .mpt file
|
|
193
|
+
|
|
194
|
+
### Galvanostatic cycling (GC)
|
|
195
|
+
|
|
196
|
+
GC mode plots potential vs. capacity for each charge/discharge cycle—the primary visualization for battery cycling data. Batplot automatically detects cycles from Neware `.csv` or Biologic `.mpt` files, assigns each cycle a distinct color, and supports both specific capacity (mAh/g) and raw capacity. For `.mpt` files, pass `--mass` (mg) to compute specific capacity. Discontinuous or paused experiments are handled by splitting data into contiguous charge/discharge segments. Use the interactive menu to customize colors, visibility, and export.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# From .csv (capacity in file)
|
|
200
|
+
batplot battery.csv --gc
|
|
201
|
+
|
|
202
|
+
# From .mpt (requires --mass in mg)
|
|
203
|
+
batplot battery.mpt --gc --mass 7.0
|
|
204
|
+
|
|
205
|
+
# With interactive menu
|
|
206
|
+
batplot battery.csv --gc --interactive
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Cyclic voltammetry (CV)
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
batplot cyclic.mpt --cv
|
|
213
|
+
batplot cyclic.mpt --cv --interactive
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Differential capacity (dQ/dV)
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
batplot battery.csv --dqdv
|
|
220
|
+
batplot battery.csv --dqdv --interactive
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Capacity per cycle (CPC)
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Single file
|
|
227
|
+
batplot stability.csv --cpc
|
|
228
|
+
batplot stability.mpt --cpc --mass 5.4
|
|
229
|
+
|
|
230
|
+
# Multiple files with individual colors
|
|
231
|
+
batplot file1.csv file2.mpt --cpc --mass 6.0 --interactive
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Time vs potential
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Plot time (h) vs potential from CSV/MPT
|
|
238
|
+
batplot battery.csv --xaxis time --interactive
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Potential window (custom potential–time .mpt)
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Two columns: potential, time. Use --pw and --cd to plot as GC
|
|
245
|
+
batplot custom.mpt --gc --pw 0.01 3 --cd 0.2 --interactive
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Operando Mode
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Contour from folder of .xy/.xye/.qye/.dat
|
|
254
|
+
batplot --operando --interactive
|
|
255
|
+
|
|
256
|
+
# With folder path
|
|
257
|
+
batplot /path/to/data --operando --interactive
|
|
258
|
+
|
|
259
|
+
# Q conversion from 2θ
|
|
260
|
+
batplot --operando --wl 0.25995 --interactive
|
|
261
|
+
|
|
262
|
+
# Derivative contour
|
|
263
|
+
batplot --operando --1d --interactive
|
|
264
|
+
|
|
265
|
+
# With CIF tick labels
|
|
266
|
+
batplot folder phase.cif:1.54 --operando --interactive
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Plotting multiple files
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# All XY files in current directory on same figure
|
|
275
|
+
batplot allfiles
|
|
276
|
+
batplot allfiles --stack --interactive
|
|
277
|
+
|
|
278
|
+
# Only specific extension (natural-sorted)
|
|
279
|
+
batplot allxyfiles
|
|
280
|
+
batplot "/path/to/data" allnorfiles --interactive
|
|
281
|
+
|
|
282
|
+
# Explicit file list
|
|
283
|
+
batplot file1.xye file2.qye structure.cif:1.54 --stack --interactive
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Batch export (--all)
|
|
289
|
+
|
|
290
|
+
Export each file as a separate figure to `Figures/`:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
batplot --all
|
|
294
|
+
batplot --all --format png
|
|
295
|
+
batplot --all --xaxis 2theta --xrange 10 80
|
|
296
|
+
batplot --all style.bps --gc --mass 7
|
|
297
|
+
|
|
298
|
+
# With --readcol for custom columns (put --readcol before style file)
|
|
299
|
+
batplot --all --readcol 2 3 --xaxis 2theta
|
|
300
|
+
batplot --all --readcol 2 3 style.bps --xaxis 2theta
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Supported File Formats
|
|
306
|
+
|
|
307
|
+
| Type | Formats |
|
|
308
|
+
|------|---------|
|
|
309
|
+
| **Electrochemistry** | `.csv` (Neware), `.mpt` (Biologic), `.xlsx` (Landt/Lanhe CPC) |
|
|
310
|
+
| **XRD / PDF** | `.xye`, `.xy`, `.qye`, `.dat`, `.csv`, `.txt`; Bruker `.brml`, `.raw` |
|
|
311
|
+
| **XAS** | `.nor`, `.chik`, `.chir` |
|
|
312
|
+
| **Generic** | Use `--readcol` and `--xaxis` for custom formats |
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Interactive Features
|
|
317
|
+
|
|
318
|
+
With `--interactive`:
|
|
319
|
+
- **Cycle/Scan Control**: Toggle visibility, change colors
|
|
320
|
+
- **Styling**: Line widths, markers, fonts
|
|
321
|
+
- **Axes**: Labels, limits, ticks, spine styles
|
|
322
|
+
- **Export**: Sessions (`.pkl`), styles (`.bps`/`.bpsg`), high-res images
|
|
323
|
+
- **Live Preview**: All changes update in real-time
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Help & Documentation
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
batplot --help # General help
|
|
331
|
+
batplot --help xy # XY mode guide
|
|
332
|
+
batplot --help ec # Electrochemistry guide
|
|
333
|
+
batplot --help op # Operando guide
|
|
334
|
+
batplot --version # Version and release notes
|
|
335
|
+
batplot --manual # Open illustrated manual
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
- [USER_MANUAL.md](USER_MANUAL.md) — Detailed usage and workflows
|
|
339
|
+
- [FLAGS_REFERENCE.md](FLAGS_REFERENCE.md) — Complete flag reference by mode
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Requirements
|
|
344
|
+
|
|
345
|
+
- Python ≥ 3.9
|
|
346
|
+
- numpy
|
|
347
|
+
- matplotlib
|
|
348
|
+
|
|
349
|
+
## License
|
|
350
|
+
|
|
351
|
+
See [LICENSE](LICENSE)
|
|
352
|
+
|
|
353
|
+
## Author & Contact
|
|
354
|
+
|
|
355
|
+
Tian Dai
|
|
356
|
+
tianda@uio.no
|
|
357
|
+
University of Oslo
|
|
358
|
+
https://www.mn.uio.no/kjemi/english/people/aca/tianda/
|
|
359
|
+
https://github.com/chem-plot/
|
|
360
|
+
|
|
361
|
+
**Subscribe for Updates**: Join batplot-lab@kjemi.uio.no for updates. If not from UiO, email sympa@kjemi.uio.no with subject: "subscribe batplot-lab@kjemi.uio.no your-name"
|
batplot-1.8.29/README.md
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# batplot
|
|
2
|
+
|
|
3
|
+
**Interactive plotting tool for battery and materials characterization data**
|
|
4
|
+
|
|
5
|
+
`batplot` is a Python CLI tool for visualizing and analyzing electrochemical and structural characterization data with interactive styling and session management. The electrochemistry and operando plots were inspired from Amalie Skurtveit's python scripts (https://github.com/piieceofcake?tab=repositories).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Electrochemistry Modes**: Galvanostatic cycling (GC), cyclic voltammetry (CV), differential capacity (dQdV), capacity per cycle (CPC) with multi-file support
|
|
10
|
+
- **Normal xy plot**: Designed for XRD, PDF, XAS (XANES/EXAFS) but also support other types
|
|
11
|
+
- **Operando Analysis**: Correlate in-situ characterizations (XRD/PDF/XAS) with electrochemical data
|
|
12
|
+
- **Interactive plotting**: Real-time editing customized for each type of plottings
|
|
13
|
+
- **Session Persistence**: Save and reload complete plot states with `.pkl` files
|
|
14
|
+
- **Style Management**: Import/export plot styles as `.bps`/`.bpsg` files
|
|
15
|
+
- **Batch Processing**: Export each file separately with `--all`
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install batplot
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
Tutorial: https://drive.google.com/file/d/1NTFJWNBbWW4mgz0H5ZelGjuOBWxoFgkr/view
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 1D (XY) Mode — XRD, PDF, XAS and much more
|
|
30
|
+
|
|
31
|
+
In batplot, --xaxis is frequently used to indicate the data type.
|
|
32
|
+
|
|
33
|
+
### Basic plotting
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
|
|
37
|
+
# Specify X-axis type (Q, 2theta, r, k, energy, time or any user defined names)
|
|
38
|
+
# By defauly, batplot will skip the header lines, plot the first and second columns as x and y
|
|
39
|
+
# Q and q are equivalent (case-insensitive)
|
|
40
|
+
batplot pattern.xye --xaxis 2theta
|
|
41
|
+
batplot data.qye --xaxis q
|
|
42
|
+
batplot data.txt --xaxis whatever
|
|
43
|
+
|
|
44
|
+
# Set X-axis range
|
|
45
|
+
batplot pattern.xye --xaxis 2theta --xrange 10 80
|
|
46
|
+
|
|
47
|
+
# Save to file (default .svg if no extension)
|
|
48
|
+
batplot pattern.xye --xaxis 2theta --out figure
|
|
49
|
+
batplot pattern.txt --xaxis Energy --out figure.png
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Wavelength and Q conversion for XRD data
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Convert 2θ to Q using wavelength (Å), --xaxis is no longer needed as providing wavelength is implying that user wants to convert and plot the data in Q space
|
|
56
|
+
batplot data.raw --wl 1.5406
|
|
57
|
+
|
|
58
|
+
# Per-file wavelength: file.xye:1.54, in this case --xaxis is also not needed and files will be plotted in Q space
|
|
59
|
+
batplot scan1.brml:1.5406 scan2.xye:0.7093
|
|
60
|
+
|
|
61
|
+
# Convert and export to converted/ subfolder (q and Q equivalent)
|
|
62
|
+
batplot data.xye --convert 1.54 q
|
|
63
|
+
batplot data.qye --convert q 1.54
|
|
64
|
+
|
|
65
|
+
# With --readcol for custom column layout (e.g. 2θ in col 3, intensity in col 4)
|
|
66
|
+
batplot data.csv --readcol 3 4 --convert 1.54 q
|
|
67
|
+
batplot f1.txt --readcol 2 3 f2.txt --readcol 5 6 --convert 1.54 q
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Stacking and normalization
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Stack curves vertically (auto-normalizes)
|
|
74
|
+
batplot file1.xy file2.xy --stack
|
|
75
|
+
|
|
76
|
+
# Control spacing between stacked curves
|
|
77
|
+
batplot file1.xy file2.xy --stack --delta 0.15
|
|
78
|
+
|
|
79
|
+
# Normalize intensity to 0–1 (without stacking)
|
|
80
|
+
batplot file.xy --norm
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Dual y-axis (right y-axis)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Plot selected files on the right y-axis (--ry disables --stack)
|
|
87
|
+
batplot file1.xy --ry file2.xy --ry file3.xy file4.xy --ry --interactive
|
|
88
|
+
# Files 1, 2, 4 use right y-axis; file 3 uses left y-axis
|
|
89
|
+
|
|
90
|
+
# With --txaxis: right y-axis curves use the top x-axis (default: shared bottom x)
|
|
91
|
+
batplot file1.xy --ry file2.xy --txaxis --interactive
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Column selection and multi-curve
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Read columns 2 and 3 as X, Y (1-indexed)
|
|
98
|
+
batplot data.xy --readcol 2 3
|
|
99
|
+
|
|
100
|
+
# Per-file columns
|
|
101
|
+
batplot file1.xy --readcol 2 3 file2.xy --readcol 4 5
|
|
102
|
+
|
|
103
|
+
# Multiple curves from same file (cols 1,2 and 1,3)
|
|
104
|
+
batplot data.xy --readcol 1 2 1 3
|
|
105
|
+
|
|
106
|
+
# Range: col 1 as x, cols 2–20 as 19 y-curves
|
|
107
|
+
batplot file.txt --readcol 1 2-20
|
|
108
|
+
|
|
109
|
+
# With --convert: use custom columns when converting XRD data
|
|
110
|
+
batplot data.csv --readcol 3 4 --convert 1.54 q
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Derivatives and EXAFS
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Plot first derivative (dy/dx)
|
|
117
|
+
batplot file.xy --1d --stack
|
|
118
|
+
|
|
119
|
+
# EXAFS k-weighting
|
|
120
|
+
batplot data.chik --chik # χ(k)
|
|
121
|
+
batplot data.chik --k2chik # k²χ(k), most common
|
|
122
|
+
batplot data.chik --k3chik --xrange 2 12
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Interactive menu
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Open interactive menu for styling, ranges, export, session save
|
|
129
|
+
batplot pattern.xye --interactive
|
|
130
|
+
batplot file1.xy file2.xy --stack --interactive
|
|
131
|
+
batplot allfiles --xaxis 2theta --xrange 15 75 --interactive
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Electrochemistry Mode
|
|
137
|
+
|
|
138
|
+
### Data export requirements from instruments
|
|
139
|
+
|
|
140
|
+
- **Neware**: Customized report — check all boxes
|
|
141
|
+
- **Biologic**: Export all info to .mpt file
|
|
142
|
+
|
|
143
|
+
### Galvanostatic cycling (GC)
|
|
144
|
+
|
|
145
|
+
GC mode plots potential vs. capacity for each charge/discharge cycle—the primary visualization for battery cycling data. Batplot automatically detects cycles from Neware `.csv` or Biologic `.mpt` files, assigns each cycle a distinct color, and supports both specific capacity (mAh/g) and raw capacity. For `.mpt` files, pass `--mass` (mg) to compute specific capacity. Discontinuous or paused experiments are handled by splitting data into contiguous charge/discharge segments. Use the interactive menu to customize colors, visibility, and export.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# From .csv (capacity in file)
|
|
149
|
+
batplot battery.csv --gc
|
|
150
|
+
|
|
151
|
+
# From .mpt (requires --mass in mg)
|
|
152
|
+
batplot battery.mpt --gc --mass 7.0
|
|
153
|
+
|
|
154
|
+
# With interactive menu
|
|
155
|
+
batplot battery.csv --gc --interactive
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Cyclic voltammetry (CV)
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
batplot cyclic.mpt --cv
|
|
162
|
+
batplot cyclic.mpt --cv --interactive
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Differential capacity (dQ/dV)
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
batplot battery.csv --dqdv
|
|
169
|
+
batplot battery.csv --dqdv --interactive
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Capacity per cycle (CPC)
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Single file
|
|
176
|
+
batplot stability.csv --cpc
|
|
177
|
+
batplot stability.mpt --cpc --mass 5.4
|
|
178
|
+
|
|
179
|
+
# Multiple files with individual colors
|
|
180
|
+
batplot file1.csv file2.mpt --cpc --mass 6.0 --interactive
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Time vs potential
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Plot time (h) vs potential from CSV/MPT
|
|
187
|
+
batplot battery.csv --xaxis time --interactive
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Potential window (custom potential–time .mpt)
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Two columns: potential, time. Use --pw and --cd to plot as GC
|
|
194
|
+
batplot custom.mpt --gc --pw 0.01 3 --cd 0.2 --interactive
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Operando Mode
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Contour from folder of .xy/.xye/.qye/.dat
|
|
203
|
+
batplot --operando --interactive
|
|
204
|
+
|
|
205
|
+
# With folder path
|
|
206
|
+
batplot /path/to/data --operando --interactive
|
|
207
|
+
|
|
208
|
+
# Q conversion from 2θ
|
|
209
|
+
batplot --operando --wl 0.25995 --interactive
|
|
210
|
+
|
|
211
|
+
# Derivative contour
|
|
212
|
+
batplot --operando --1d --interactive
|
|
213
|
+
|
|
214
|
+
# With CIF tick labels
|
|
215
|
+
batplot folder phase.cif:1.54 --operando --interactive
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Plotting multiple files
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# All XY files in current directory on same figure
|
|
224
|
+
batplot allfiles
|
|
225
|
+
batplot allfiles --stack --interactive
|
|
226
|
+
|
|
227
|
+
# Only specific extension (natural-sorted)
|
|
228
|
+
batplot allxyfiles
|
|
229
|
+
batplot "/path/to/data" allnorfiles --interactive
|
|
230
|
+
|
|
231
|
+
# Explicit file list
|
|
232
|
+
batplot file1.xye file2.qye structure.cif:1.54 --stack --interactive
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Batch export (--all)
|
|
238
|
+
|
|
239
|
+
Export each file as a separate figure to `Figures/`:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
batplot --all
|
|
243
|
+
batplot --all --format png
|
|
244
|
+
batplot --all --xaxis 2theta --xrange 10 80
|
|
245
|
+
batplot --all style.bps --gc --mass 7
|
|
246
|
+
|
|
247
|
+
# With --readcol for custom columns (put --readcol before style file)
|
|
248
|
+
batplot --all --readcol 2 3 --xaxis 2theta
|
|
249
|
+
batplot --all --readcol 2 3 style.bps --xaxis 2theta
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Supported File Formats
|
|
255
|
+
|
|
256
|
+
| Type | Formats |
|
|
257
|
+
|------|---------|
|
|
258
|
+
| **Electrochemistry** | `.csv` (Neware), `.mpt` (Biologic), `.xlsx` (Landt/Lanhe CPC) |
|
|
259
|
+
| **XRD / PDF** | `.xye`, `.xy`, `.qye`, `.dat`, `.csv`, `.txt`; Bruker `.brml`, `.raw` |
|
|
260
|
+
| **XAS** | `.nor`, `.chik`, `.chir` |
|
|
261
|
+
| **Generic** | Use `--readcol` and `--xaxis` for custom formats |
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Interactive Features
|
|
266
|
+
|
|
267
|
+
With `--interactive`:
|
|
268
|
+
- **Cycle/Scan Control**: Toggle visibility, change colors
|
|
269
|
+
- **Styling**: Line widths, markers, fonts
|
|
270
|
+
- **Axes**: Labels, limits, ticks, spine styles
|
|
271
|
+
- **Export**: Sessions (`.pkl`), styles (`.bps`/`.bpsg`), high-res images
|
|
272
|
+
- **Live Preview**: All changes update in real-time
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Help & Documentation
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
batplot --help # General help
|
|
280
|
+
batplot --help xy # XY mode guide
|
|
281
|
+
batplot --help ec # Electrochemistry guide
|
|
282
|
+
batplot --help op # Operando guide
|
|
283
|
+
batplot --version # Version and release notes
|
|
284
|
+
batplot --manual # Open illustrated manual
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
- [USER_MANUAL.md](USER_MANUAL.md) — Detailed usage and workflows
|
|
288
|
+
- [FLAGS_REFERENCE.md](FLAGS_REFERENCE.md) — Complete flag reference by mode
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Requirements
|
|
293
|
+
|
|
294
|
+
- Python ≥ 3.9
|
|
295
|
+
- numpy
|
|
296
|
+
- matplotlib
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
See [LICENSE](LICENSE)
|
|
301
|
+
|
|
302
|
+
## Author & Contact
|
|
303
|
+
|
|
304
|
+
Tian Dai
|
|
305
|
+
tianda@uio.no
|
|
306
|
+
University of Oslo
|
|
307
|
+
https://www.mn.uio.no/kjemi/english/people/aca/tianda/
|
|
308
|
+
https://github.com/chem-plot/
|
|
309
|
+
|
|
310
|
+
**Subscribe for Updates**: Join batplot-lab@kjemi.uio.no for updates. If not from UiO, email sympa@kjemi.uio.no with subject: "subscribe batplot-lab@kjemi.uio.no your-name"
|