batplot 1.8.4__py3-none-any.whl → 1.8.11__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.
- batplot/__init__.py +1 -1
- batplot/args.py +22 -4
- batplot/batch.py +12 -0
- batplot/batplot.py +383 -132
- batplot/converters.py +171 -122
- batplot/cpc_interactive.py +319 -161
- batplot/data/USER_MANUAL.md +49 -0
- batplot/electrochem_interactive.py +120 -80
- batplot/interactive.py +1766 -81
- batplot/modes.py +12 -11
- batplot/operando.py +22 -0
- batplot/operando_ec_interactive.py +390 -16
- batplot/session.py +85 -9
- batplot/style.py +198 -21
- {batplot-1.8.4.dist-info → batplot-1.8.11.dist-info}/METADATA +1 -1
- {batplot-1.8.4.dist-info → batplot-1.8.11.dist-info}/RECORD +20 -20
- {batplot-1.8.4.dist-info → batplot-1.8.11.dist-info}/WHEEL +1 -1
- {batplot-1.8.4.dist-info → batplot-1.8.11.dist-info}/licenses/LICENSE +0 -0
- {batplot-1.8.4.dist-info → batplot-1.8.11.dist-info}/entry_points.txt +0 -0
- {batplot-1.8.4.dist-info → batplot-1.8.11.dist-info}/top_level.txt +0 -0
batplot/__init__.py
CHANGED
batplot/args.py
CHANGED
|
@@ -141,6 +141,7 @@ def _print_general_help() -> None:
|
|
|
141
141
|
"How to run (basics):\n"
|
|
142
142
|
" [1D(XY) curves]\n"
|
|
143
143
|
" batplot file1.xy file2.qye [option1] [option2] # 1D curves, read the first two columns as X and Y axis by default\n"
|
|
144
|
+
" batplot file1.xy file2.xy --1d --stack --i # Plot 1st derivatives with interactive menu\n"
|
|
144
145
|
" batplot allfiles # Plot all files in current directory on same figure\n"
|
|
145
146
|
" batplot allfiles /path/to/dir # Plot all files in specified directory\n"
|
|
146
147
|
" batplot allfiles --i # Plot all files with interactive menu\n"
|
|
@@ -208,7 +209,8 @@ def _print_xy_help() -> None:
|
|
|
208
209
|
"Examples:\n"
|
|
209
210
|
" batplot a.xye:1.5406 b.qye --stack --i\n"
|
|
210
211
|
" batplot a.dat b.xy --wl 1.54 --i\n"
|
|
211
|
-
" batplot pattern.qye ticks.cif:1.54 --i\n
|
|
212
|
+
" batplot pattern.qye ticks.cif:1.54 --i\n"
|
|
213
|
+
" batplot file1.xy file2.xy --1d --stack --i # Plot 1st derivatives with interactive menu\n\n"
|
|
212
214
|
"Plot all files together:\n"
|
|
213
215
|
" batplot allfiles # Plot all XY files on same figure\n"
|
|
214
216
|
" batplot allfiles /path/to/dir # Plot all XY files in specified directory\n"
|
|
@@ -241,6 +243,8 @@ def _print_xy_help() -> None:
|
|
|
241
243
|
" --kchik : multiply y by x for EXAFS kχ(k) plots (sets labels to k (Å⁻¹) vs kχ(k) (Å⁻¹))\n"
|
|
242
244
|
" --k2chik : multiply y by x² for EXAFS k²χ(k) plots (sets labels to k (Å⁻¹) vs k²χ(k) (Å⁻²))\n"
|
|
243
245
|
" --k3chik : multiply y by x³ for EXAFS k³χ(k) plots (sets labels to k (Å⁻¹) vs k³χ(k) (Å⁻³))\n"
|
|
246
|
+
" --1d : plot the first derivative (dy/dx) of the datasets\n"
|
|
247
|
+
" --2d : plot the first derivative (dy/dx) of the datasets (alias for --1d)\n"
|
|
244
248
|
" --xrange/-r <min> <max> : set x-axis range, e.g. --xrange 0 10\n"
|
|
245
249
|
" --out/-o <filename> : save figure to file, e.g. --out file.svg\n"
|
|
246
250
|
" --xaxis <type> : set x-axis type (Q, 2theta, r, k, energy, rft, time, or user defined)\n"
|
|
@@ -248,6 +252,14 @@ def _print_xy_help() -> None:
|
|
|
248
252
|
" --ro : swap x and y axes (exchange x and y values before plotting)\n"
|
|
249
253
|
" e.g. --xaxis time --ro plots time as y-axis and voltage as x-axis\n"
|
|
250
254
|
" --wl <float> : set wavelength for Q conversion for all files, e.g. --wl 1.5406\n"
|
|
255
|
+
" --convert/-c <from> <to> : convert XRD data and export to 'converted' subfolder:\n"
|
|
256
|
+
" - <wl1> <wl2> : convert 2θ from wavelength1 to wavelength2\n"
|
|
257
|
+
" - <wl> q : convert 2θ (with wavelength) to Q space\n"
|
|
258
|
+
" - q <wl> : convert Q space to 2θ (with wavelength)\n"
|
|
259
|
+
" Examples:\n"
|
|
260
|
+
" batplot file.xye --convert 1.54 0.25\n"
|
|
261
|
+
" batplot file.xye --convert 1.54 q\n"
|
|
262
|
+
" batplot file.qye --convert q 1.54\n"
|
|
251
263
|
" File wavelength syntax : specify wavelength(s) per file using colon syntax:\n"
|
|
252
264
|
" - file:wl : single wavelength (for Q conversion or CIF 2theta calculation)\n"
|
|
253
265
|
" - file:wl1:wl2 : dual wavelength (convert 2theta→Q using wl1, then Q→2theta using wl2)\n"
|
|
@@ -332,12 +344,15 @@ def _print_op_help() -> None:
|
|
|
332
344
|
"Operando contour plots\n\n"
|
|
333
345
|
"Example usage:\n"
|
|
334
346
|
" batplot --operando --interactive --wl 0.25995 # Interactive mode with Q conversion\n"
|
|
335
|
-
" batplot --operando --xaxis 2theta # Using 2theta axis\n
|
|
347
|
+
" batplot --operando --xaxis 2theta # Using 2theta axis\n"
|
|
348
|
+
" batplot --operando --1d --interactive # Plot derivatives as contour with interactive menu\n"
|
|
349
|
+
" batplot --operando --2d --interactive # Plot derivatives (alias for --1d)\n\n"
|
|
336
350
|
" • Folder should contain XY files (.xy/.xye/.qye/.dat).\n"
|
|
337
351
|
" • Intensity scale is auto-adjusted between min/max values.\n"
|
|
338
352
|
" • If no .qye present, provide --xaxis 2theta or set --wl for Q conversion.\n"
|
|
339
353
|
" • If a .mpt file is present, an EC side panel is added for dual-panel mode.\n"
|
|
340
|
-
" • Without a .mpt file, operando-only mode shows the contour plot alone.\n
|
|
354
|
+
" • Without a .mpt file, operando-only mode shows the contour plot alone.\n"
|
|
355
|
+
" • --1d / --2d: plot the first derivative (dy/dx) of each scan as a contour plot.\n\n"
|
|
341
356
|
"Interactive (--interactive): resize axes/canvas, change colormap, set intensity range (oz),\n"
|
|
342
357
|
"EC y-axis options (time ↔ ions), geometry tweaks, toggle spines/ticks/labels,\n"
|
|
343
358
|
"print/export/import style, save session.\n"
|
|
@@ -416,7 +431,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
416
431
|
parser.add_argument("--out", "-o", type=str, help=argparse.SUPPRESS)
|
|
417
432
|
parser.add_argument("--errors", action="store_true", help=argparse.SUPPRESS)
|
|
418
433
|
parser.add_argument("--xaxis", type=str, help=argparse.SUPPRESS)
|
|
419
|
-
parser.add_argument("--convert", "-c", nargs="
|
|
434
|
+
parser.add_argument("--convert", "-c", nargs=2, metavar=("FROM", "TO"),
|
|
435
|
+
help="Convert XRD data: wavelength-to-wavelength (e.g., 1.54 0.25), wavelength-to-Q (e.g., 1.54 q), or Q-to-wavelength (e.g., q 1.54). Exports to 'converted' subfolder.")
|
|
420
436
|
parser.add_argument("--wl", type=float, help=argparse.SUPPRESS)
|
|
421
437
|
parser.add_argument("--fullprof", nargs="+", type=float, help=argparse.SUPPRESS)
|
|
422
438
|
parser.add_argument("--norm", action="store_true", help=argparse.SUPPRESS)
|
|
@@ -453,6 +469,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
453
469
|
help=argparse.SUPPRESS)
|
|
454
470
|
parser.add_argument("--readcolcsv", nargs=2, type=int, metavar=('X_COL', 'Y_COL'),
|
|
455
471
|
help=argparse.SUPPRESS)
|
|
472
|
+
parser.add_argument("--1d", action="store_true", dest="derivative_1d", help=argparse.SUPPRESS)
|
|
473
|
+
parser.add_argument("--2d", action="store_true", dest="derivative_2d", help=argparse.SUPPRESS)
|
|
456
474
|
return parser
|
|
457
475
|
|
|
458
476
|
|
batplot/batch.py
CHANGED
|
@@ -646,6 +646,18 @@ def batch_process(directory: str, args):
|
|
|
646
646
|
else:
|
|
647
647
|
x_plot = x
|
|
648
648
|
|
|
649
|
+
# Calculate first derivative if requested (after axis conversion)
|
|
650
|
+
if getattr(args, 'derivative_1d', False) or getattr(args, 'derivative_2d', False):
|
|
651
|
+
# Calculate dy/dx using numpy gradient
|
|
652
|
+
# numpy.gradient handles non-uniform spacing automatically
|
|
653
|
+
if len(y) > 1:
|
|
654
|
+
dy_dx = np.gradient(y, x_plot)
|
|
655
|
+
y = dy_dx
|
|
656
|
+
else:
|
|
657
|
+
# Single point or empty - cannot calculate derivative
|
|
658
|
+
print(f"Warning: Cannot calculate derivative for {fname}: insufficient data points")
|
|
659
|
+
continue
|
|
660
|
+
|
|
649
661
|
# Normalize if --norm flag is set
|
|
650
662
|
if getattr(args, 'norm', False):
|
|
651
663
|
if y.size:
|