compphysutils 0.4.0__tar.gz → 0.4.2__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.
Files changed (98) hide show
  1. {compphysutils-0.4.0 → compphysutils-0.4.2}/MANIFEST.in +2 -0
  2. {compphysutils-0.4.0/src/compphysutils.egg-info → compphysutils-0.4.2}/PKG-INFO +7 -2
  3. {compphysutils-0.4.0 → compphysutils-0.4.2}/pyproject.toml +1 -2
  4. {compphysutils-0.4.0 → compphysutils-0.4.2}/setup.cfg +8 -2
  5. compphysutils-0.4.2/src/compphysutils/graphics/__init__.py +3 -0
  6. compphysutils-0.4.2/src/compphysutils/graphics/atom_plot.py +13 -0
  7. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorate/image.py +1 -1
  8. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/fitter.py +12 -9
  9. compphysutils-0.4.2/src/compphysutils/graphics/plot3dcoords +87 -0
  10. compphysutils-0.4.2/src/compphysutils/graphics/plot_types/coord.py +78 -0
  11. compphysutils-0.4.2/src/compphysutils/graphics/plot_types/errorbar.py +47 -0
  12. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/quiver.py +16 -43
  13. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plotconfig +1 -1
  14. compphysutils-0.4.2/src/compphysutils/graphics/plotcoords +22 -0
  15. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plotter.py +75 -10
  16. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/__init__.py +1 -1
  17. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/average.py +1 -1
  18. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/union.py +1 -1
  19. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsecoords +1 -1
  20. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parser.py +27 -0
  21. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/cols.py +11 -2
  22. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_processor.py +1 -1
  23. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/runcombine +1 -1
  24. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/runparser +1 -1
  25. {compphysutils-0.4.0 → compphysutils-0.4.2/src/compphysutils.egg-info}/PKG-INFO +7 -2
  26. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils.egg-info/SOURCES.txt +5 -0
  27. compphysutils-0.4.2/src/compphysutils.egg-info/requires.txt +4 -0
  28. compphysutils-0.4.0/src/compphysutils/graphics/__init__.py +0 -1
  29. compphysutils-0.4.0/src/compphysutils/graphics/plot_types/errorbar.py +0 -11
  30. {compphysutils-0.4.0 → compphysutils-0.4.2}/COPYING.reference +0 -0
  31. {compphysutils-0.4.0 → compphysutils-0.4.2}/LICENSE +0 -0
  32. {compphysutils-0.4.0 → compphysutils-0.4.2}/README.md +0 -0
  33. {compphysutils-0.4.0 → compphysutils-0.4.2}/examples/cluster.cfg +0 -0
  34. {compphysutils-0.4.0 → compphysutils-0.4.2}/examples/na_pyramid_100.cfg +0 -0
  35. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/__init__.py +0 -0
  36. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/Vector.py +0 -0
  37. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/VectorReal.py +0 -0
  38. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/VectorRepresentation.py +0 -0
  39. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/__init__.py +0 -0
  40. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/gencluster +0 -0
  41. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/generator.py +0 -0
  42. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/crystalgen/readCrystalChar.py +0 -0
  43. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorate/__init__.py +0 -0
  44. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorate/arrow.py +0 -0
  45. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorate/line.py +0 -0
  46. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorate/rect.py +0 -0
  47. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorate/text.py +0 -0
  48. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/decorator.py +0 -0
  49. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/fit_types/__init__.py +0 -0
  50. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/fit_types/inverse.py +0 -0
  51. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/fit_types/linear.py +0 -0
  52. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/fit_types/lorentz_peak.py +0 -0
  53. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/fit_types/quadratic.py +0 -0
  54. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/__init__.py +0 -0
  55. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/colormap.py +0 -0
  56. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/fill_between.py +0 -0
  57. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/level.py +0 -0
  58. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/line.py +0 -0
  59. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/linlog.py +0 -0
  60. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/loglog.py +0 -0
  61. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/plot_types/scatter.py +0 -0
  62. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/transformer.py +0 -0
  63. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/transforms/__init__.py +0 -0
  64. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/graphics/transforms/log.py +0 -0
  65. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine.py +0 -0
  66. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/__init__.py +0 -0
  67. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/difference.py +0 -0
  68. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/integrate-field-axis.py +0 -0
  69. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/join-partial.py +0 -0
  70. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/join.py +0 -0
  71. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/map-to-fermi-window.py +0 -0
  72. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/roll-extract.py +0 -0
  73. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/scale.py +0 -0
  74. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/sum.py +0 -0
  75. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/thermal-average.py +0 -0
  76. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/tm-orbital-sum.py +0 -0
  77. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/translate.py +0 -0
  78. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/combine_commands/union-partial.py +0 -0
  79. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/__init__.py +0 -0
  80. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/coord-aims.py +0 -0
  81. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/coord-cub.py +0 -0
  82. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/coord-tm.py +0 -0
  83. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/coord-xyz.py +0 -0
  84. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/csv.py +0 -0
  85. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/eiger.py +0 -0
  86. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/image.py +0 -0
  87. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/parsers/tm-mos.py +0 -0
  88. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/__init__.py +0 -0
  89. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/average.py +0 -0
  90. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/gap.py +0 -0
  91. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/level-spacing.py +0 -0
  92. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/levels.py +0 -0
  93. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/mirror.py +0 -0
  94. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/plane-rotate.py +0 -0
  95. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/post_process/scale.py +0 -0
  96. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils/parser/savepoint.py +0 -0
  97. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils.egg-info/dependency_links.txt +0 -0
  98. {compphysutils-0.4.0 → compphysutils-0.4.2}/src/compphysutils.egg-info/top_level.txt +0 -0
@@ -1,4 +1,6 @@
1
1
  include examples/cluster.cfg examples/na_pyramid_100.cfg
2
2
  include src/compphysutils/crystalgen/gencluster
3
3
  include src/compphysutils/graphics/plotconfig
4
+ include src/compphysutils/graphics/plotcoords
5
+ include src/compphysutils/graphics/plot3dcoords
4
6
  include src/compphysutils/parser/runparser src/compphysutils/parser/parsecoords src/compphysutils/parser/runcombine
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: compphysutils
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Set of utilities for computational condensed matter physics
5
5
  Home-page: https://github.com/StepanMarek/CompPhysUtils
6
6
  Author: Stepan Marek
@@ -11,6 +11,11 @@ Requires-Python: >=3.6
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
  License-File: COPYING.reference
14
+ Requires-Dist: matplotlib>=3.10.1
15
+ Requires-Dist: numpy
16
+ Requires-Dist: scipy
17
+ Requires-Dist: raylib>=5.5.0.0
18
+ Dynamic: license-file
14
19
 
15
20
  # CompPhysUtils
16
21
  ## Collection of Python utilities for Computational Condensed Matter Physicists
@@ -1,6 +1,5 @@
1
1
  [build-system]
2
2
  requires = [
3
- "setuptools>=42",
4
- "wheel"
3
+ "setuptools>=42"
5
4
  ]
6
5
  build-backend = "setuptools.build_meta"
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = compphysutils
3
- version = 0.4.0
3
+ version = 0.4.2
4
4
  author = Stepan Marek
5
5
  description = Set of utilities for computational condensed matter physics
6
6
  long_description = file: README.md
@@ -12,11 +12,16 @@ classifiers =
12
12
  Development Status :: 3 - Alpha
13
13
 
14
14
  [options]
15
- package-dir =
15
+ package_dir =
16
16
  = src
17
17
  include_package_data = True
18
18
  packages = find:
19
19
  python_requires = >=3.6
20
+ install_requires =
21
+ matplotlib >= 3.10.1
22
+ numpy
23
+ scipy
24
+ raylib >= 5.5.0.0
20
25
 
21
26
  [options.packages.find]
22
27
  where = src
@@ -24,6 +29,7 @@ where = src
24
29
  [options.package_data]
25
30
  gencluster = src/compphysutils/crystalgen/gencluster
26
31
  plotconfig = src/compphysutils/graphics/plotconfig
32
+ plot3dcoords = src/compphysutils/graphics/plot3dcoords
27
33
 
28
34
  [egg_info]
29
35
  tag_build =
@@ -0,0 +1,3 @@
1
+ from .atom_plot import atom_colors, atom_sizes
2
+
3
+ __all__ = ["parser"]
@@ -0,0 +1,13 @@
1
+ atom_colors = {
2
+ "H" : [255,255,255,255],
3
+ "C" : [ 0, 0, 0,255],
4
+ "FE" : [210,120, 10,255],
5
+ "AU" : [255,209, 35,255]
6
+ }
7
+
8
+ atom_sizes = {
9
+ "H" : 0.5,
10
+ "C" : 0.7,
11
+ "FE" : 1.2,
12
+ "AU" : 1.5
13
+ }
@@ -4,7 +4,7 @@ import numpy
4
4
  imageAP = argparse.ArgumentParser("Plots the image loaded as dataset to a given axis coordinate dimension.")
5
5
  imageAP.add_argument("imageDataset", help="Name of the dataset containing the RGB(A) data. They should be in an unrolled loop.")
6
6
  imageAP.add_argument("imageRect", nargs=4, type=float, help="Rectangle for the image to be drawn into, in axes coordinates. (x,y,width,height).")
7
- imageAP.add_argument("--shape", type=lambda x: list(map(int, x.split(","))), help="Shape of the image, in format width,height.")
7
+ imageAP.add_argument("--shape", type=int, nargs=2, help="Shape of the image, in format width,height.")
8
8
 
9
9
  def command(axes, datasets, argString):
10
10
  args = imageAP.parse_args(argString)
@@ -86,10 +86,13 @@ def plotFit(dataset, fitFunctionName, axisObj, **fitParams):
86
86
  popt = guesses
87
87
  perr = guesses
88
88
  else:
89
- if len(dataset) == 3:
90
- popt, pcov = curve_fit(fitFunctions[fitFunctionName], dataset[0][ixMin:ixMax+1], dataset[1][ixMin:ixMax+1], sigma=dataset[2][ixMin:ixMax+1], p0=guesses)
91
- else:
92
- popt, pcov = curve_fit(fitFunctions[fitFunctionName], dataset[0][ixMin:ixMax+1], dataset[1][ixMin:ixMax+1], p0=guesses)
89
+ try:
90
+ if len(dataset) == 3:
91
+ popt, pcov = curve_fit(fitFunctions[fitFunctionName], dataset[0][ixMin:ixMax+1], dataset[1][ixMin:ixMax+1], sigma=dataset[2][ixMin:ixMax+1], p0=guesses)
92
+ else:
93
+ popt, pcov = curve_fit(fitFunctions[fitFunctionName], dataset[0][ixMin:ixMax+1], dataset[1][ixMin:ixMax+1], p0=guesses)
94
+ except RuntimeError:
95
+ raise RuntimeError(f'Did not manage to find params for fit {fitParams["fitIndex"]}')
93
96
  perr = []
94
97
  for i in range(len(pcov)):
95
98
  perr.append(pcov[i][i] ** 0.5)
@@ -102,9 +105,9 @@ def plotFit(dataset, fitFunctionName, axisObj, **fitParams):
102
105
  xs.append(xMin + dx*i)
103
106
  ys.append(fitFunctions[fitFunctionName](xMin + dx*i, *popt))
104
107
  if fitParams["fitLabel"]:
105
- axisObj.plot(xs,ys,label=fitParams["fitLabel"],color=next(fitParams["fitColorCycle"]))
108
+ axisObj.plot(xs,ys,label=fitParams["fitLabel"],color=next(fitParams["fitColorCycle"]),ls=next(fitParams["fitLinestyleCycle"]))
106
109
  else:
107
- axisObj.plot(xs,ys,color=next(fitParams["fitColorCycle"]))
110
+ axisObj.plot(xs,ys,color=next(fitParams["fitColorCycle"]),ls=next(fitParams["fitLinestyleCycle"]))
108
111
  # Construct the param string
109
112
  if fitParams["showParams"]:
110
113
  pstring = ""
@@ -118,8 +121,8 @@ def plotFit(dataset, fitFunctionName, axisObj, **fitParams):
118
121
  if fitParams["paramsPlacement"]:
119
122
  # Text anchor is the bottom left corner by default
120
123
  if fitParams["paramsPlacement"] == "tl":
121
- axisObj.text(0.1, 0.9-0.05*(len(popt)-1)-0.05*(fitParams["paramsOffset"]), pstring, transform=axisObj.transAxes)
124
+ axisObj.text(0.1, 0.9-0.07*(len(popt)-1)-0.07*(fitParams["paramsOffset"]), pstring, transform=axisObj.transAxes)
122
125
  else:
123
126
  # Default to top left
124
- axisObj.text(0.1, 0.9-0.05*(len(popt)-1)-0.05*(fitParams["paramsOffset"]), pstring, transform=axisObj.transAxes)
125
- return popt
127
+ axisObj.text(1.1, 0.9-0.07*(len(popt)-1)-0.07*(fitParams["paramsOffset"]), pstring, transform=axisObj.transAxes)
128
+ return popt, perr
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+ from compphysutils.parser import readFile
4
+ import pyray
5
+ from compphysutils.graphics.atom_plot import atom_sizes, atom_colors
6
+ import numpy
7
+ from compphysutils.graphics.plotter import ColorIterator
8
+
9
+ argparser = argparse.ArgumentParser(prog="plot3dcoords", description="Plots the coordinates and optionally isosurfaces using pyraylib.")
10
+ argparser.add_argument("--format", "-f", dest="format", help="Name of the format of the coordinate file.")
11
+ argparser.add_argument("--camera_pos", type=float, nargs=3, help="Initial position of the camera. Default : (0,0,10)", default=(0.0,0.0,10.0))
12
+ argparser.add_argument("--triangles", nargs="*", default=False, help="Filenames containing column triangulation data for surfaces (isosurfaces) to be plotted.")
13
+ argparser.add_argument("--sphere_res", default=30, type=int, help="Resolution of individual spheres - sets rings + sections. [default : 10]")
14
+ argparser.add_argument("coordinate_file", help="Name of the coordinate file to be processed")
15
+ argparser.add_argument("savefile", help="Name of the file into which to save the rendered coordinates")
16
+
17
+ args = argparser.parse_args()
18
+ dataset = readFile(args.coordinate_file, args.format)
19
+ # Init window and start loading models
20
+ pyray.init_window(1024,768, args.savefile)
21
+
22
+ atom_models = []
23
+
24
+ for atom_index in range(len(dataset[0])):
25
+ # TODO : Settable rings+sections
26
+ sphere_mesh = pyray.gen_mesh_sphere(atom_sizes[dataset[3][atom_index].upper()], args.sphere_res, args.sphere_res)
27
+ atom_models.append(pyray.load_model_from_mesh(sphere_mesh))
28
+
29
+ surface_models = []
30
+ if args.triangles:
31
+ for surface_index in range(len(args.triangles)):
32
+ triset = readFile(args.triangles[surface_index], "cols", "0 1 2 3 4 5 6 7 8")
33
+ vertices = numpy.zeros(9*len(triset[0]), dtype=numpy.float32)
34
+ for i in range(len(triset[0])):
35
+ for j in range(9):
36
+ vertices[9*i+j] = triset[j][i]
37
+ mesh = pyray.Mesh(3*len(triset[0]), len(triset[0]), vertices)
38
+ pyray.upload_mesh(mesh, True)
39
+ surface_models.append(pyray.load_model_from_mesh(mesh))
40
+
41
+ # TODO : Allow for custom setting of surface colors
42
+ surface_color = ColorIterator("255,0,0,120 0,0,255,120")
43
+
44
+ camera = pyray.Camera3D()
45
+ camera.position = args.camera_pos
46
+ # TODO : Set other camera parameters from the command line
47
+ camera.up = [0,1,0]
48
+ camera.target = [0,0,0]
49
+ camera.fovy = 90
50
+ camera.projection = pyray.CAMERA_PERSPECTIVE
51
+
52
+ # Models uploaded, start the render loop
53
+ while not pyray.window_should_close():
54
+ pyray.begin_drawing()
55
+ pyray.clear_background(pyray.RAYWHITE)
56
+ pyray.begin_mode_3d(camera)
57
+ # TODO : This is more flexible, but a single model might be more performant for very large structures
58
+ for atom_index in range(len(dataset[0])):
59
+ # Draw the atom
60
+ pyray.draw_model(atom_models[atom_index],
61
+ [dataset[0][atom_index],
62
+ dataset[1][atom_index],
63
+ dataset[2][atom_index]],
64
+ 1.0,
65
+ atom_colors[dataset[3][atom_index].upper()]
66
+ )
67
+ # Draw the surfaces
68
+ for surface_index in range(len(surface_models)):
69
+ pyray.draw_model(surface_models[surface_index],
70
+ [0.0, 0.0, 0.0],
71
+ 1.0,
72
+ list(map(int, next(surface_color))))
73
+ pyray.end_mode_3d()
74
+ pyray.end_drawing()
75
+ # Check for screenshot
76
+ if pyray.is_key_pressed(pyray.KEY_S):
77
+ pyray.take_screenshot(args.savefile)
78
+ # Updating camera
79
+ if pyray.is_mouse_button_down(pyray.MOUSE_BUTTON_LEFT) or pyray.get_mouse_wheel_move() != 0.0:
80
+ pyray.update_camera(camera, pyray.CAMERA_THIRD_PERSON)
81
+
82
+ for atom_index in range(len(dataset[0])):
83
+ pyray.unload_model(atom_models[atom_index])
84
+ # TODO : Fix the segfault on free
85
+ #for surface_index in range(len(surface_models)):
86
+ # pyray.unload_model(surface_models[surface_index])
87
+ pyray.close_window()
@@ -0,0 +1,78 @@
1
+ import argparse
2
+ import numpy
3
+ import matplotlib.tri as mtri
4
+
5
+ ap = argparse.ArgumentParser(description="Simple render of the atomic coordinates from a coord dataset.")
6
+
7
+ ap.add_argument("--view", type=lambda x: list(map(float, x.split(","))), help="Camera position in angular coordinates in degrees (azimuthal,elevation,roll). Default : (0,0,0)", default=[0,0,0])
8
+
9
+ colors = {
10
+ "au" : "#ffcc00",
11
+ "na" : "#ffff00",
12
+ "fe" : "#ff9933",
13
+ "h" : "#ffffff",
14
+ "c" : "#111111",
15
+ "o" : "#ff0000",
16
+ "n" : "#0000ff",
17
+ "s" : "#ffeb00",
18
+ "mo" : "#006792"
19
+ }
20
+
21
+ radii = {
22
+ "au" : 1.5,
23
+ "na" : 1.2,
24
+ "fe" : 1.4,
25
+ "h" : 0.5,
26
+ "c" : 1.0,
27
+ "o" : 1.1,
28
+ "n" : 1.1,
29
+ "s" : 1.3,
30
+ "mo" : 1.3,
31
+ }
32
+
33
+ def plotSpheres(axes3d, position=numpy.array([[0.0],[0.0],[0.0]]), elements=False):
34
+ # Create the mesh
35
+ phi = numpy.linspace(0, numpy.pi*2, 20)
36
+ theta = numpy.linspace(0, numpy.pi, 20)
37
+ theta, phi = numpy.meshgrid(theta, phi)
38
+ phi, theta = phi.flatten(), theta.flatten()
39
+ x0 = numpy.cos(phi) * numpy.sin(theta)
40
+ y0 = numpy.sin(phi) * numpy.sin(theta)
41
+ z0 = numpy.cos(theta)
42
+ # Add triangulation
43
+ tri = mtri.Triangulation(theta, phi)
44
+ for j in range(len(position[0])):
45
+ if not elements:
46
+ x = x0 - position[0,j]
47
+ y = y0 - position[1,j]
48
+ z = z0 - position[2,j]
49
+ axes3d.plot_trisurf(x, y, z, triangles=tri.triangles, edgecolor="none",linewidth=0,antialiased=False,color="b")
50
+ else:
51
+ try:
52
+ x = radii[elements[j].lower()] * x0 - position[0,j]
53
+ y = radii[elements[j].lower()] * y0 - position[1,j]
54
+ z = radii[elements[j].lower()] * z0 - position[2,j]
55
+ except KeyError:
56
+ x = x0 - position[0,j]
57
+ y = y0 - position[1,j]
58
+ z = z0 - position[2,j]
59
+ try:
60
+ axes3d.plot_trisurf(x, y, z, triangles=tri.triangles, edgecolor="none",linewidth=0,antialiased=False,color=colors[elements[j].lower()])
61
+ except KeyError:
62
+ axes3d.plot_trisurf(x, y, z, triangles=tri.triangles, edgecolor="none",linewidth=0,antialiased=False,color="b")
63
+
64
+
65
+ def plot(datasets, axisObj, **plotOptions):
66
+ figure = plotOptions["figure"]
67
+ figure.clf()
68
+ axes = figure.add_axes((0.0,0.0,1.0,1.0),projection="3d")
69
+ axes.set_axis_off()
70
+ args = ap.parse_args(plotOptions["plotArgString"])
71
+ for i in range(len(datasets)):
72
+ #axes.scatter(datasets[i][0], datasets[i][1], datasets[i][2])
73
+ if len(datasets[i]) > 3:
74
+ plotSpheres(axes, position=numpy.array(datasets[i][0:3]), elements=datasets[i][3])
75
+ else:
76
+ plotSpheres(axes, position=numpy.array(datasets[i][0:3]))
77
+ axes.view_init(elev=args.view[1], azim=args.view[0], roll=args.view[2])
78
+ return axes
@@ -0,0 +1,47 @@
1
+ import argparse
2
+
3
+ ap = argparse.ArgumentParser(prog="errorbar", description="Plot scatter with error bounds.")
4
+ ap.add_argument("--lineWidth", default=0, type=float, help="Width of the line joining the points. [default : 0]")
5
+ ap.add_argument("--elineWidth", default=2, type=float, help="Width of the error bar line. [default : 2]")
6
+ ap.add_argument("--singleErr", default="y", choices=["x", "y"], help="When only a single error set is provided, which coordinate it corresponds to.")
7
+
8
+ def plot(datasets, axisObj, datasetLabels=False, **plotOptions):
9
+ args = ap.parse_args(plotOptions["plotArgString"])
10
+ if not datasetLabels:
11
+ datasetLabels = [None] * len(datasets)
12
+ for dataIndex in range(len(datasets)):
13
+ if len(datasets[dataIndex]) >= 4:
14
+ # If at least four columns provided, plot errors on both axes
15
+ axisObj.errorbar(datasets[dataIndex][0],
16
+ datasets[dataIndex][2],
17
+ xerr=datasets[dataIndex][1],
18
+ yerr=datasets[dataIndex][3],
19
+ capsize=4,
20
+ lw=args.lineWidth,
21
+ elinewidth=args.elineWidth,
22
+ marker=next(plotOptions["markerstyleCycle"]),
23
+ label=datasetLabels[dataIndex],
24
+ color=next(plotOptions["colorCycle"]))
25
+ else:
26
+ # Otherwise, just plot one error
27
+ if args.singleErr == "x":
28
+ axisObj.errorbar(datasets[dataIndex][0],
29
+ datasets[dataIndex][1],
30
+ xerr=datasets[dataIndex][2],
31
+ capsize=4,
32
+ lw=args.lineWidth,
33
+ elinewidth=args.elineWidth,
34
+ marker=next(plotOptions["markerstyleCycle"]),
35
+ label=datasetLabels[dataIndex],
36
+ color=next(plotOptions["colorCycle"]))
37
+ else:
38
+ axisObj.errorbar(datasets[dataIndex][0],
39
+ datasets[dataIndex][1],
40
+ yerr=datasets[dataIndex][2],
41
+ capsize=4,
42
+ lw=args.lineWidth,
43
+ elinewidth=args.elineWidth,
44
+ marker=next(plotOptions["markerstyleCycle"]),
45
+ label=datasetLabels[dataIndex],
46
+ color=next(plotOptions["colorCycle"]))
47
+ return axisObj
@@ -13,6 +13,10 @@ ap.add_argument("--scale", default=1, type=float, help="Scale used for the matla
13
13
  ap.add_argument("--scaleUnits", default="xy", help="Scale units used for the matlab primitive. Default : xy")
14
14
  ap.add_argument("--units", default="xy", help="Units used for the matlab primitive. Default : xy")
15
15
  ap.add_argument("--pivot", default="tail", help="Pivot used for the matlab primitive. Default : tail")
16
+ ap.add_argument("--headlength", default=10, type=float, help="Headlength argument passed to the matlab primitive. Default : 10")
17
+ ap.add_argument("--headwidth", default=10, type=float, help="Headlength argument passed to the matlab primitive. Default : 10")
18
+ ap.add_argument("--headaxislength", default=10, type=float, help="Headlength argument passed to the matlab primitive. Default : 10")
19
+ ap.add_argument("--stride", default=1, type=int, help="Optionally, stride the points in both directions to reduce the number of points.")
16
20
 
17
21
  def plot(datasets, axisObj, datasetLabels=False, **plotOptions):
18
22
  args = ap.parse_args(plotOptions["plotArgString"])
@@ -40,6 +44,15 @@ def plot(datasets, axisObj, datasetLabels=False, **plotOptions):
40
44
  if args.normalize:
41
45
  components = components / (numpy.sum(components ** 2, axis=0) ** 0.5)
42
46
  # Change default arrow style to resamble annotation arrows
47
+ if args.stride != 1:
48
+ print(coordinates.shape)
49
+ coordinates = numpy.lib.stride_tricks.as_strided(coordinates,
50
+ shape=(coordinates.shape[0], coordinates.shape[1]//args.stride, coordinates.shape[2]//args.stride),
51
+ strides=(coordinates.strides[0], coordinates.strides[1]*args.stride, coordinates.strides[2]*args.stride))
52
+ print(coordinates.shape)
53
+ components = numpy.lib.stride_tricks.as_strided(components,
54
+ shape=(components.shape[0], components.shape[1]//args.stride, components.shape[2]//args.stride),
55
+ strides=(components.strides[0], components.strides[1]*args.stride, components.strides[2]*args.stride))
43
56
  axisObj.quiver(*coordinates, *components,
44
57
  label=datasetLabels[datasetIndex],
45
58
  color=next(plotOptions["colorCycle"]),
@@ -48,48 +61,8 @@ def plot(datasets, axisObj, datasetLabels=False, **plotOptions):
48
61
  scale_units=args.scaleUnits,
49
62
  units=args.units,
50
63
  pivot=args.pivot,
51
- headlength=10,
52
- headaxislength=10,
53
- headwidth=10
64
+ headlength=args.headlength,
65
+ headaxislength=args.headaxislength,
66
+ headwidth=args.headwidth
54
67
  )
55
68
  return axisObj
56
- #def plot(datasets, axisObj, datasetLabels=False, **plotOptions):
57
- # # Datasets are cols,columns,rows organized
58
- # if not datasetLabels:
59
- # datasetLabels = [False] * len(datasets)
60
- # # Parse arguments
61
- # args = ap.parse_args(plotOptions["plotArgString"])
62
- # # Now, determine stride
63
- # if args.plane == "xy":
64
- # # Keep a constant z
65
- # if args.changeOrder == "xyz":
66
- # # Simplest case - simply take consecutive points - equal to stride 1
67
- # # Find start
68
- # startIndex = args.loneIndex * args.gridsize[0] * args.gridsize[1]
69
- # finalIndex = startIndex + args.gridsize[0] * args.gridsize[1]
70
- # stride = 1
71
- # # Extract the required fields
72
- # for colIndex in range(len(datasets)):
73
- # x = numpy.array(datasets[colIndex][0])
74
- # y = numpy.array(datasets[colIndex][1])
75
- # z = numpy.array(datasets[colIndex][2])
76
- # curr_x = numpy.array(datasets[colIndex][0])
77
- # curr_y = numpy.array(datasets[colIndex][1])
78
- # curr_z = numpy.array(datasets[colIndex][2])
79
- # x_plot = x[startIndex:finalIndex:stride]
80
- # y_plot = y[startIndex:finalIndex:stride]
81
- # curr_x_plot = curr_x[startIndex:finalIndex:stride]
82
- # curr_y_plot = curr_y[startIndex:finalIndex:stride]
83
- # # Plot the quiver
84
- # zValue = z[startIndex]
85
- # zValue = round(zValue, 2)
86
- # axisObj.quiver(x_plot, y_plot, curr_x_plot, curr_y_plot,
87
- # label="$z = "+str(zValue)+"$",
88
- # color=next(plotOptions["colorCycle"]),
89
- # linestyle=next(plotOptions["linestyleCycle"]),
90
- # angles="xy",
91
- # scale=0.3*max((max(curr_x_plot), max(curr_y_plot))),
92
- # units="xy",
93
- # )
94
- # # Return the axis object
95
- # return axisObj
@@ -1,4 +1,4 @@
1
- #!/usr/bin/python3
1
+ #!/usr/bin/env python3
2
2
  import argparse
3
3
  from compphysutils.graphics.plotter import fromConfig
4
4
 
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+ from compphysutils.parser import readFile
4
+ from compphysutils.graphics.plotter import plot
5
+ import matplotlib.pyplot as plt
6
+
7
+ argparser = argparse.ArgumentParser(description="Plots the coordinates, using default parameters.")
8
+ argparser.add_argument("--format", "-f", dest="format", help="Name of the format of the coordinate file.")
9
+ argparser.add_argument("--view", help="View option broadcasted to coord plot : Camera position in angular coordinates in degrees (azimuthal,elevation,roll). Default : (0,0,0)", default="0,0,0")
10
+ argparser.add_argument("--dpi", default=300, type=int, help="Resolution of the coord image")
11
+ argparser.add_argument("coordinate_file", help="Name of the coordinate file to be processed")
12
+ argparser.add_argument("savefile", help="Name of the file into which to save the rendered coordinates")
13
+
14
+ args = argparser.parse_args()
15
+ dataset = readFile(args.coordinate_file, args.format)
16
+ # TODO : Variable figure size?
17
+ plt.gcf().set_size_inches(4,4)
18
+ # TODO : Axes limits
19
+ plot([dataset], "coord", axes=plt.gca(), figure=plt.gcf(), plotArgString=["--view", args.view], xlabel=False, ylabel=False, xlim=False, ylim=False, xticks=False, yticks=False)
20
+ # TODO : Variable DPI
21
+ # TODO : Redo by default config?
22
+ plt.savefig(args.savefile, bbox_inches="tight", dpi=args.dpi)
@@ -1,7 +1,7 @@
1
1
  import matplotlib.pyplot as plt
2
2
  from .. import __user_conf_dir
3
3
  from ..parser import parseDatasetConfig
4
- from ..parser import save
4
+ from ..parser import save, writeFile
5
5
  import configparser
6
6
  from ..parser.combine import runGroupData
7
7
  from .fitter import plotFit
@@ -71,16 +71,16 @@ def plot(datasets, plotType="scatter", axes=False, figure=False, **plotOptions):
71
71
  if not axes:
72
72
  axes = figure.gca()
73
73
  if plotType in plotTypes:
74
- plotTypes[plotType](datasets, axes, figure=figure, **plotOptions)
74
+ axes = plotTypes[plotType](datasets, axes, figure=figure, **plotOptions)
75
75
  elif plotType in plotModules:
76
76
  # Module is present but probably not loaded
77
77
  plotModules[plotType]["spec"].loader.exec_module(plotModules[plotType]["module"])
78
78
  plotModules[plotType]["loaded"] = True
79
79
  plotTypes[plotType] = plotModules[plotType]["module"].plot
80
- plotTypes[plotType](datasets, axes, figure=figure, **plotOptions)
80
+ axes = plotTypes[plotType](datasets, axes, figure=figure, **plotOptions)
81
81
  else:
82
82
  # Defaults to scatter
83
- plotTypes["scatter"](datasets, axes, **plotOptions)
83
+ axes = plotTypes["scatter"](datasets, axes, **plotOptions)
84
84
  axes.set_xlabel(plotOptions["xlabel"])
85
85
  axes.set_ylabel(plotOptions["ylabel"])
86
86
  if plotOptions["xlim"]:
@@ -92,6 +92,15 @@ def plot(datasets, plotType="scatter", axes=False, figure=False, **plotOptions):
92
92
  #axes.set_xticks(plotOptions["xticks"][0], labels=plotOptions["xticks"][1])
93
93
  axes.set_xticks(plotOptions["xticks"][0])
94
94
  axes.set_xticklabels(plotOptions["xticks"][1])
95
+ if plotOptions["xticks-rotate"]:
96
+ axes.tick_params(axis="x", labelrotation=90)
97
+ # If requested, move ticks to top
98
+ axes.tick_params(axis="x",
99
+ top=plotOptions["xticks-swap"],
100
+ labeltop=plotOptions["xticks-swap"],
101
+ bottom=not plotOptions["xticks-swap"],
102
+ labelbottom=not plotOptions["xticks-swap"]
103
+ )
95
104
  if plotOptions["yticks"]:
96
105
  axes.set_yticks(plotOptions["yticks"][0])
97
106
  axes.set_yticklabels(plotOptions["yticks"][1])
@@ -164,7 +173,7 @@ def fromConfig(configFileName, axes=False, figure=False, datasets={}):
164
173
  float(cfg["plot"].get("fig-width-inches", 6.4)),
165
174
  float(cfg["plot"].get("fig-height-inches", 4.8))
166
175
  )
167
- plotOptions["colorCycle"] = cfg["plot"].get("colorCycle", "b")
176
+ plotOptions["colorCycle"] = cfg["plot"].get("colorCycle", "r g b c m y k")
168
177
  plotOptions["colorCycle"] = ColorIterator(plotOptions["colorCycle"])
169
178
  plotOptions["linestyleCycle"] = cfg["plot"].get("linestyleCycle", "solid")
170
179
  plotOptions["linestyleCycle"] = LinestyleIterator(plotOptions["linestyleCycle"])
@@ -189,6 +198,9 @@ def fromConfig(configFileName, axes=False, figure=False, datasets={}):
189
198
  plotOptions[ticksName] = datasets[plotOptions[ticksName]]
190
199
  elif cfg["plot"].get("hide-"+ticksName, False):
191
200
  plotOptions[ticksName] = [[],[]]
201
+ plotOptions[ticksName+"-rotate"] = cfg["plot"].get(ticksName+"-rotate", False)
202
+ # xticks on top if requested
203
+ plotOptions["xticks-swap"] = cfg["plot"].get("xticks-swap", False)
192
204
  axes = plot(chosenDatasets, graphType, axes=axes, figure=figure, **plotOptions)
193
205
  # If the axes are hidden, hide them
194
206
  if cfg["plot"].get("hide-axes", False):
@@ -208,11 +220,29 @@ def fromConfig(configFileName, axes=False, figure=False, datasets={}):
208
220
  if len(fitLabels) < numFits:
209
221
  fitLabels += [False] * (numFits - len(fitLabels))
210
222
  prevFitParams = []
223
+ prevFitErrors = []
224
+ fitParamLengths = []
225
+ currFitParams = []
226
+ currFitErrors = []
211
227
  fitColorIterator = ColorIterator(cfg["plot"].get("fit-colorCycle", "tab:blue tab:orange tab:green tab:cyan"))
228
+ fitLinestyleIterator = LinestyleIterator(cfg["plot"].get("fit-linestyleCycle", ":"))
229
+ # Ready the ranges for fits - each fit requires a separate range
230
+ fitXMins = [False]*numFits
231
+ fitXMaxs = [False]*numFits
232
+ providedXMins = cfg["plot"].get("fit-xmin", False)
233
+ providedXMaxs = cfg["plot"].get("fit-xmax", False)
234
+ if providedXMins:
235
+ providedXMins = providedXMins.split("\n")
236
+ for i in range(len(providedXMins)):
237
+ fitXMins[i] = float(providedXMins[i])
238
+ if providedXMaxs:
239
+ providedXMaxs = providedXMaxs.split("\n")
240
+ for i in range(len(providedXMaxs)):
241
+ fitXMaxs[i] = float(providedXMaxs[i])
212
242
  for allFitArgs in cfg["plot"].get("fit").split("\n"):
213
243
  fitArgs = allFitArgs.split()
214
244
  # TODO : Fit args?
215
- prevFitParams += list(plotFit(
245
+ currFitParams, currFitErrors = plotFit(
216
246
  chosenDatasets[int(fitArgs[1])],
217
247
  fitArgs[0],
218
248
  axes,
@@ -221,13 +251,45 @@ def fromConfig(configFileName, axes=False, figure=False, datasets={}):
221
251
  showParams=cfg["plot"].getboolean("fit-show-params", True),
222
252
  showError=cfg["plot"].getboolean("fit-show-error", True),
223
253
  fitColorCycle=fitColorIterator,
254
+ fitLinestyleCycle=fitLinestyleIterator,
224
255
  paramsPlacement=cfg["plot"].get("params-placement", False),
225
256
  paramsOffset=len(prevFitParams),
226
- xMin=float(cfg["plot"].get("fit-xmin", False)),
227
- xMax=float(cfg["plot"].get("fit-xmax", False)),
228
- dirtyRun=cfg["plot"].getboolean("fit-dirty-run", False)
229
- ))
257
+ xMin=fitXMins[fitIndex],
258
+ xMax=fitXMaxs[fitIndex],
259
+ dirtyRun=cfg["plot"].getboolean("fit-dirty-run", False),
260
+ fitIndex=fitIndex
261
+ )
230
262
  fitIndex += 1
263
+ prevFitParams += list(currFitParams)
264
+ prevFitErrors += list(currFitErrors)
265
+ fitParamLengths.append(len(currFitParams))
266
+ # Save fit params, if required
267
+ fitSaveName = cfg["plot"].get("fit-savepoint", False)
268
+ if fitSaveName:
269
+ fitSaveArgs = fitSaveName.split()
270
+ # No context name nor dataset name, only format and target filename (optional)
271
+ fitFormatName = fitSaveArgs[0]
272
+ fitFileName = "fit.dat"
273
+ fitParserArgs = False
274
+ if len(fitSaveArgs) > 1:
275
+ fitFileName = fitSaveArgs[1]
276
+ if len(fitSaveArgs) > 2:
277
+ fitParserArgs = " ".join(fitSaveArgs[2:])
278
+ # Regularize to dataset - take the first fit as determination
279
+ dataset = []
280
+ for j in range(fitParamLengths[0]):
281
+ dataset.append([])
282
+ # Append for both value and error
283
+ dataset.append([])
284
+ fitNumCols = fitParamLengths[0]
285
+ paramOffset = 0
286
+ for i in range(len(fitParamLengths)):
287
+ for j in range(fitNumCols):
288
+ dataset[2*j].append(prevFitParams[paramOffset + j])
289
+ dataset[2*j+1].append(prevFitErrors[paramOffset + j])
290
+ paramOffset += fitParamLengths[i]
291
+ # Dataset regularized, output
292
+ writeFile(fitFileName, fitFormatName, dataset, fitParserArgs)
231
293
  # Handle decorations for main axes
232
294
  if cfg["plot"].get("decorate", False):
233
295
  decorationCommands = cfg["plot"].get("decorate").split("\n")
@@ -298,6 +360,9 @@ def fromConfig(configFileName, axes=False, figure=False, datasets={}):
298
360
  # Plot another dataset sharing the same x axis but different y axis
299
361
  # Always, only a single twinx makes sense - provide no arguments
300
362
  fromConfig(cfg["plot"].get("twinx"), axes=axes.twinx(), figure=figure, datasets=datasets)
363
+ if cfg["plot"].get("twiny", False):
364
+ # same as twinx, but for shared y-axis
365
+ fromConfig(cfg["plot"].get("twiny"), axes=axes.twiny(), figure=figure, datasets=datasets)
301
366
  # If axes are provided, assume figure is printed somewhere else
302
367
  # TODO : Is this a reasonable assumption?
303
368
  if axesGiven:
@@ -1 +1 @@
1
- from .parser import parseDatasetConfig, save, writeFile, readFile
1
+ from .parser import parseDatasetConfig, save, writeFile, readFile, parseRange
@@ -1,6 +1,6 @@
1
1
  import argparse
2
2
 
3
- averageAP = argparse.ArgumentParser()
3
+ averageAP = argparse.ArgumentParser(prog="average", help="Element-wise average of the columns")
4
4
  averageAP.add_argument("--stderr", action="store_true", help="If given, second column of the new dataset includes standard error given by the average. Need at least two averaging datasets.")
5
5
  averageAP.add_argument("new_name", help="Name of the dataset containing the averaged values.")
6
6
  averageAP.add_argument("datasets_to_average", nargs="+", help="Datasets that are to be averaged, elementwise in each column. Number of columns is given by the first dataset.")
@@ -10,6 +10,6 @@ def command(datasets, commandArgs):
10
10
  for i in range(ncols):
11
11
  newcols.append([])
12
12
  for datasetName in args.datasets_to_merge:
13
- newcols[i] = newcols[i] + datasets[datasetName][i]
13
+ newcols[i] = newcols[i] + list(datasets[datasetName][i])
14
14
  datasets[args.new_name] = newcols
15
15
  return datasets
@@ -1,4 +1,4 @@
1
- #!/usr/bin/python3
1
+ #!/usr/bin/env python3
2
2
  import argparse
3
3
  import sys
4
4
  from compphysutils.parser import writeFile, readFile
@@ -287,3 +287,30 @@ def parseDatasetConfig(configFilename):
287
287
  if "savepoint" in cfg[groupName]:
288
288
  save(cfg[groupName].get("savepoint"), "post-process", datasets, datasetName)
289
289
  return datasets
290
+
291
+ def parseRange(rangeString):
292
+ """
293
+ A helper routine that parses the python-like range to array of bounds.
294
+ Typical behaviour is
295
+
296
+ ':' -> [0,-1]
297
+ '10:' -> [10,-1]
298
+ ':20' -> [0,19]
299
+ '1:5' -> [1,4]
300
+
301
+ As a special case, also handles single element access
302
+
303
+ '5' -> [5]
304
+ """
305
+ splitRange = rangeString.split(":")
306
+ if len(splitRange) == 1:
307
+ return [int(splitRange[0])]
308
+ elif len(splitRange) == 2:
309
+ toReturn = [0,-1]
310
+ if splitRange[0] != "":
311
+ toReturn[0] = int(splitRange[0])
312
+ if splitRange[1] != "":
313
+ toReturn[1] = int(splitRange[1])
314
+ return toReturn
315
+ else:
316
+ raise ValueError("Cannot parse "+rangeString+" as python-like range.")
@@ -6,15 +6,24 @@ class ColsReference:
6
6
  def __init__(self, parserArgs=["0"]):
7
7
  self.argsReader = argparse.ArgumentParser(description="Parses the arguments for the parser itself.")
8
8
  self.argsReader.add_argument("--comment", help="Character to be used as indicator of comment. [default : #]", default="#")
9
+ self.argsReader.add_argument("--skip", type=int, default=0, help="Skip a given number of lines before starting the read.")
9
10
  self.argsReader.add_argument("cols", nargs="+", type=int, help="Indices of columns to read.")
10
11
  self.args = self.argsReader.parse_args(parserArgs)
12
+ self.skips_remaining = self.args.skip
11
13
 
12
14
  def continueReading(self, line):
13
- if line[0] == self.args.comment:
15
+ stripLine = line.strip()
16
+ if self.skips_remaining > 0:
17
+ self.skips_remaining -= 1
18
+ return False
19
+ if len(stripLine) == 0:
20
+ # Do not attempt to read empty lines
21
+ return False
22
+ if stripLine[0] == self.args.comment:
14
23
  return False
15
24
  # Not commented, read
16
25
  # TODO : Different var types
17
- splitLine = line.split()
26
+ splitLine = stripLine.split()
18
27
  retVal = []
19
28
  for i in self.args.cols:
20
29
  retVal.append(float(splitLine[i]))
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from .. import __user_conf_dir
3
- import importlib
3
+ import importlib.util
4
4
 
5
5
  ## Search for default post-processing commands
6
6
  roots = []
@@ -1,4 +1,4 @@
1
- #!/usr/bin/python3
1
+ #!/usr/bin/env python3
2
2
  import argparse
3
3
  import sys
4
4
  import configparser
@@ -1,4 +1,4 @@
1
- #!/usr/bin/python3
1
+ #!/usr/bin/env python3
2
2
  import argparse
3
3
  import sys
4
4
  from compphysutils.parser import parseDatasetConfig
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: compphysutils
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Set of utilities for computational condensed matter physics
5
5
  Home-page: https://github.com/StepanMarek/CompPhysUtils
6
6
  Author: Stepan Marek
@@ -11,6 +11,11 @@ Requires-Python: >=3.6
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
  License-File: COPYING.reference
14
+ Requires-Dist: matplotlib>=3.10.1
15
+ Requires-Dist: numpy
16
+ Requires-Dist: scipy
17
+ Requires-Dist: raylib>=5.5.0.0
18
+ Dynamic: license-file
14
19
 
15
20
  # CompPhysUtils
16
21
  ## Collection of Python utilities for Computational Condensed Matter Physicists
@@ -10,6 +10,7 @@ src/compphysutils/__init__.py
10
10
  src/compphysutils.egg-info/PKG-INFO
11
11
  src/compphysutils.egg-info/SOURCES.txt
12
12
  src/compphysutils.egg-info/dependency_links.txt
13
+ src/compphysutils.egg-info/requires.txt
13
14
  src/compphysutils.egg-info/top_level.txt
14
15
  src/compphysutils/crystalgen/Vector.py
15
16
  src/compphysutils/crystalgen/VectorReal.py
@@ -19,9 +20,12 @@ src/compphysutils/crystalgen/gencluster
19
20
  src/compphysutils/crystalgen/generator.py
20
21
  src/compphysutils/crystalgen/readCrystalChar.py
21
22
  src/compphysutils/graphics/__init__.py
23
+ src/compphysutils/graphics/atom_plot.py
22
24
  src/compphysutils/graphics/decorator.py
23
25
  src/compphysutils/graphics/fitter.py
26
+ src/compphysutils/graphics/plot3dcoords
24
27
  src/compphysutils/graphics/plotconfig
28
+ src/compphysutils/graphics/plotcoords
25
29
  src/compphysutils/graphics/plotter.py
26
30
  src/compphysutils/graphics/transformer.py
27
31
  src/compphysutils/graphics/decorate/__init__.py
@@ -37,6 +41,7 @@ src/compphysutils/graphics/fit_types/lorentz_peak.py
37
41
  src/compphysutils/graphics/fit_types/quadratic.py
38
42
  src/compphysutils/graphics/plot_types/__init__.py
39
43
  src/compphysutils/graphics/plot_types/colormap.py
44
+ src/compphysutils/graphics/plot_types/coord.py
40
45
  src/compphysutils/graphics/plot_types/errorbar.py
41
46
  src/compphysutils/graphics/plot_types/fill_between.py
42
47
  src/compphysutils/graphics/plot_types/level.py
@@ -0,0 +1,4 @@
1
+ matplotlib>=3.10.1
2
+ numpy
3
+ scipy
4
+ raylib>=5.5.0.0
@@ -1 +0,0 @@
1
- __all__ = ["parser"]
@@ -1,11 +0,0 @@
1
- def plot(datasets, axisObj, datasetLabels=False, **plotOptions):
2
- if not datasetLabels:
3
- datasetLabels = [None] * len(datasets)
4
- for dataIndex in range(len(datasets)):
5
- if len(datasets[dataIndex]) >= 4:
6
- # If at least four columns provided, plot errors on both axes
7
- axisObj.errorbar(datasets[dataIndex][0], datasets[dataIndex][2], xerr=datasets[dataIndex][1], yerr=datasets[dataIndex][3], capsize=4, lw=0, elinewidth=2, marker="p", ms=1, label=datasetLabels[dataIndex], color=next(plotOptions["colorCycle"]))
8
- else:
9
- # Otherwise, just plot yerr
10
- axisObj.errorbar(datasets[dataIndex][0], datasets[dataIndex][1], yerr=datasets[dataIndex][2], capsize=4, lw=0, elinewidth=2, marker="p", ms=2, label=datasetLabels[dataIndex], color=next(plotOptions["colorCycle"]))
11
- return axisObj
File without changes
File without changes