batplot 1.8.4__tar.gz → 1.8.6__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.

Potentially problematic release.


This version of batplot might be problematic. Click here for more details.

Files changed (84) hide show
  1. {batplot-1.8.4 → batplot-1.8.6}/LICENSE +0 -0
  2. {batplot-1.8.4 → batplot-1.8.6}/MANIFEST.in +0 -0
  3. {batplot-1.8.4/batplot.egg-info → batplot-1.8.6}/PKG-INFO +1 -1
  4. {batplot-1.8.4 → batplot-1.8.6}/README.md +0 -0
  5. {batplot-1.8.4 → batplot-1.8.6}/USER_MANUAL.md +21 -0
  6. {batplot-1.8.4 → batplot-1.8.6}/batplot/__init__.py +1 -1
  7. {batplot-1.8.4/batplot_backup_20251221_101150 → batplot-1.8.6/batplot}/args.py +22 -4
  8. {batplot-1.8.4 → batplot-1.8.6}/batplot/batch.py +12 -0
  9. {batplot-1.8.4 → batplot-1.8.6}/batplot/batplot.py +340 -126
  10. {batplot-1.8.4 → batplot-1.8.6}/batplot/cif.py +0 -0
  11. {batplot-1.8.4 → batplot-1.8.6}/batplot/cli.py +0 -0
  12. {batplot-1.8.4 → batplot-1.8.6}/batplot/color_utils.py +0 -0
  13. {batplot-1.8.4 → batplot-1.8.6}/batplot/config.py +0 -0
  14. batplot-1.8.6/batplot/converters.py +252 -0
  15. {batplot-1.8.4 → batplot-1.8.6}/batplot/cpc_interactive.py +319 -161
  16. {batplot-1.8.4 → batplot-1.8.6}/batplot/data/USER_MANUAL.md +49 -0
  17. {batplot-1.8.4 → batplot-1.8.6}/batplot/electrochem_interactive.py +120 -80
  18. {batplot-1.8.4 → batplot-1.8.6}/batplot/interactive.py +1763 -75
  19. {batplot-1.8.4 → batplot-1.8.6}/batplot/manual.py +0 -0
  20. {batplot-1.8.4 → batplot-1.8.6}/batplot/modes.py +12 -11
  21. {batplot-1.8.4/batplot_backup_20251221_101150 → batplot-1.8.6/batplot}/operando.py +22 -0
  22. {batplot-1.8.4 → batplot-1.8.6}/batplot/operando_ec_interactive.py +390 -16
  23. {batplot-1.8.4 → batplot-1.8.6}/batplot/plotting.py +0 -0
  24. {batplot-1.8.4 → batplot-1.8.6}/batplot/readers.py +0 -0
  25. {batplot-1.8.4 → batplot-1.8.6}/batplot/session.py +85 -9
  26. {batplot-1.8.4 → batplot-1.8.6}/batplot/style.py +198 -21
  27. {batplot-1.8.4 → batplot-1.8.6}/batplot/ui.py +0 -0
  28. {batplot-1.8.4 → batplot-1.8.6}/batplot/utils.py +0 -0
  29. {batplot-1.8.4 → batplot-1.8.6}/batplot/version_check.py +0 -0
  30. {batplot-1.8.4 → batplot-1.8.6/batplot.egg-info}/PKG-INFO +1 -1
  31. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/__init__.py +0 -0
  32. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/args.py +0 -0
  33. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/batch.py +0 -0
  34. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/batplot.py +0 -0
  35. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/cif.py +0 -0
  36. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/cli.py +0 -0
  37. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/color_utils.py +0 -0
  38. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/config.py +0 -0
  39. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/converters.py +0 -0
  40. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/cpc_interactive.py +0 -0
  41. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/electrochem_interactive.py +0 -0
  42. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/interactive.py +0 -0
  43. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/modes.py +0 -0
  44. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/operando.py +0 -0
  45. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/operando_ec_interactive.py +0 -0
  46. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/plotting.py +0 -0
  47. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/readers.py +0 -0
  48. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/session.py +0 -0
  49. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/style.py +0 -0
  50. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/ui.py +0 -0
  51. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/utils.py +0 -0
  52. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251121_223043/version_check.py +0 -0
  53. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/__init__.py +0 -0
  54. {batplot-1.8.4/batplot → batplot-1.8.6/batplot_backup_20251221_101150}/args.py +0 -0
  55. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/batch.py +0 -0
  56. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/batplot.py +0 -0
  57. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/cif.py +0 -0
  58. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/cli.py +0 -0
  59. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/color_utils.py +0 -0
  60. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/config.py +0 -0
  61. {batplot-1.8.4/batplot → batplot-1.8.6/batplot_backup_20251221_101150}/converters.py +0 -0
  62. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/cpc_interactive.py +0 -0
  63. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/electrochem_interactive.py +0 -0
  64. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/interactive.py +0 -0
  65. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/manual.py +0 -0
  66. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/modes.py +0 -0
  67. {batplot-1.8.4/batplot → batplot-1.8.6/batplot_backup_20251221_101150}/operando.py +0 -0
  68. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/operando_ec_interactive.py +0 -0
  69. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/plotting.py +0 -0
  70. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/readers.py +0 -0
  71. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/session.py +0 -0
  72. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/style.py +0 -0
  73. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/ui.py +0 -0
  74. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/utils.py +0 -0
  75. {batplot-1.8.4 → batplot-1.8.6}/batplot_backup_20251221_101150/version_check.py +0 -0
  76. {batplot-1.8.4 → batplot-1.8.6}/pyproject.toml +1 -1
  77. {batplot-1.8.4 → batplot-1.8.6}/setup.py +0 -0
  78. batplot-1.8.4/batplot_backup_20251221_101150/converters.py +0 -204
  79. {batplot-1.8.4 → batplot-1.8.6}/batplot.egg-info/SOURCES.txt +0 -0
  80. {batplot-1.8.4 → batplot-1.8.6}/batplot.egg-info/dependency_links.txt +0 -0
  81. {batplot-1.8.4 → batplot-1.8.6}/batplot.egg-info/entry_points.txt +0 -0
  82. {batplot-1.8.4 → batplot-1.8.6}/batplot.egg-info/requires.txt +0 -0
  83. {batplot-1.8.4 → batplot-1.8.6}/batplot.egg-info/top_level.txt +0 -0
  84. {batplot-1.8.4 → batplot-1.8.6}/setup.cfg +0 -0
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: batplot
3
- Version: 1.8.4
3
+ Version: 1.8.6
4
4
  Summary: Interactive plotting tool for material science (1D plot) and electrochemistry (GC, CV, dQ/dV, CPC, operando) with batch processing
5
5
  Author-email: Tian Dai <tianda@uio.no>
6
6
  License: MIT License
File without changes
@@ -131,8 +131,29 @@ batplot file1.xy file2.xye style.bps --out output.svg
131
131
 
132
132
  batplot file1.xy file2.xye ./Style/style.bps --out output.svg
133
133
  # Normal mode: apply style from relative path to multiple files
134
+
135
+ batplot file1.xy file2.xy --1d --stack --i
136
+ # Plot the first derivative (dy/dx) of file1 and file2 with interactive menu
137
+ ```
138
+
139
+ ### Derivative Plotting
140
+
141
+ The `--1d` and `--2d` flags (both equivalent) allow you to plot the first derivative (dy/dx) of your datasets. This is useful for identifying peaks, inflection points, and analyzing the rate of change in your data.
142
+
143
+ **Examples:**
144
+ ```bash
145
+ batplot file1.xy file2.xy --1d --stack --i
146
+ # Plot 1st derivatives of file1 and file2, stacked with interactive menu
147
+
148
+ batplot allfiles --1d --interactive
149
+ # Plot 1st derivatives of all XY files with interactive menu
150
+
151
+ batplot file1.xy --1d --xrange 10 80
152
+ # Plot 1st derivative with custom X-axis range
134
153
  ```
135
154
 
155
+ **Note:** The derivative is calculated using numpy's gradient function, which automatically handles non-uniform spacing in your X-axis data. The derivative calculation is applied after data loading and axis conversion, but before any transformations (EXAFS k-weighting, normalization, etc.).
156
+
136
157
  ### Wavelength Specification
137
158
 
138
159
  Batplot supports flexible wavelength specification for XRD data conversion and CIF tick calculation. You can specify wavelengths globally using `--wl` or per-file using colon syntax.
@@ -1,5 +1,5 @@
1
1
  """batplot: Interactive plotting for battery data visualization."""
2
2
 
3
- __version__ = "1.8.4"
3
+ __version__ = "1.8.6"
4
4
 
5
5
  __all__ = ["__version__"]
@@ -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\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\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\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="+", help=argparse.SUPPRESS)
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
 
@@ -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: