ChessAnalysisPipeline 0.0.17.dev6__tar.gz → 0.0.17.dev8__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 (76) hide show
  1. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/__init__.py +1 -2
  2. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/utils.py +7 -5
  3. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/models.py +2 -1
  4. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/select_material_params_gui.py +2 -1
  5. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/foxden/models.py +9 -11
  6. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/giwaxs/processor.py +74 -67
  7. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/server.py +36 -31
  8. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/tomo/models.py +4 -1
  9. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/models.py +47 -13
  10. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/ChessAnalysisPipeline.egg-info/PKG-INFO +4 -4
  11. chessanalysispipeline-0.0.17.dev8/ChessAnalysisPipeline.egg-info/requires.txt +3 -0
  12. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/PKG-INFO +4 -4
  13. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/setup.py +4 -5
  14. chessanalysispipeline-0.0.17.dev6/ChessAnalysisPipeline.egg-info/requires.txt +0 -3
  15. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/TaskManager.py +0 -0
  16. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/__init__.py +0 -0
  17. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/models/__init__.py +0 -0
  18. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/models/common.py +0 -0
  19. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/models/integration.py +0 -0
  20. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/models/map.py +0 -0
  21. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/processor.py +0 -0
  22. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/reader.py +0 -0
  23. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/common/writer.py +0 -0
  24. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/__init__.py +0 -0
  25. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/processor.py +0 -0
  26. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/reader.py +0 -0
  27. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/utils.py +0 -0
  28. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/edd/writer.py +0 -0
  29. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/foxden/__init__.py +0 -0
  30. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/foxden/processor.py +0 -0
  31. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/foxden/reader.py +0 -0
  32. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/foxden/utils.py +0 -0
  33. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/foxden/writer.py +0 -0
  34. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/giwaxs/__init__.py +0 -0
  35. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/giwaxs/models.py +0 -0
  36. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/giwaxs/reader.py +0 -0
  37. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/giwaxs/writer.py +0 -0
  38. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/inference/__init__.py +0 -0
  39. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/inference/processor.py +0 -0
  40. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/inference/reader.py +0 -0
  41. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/inference/writer.py +0 -0
  42. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/models.py +0 -0
  43. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/pipeline.py +0 -0
  44. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/processor.py +0 -0
  45. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/reader.py +0 -0
  46. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/runner.py +0 -0
  47. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/saxswaxs/__init__.py +0 -0
  48. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/saxswaxs/processor.py +0 -0
  49. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/saxswaxs/reader.py +0 -0
  50. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/saxswaxs/writer.py +0 -0
  51. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/sin2psi/__init__.py +0 -0
  52. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/sin2psi/processor.py +0 -0
  53. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/sin2psi/reader.py +0 -0
  54. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/sin2psi/writer.py +0 -0
  55. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/tomo/__init__.py +0 -0
  56. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/tomo/processor.py +0 -0
  57. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/tomo/reader.py +0 -0
  58. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/tomo/writer.py +0 -0
  59. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/__init__.py +0 -0
  60. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/converters.py +0 -0
  61. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/fit.py +0 -0
  62. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/general.py +0 -0
  63. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/material.py +0 -0
  64. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/utils/parfile.py +0 -0
  65. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/CHAP/writer.py +0 -0
  66. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/ChessAnalysisPipeline.egg-info/SOURCES.txt +0 -0
  67. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/ChessAnalysisPipeline.egg-info/dependency_links.txt +0 -0
  68. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/ChessAnalysisPipeline.egg-info/entry_points.txt +0 -0
  69. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/ChessAnalysisPipeline.egg-info/top_level.txt +0 -0
  70. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/LICENSE +0 -0
  71. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/MLaaS/__init__.py +0 -0
  72. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/MLaaS/ktrain.py +0 -0
  73. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/MLaaS/mnist_img.py +0 -0
  74. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/MLaaS/tfaas_client.py +0 -0
  75. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/README.md +0 -0
  76. {chessanalysispipeline-0.0.17.dev6 → chessanalysispipeline-0.0.17.dev8}/setup.cfg +0 -0
@@ -23,5 +23,4 @@ from CHAP.reader import Reader
23
23
  from CHAP.processor import Processor
24
24
  from CHAP.writer import Writer
25
25
 
26
- version = 'v0.0.17.dev6'
27
- #version = 'v0.0.17'
26
+ version = 'v0.0.17.dev8'
@@ -14,7 +14,7 @@ import subprocess
14
14
  import json
15
15
 
16
16
  # Third party modules
17
- import pkg_resources
17
+ from importlib.metadata import distributions
18
18
 
19
19
  def osinfo():
20
20
  """Helper function to provide osinfo."""
@@ -58,8 +58,9 @@ def environments():
58
58
  # Check for Virtualenv (excluding Conda)
59
59
  elif hasattr(sys, 'real_prefix') or os.getenv('VIRTUAL_ENV'):
60
60
  venv_name = os.path.basename(os.getenv('VIRTUAL_ENV', 'unknown-venv'))
61
- packages = [{'name': pkg.key, 'version': pkg.version}
62
- for pkg in pkg_resources.working_set]
61
+ packages = [{'name': pkg.metadata['Name'],
62
+ 'version': pkg.version}
63
+ for pkg in distributions()]
63
64
  environments_.append({
64
65
  'name': venv_name,
65
66
  'version': sys.version.split()[0],
@@ -71,8 +72,9 @@ def environments():
71
72
 
72
73
  # System Python (not inside Conda or Virtualenv)
73
74
  else:
74
- packages = [{'name': pkg.key, 'version': pkg.version}
75
- for pkg in pkg_resources.working_set]
75
+ packages = [{'name': pkg.metadata['Name'],
76
+ 'version': pkg.version}
77
+ for pkg in distributions()]
76
78
  environments_.append({
77
79
  'name': 'system-python',
78
80
  'version': sys.version.split()[0],
@@ -718,7 +718,8 @@ class MCAEnergyCalibrationConfig(MCACalibrationConfig):
718
718
  """
719
719
  if self.peak_energies is None:
720
720
  raise ValueError('peak_energies is required')
721
- if not 0 <= self.max_peak_index < len(self.peak_energies):
721
+ if (self.max_peak_index is not None
722
+ and not 0 <= self.max_peak_index < len(self.peak_energies)):
722
723
  raise ValueError('max_peak_index out of bounds')
723
724
  return self
724
725
 
@@ -145,7 +145,8 @@ class MaterialParamSelector:
145
145
  # pos=['4a', '8c'])
146
146
  # #pos=[(0,0,0), (1/4, 1/4, 1/4), (3/4, 3/4, 3/4)])
147
147
  self.material_name, sgnum=self.sgnum,
148
- lattice_parameters_angstroms=self.lattice_parameters)
148
+ # lattice_parameters_angstroms = lattice_parameters FIX?
149
+ lattice_parameters_angstroms = self.lattice_parameters
149
150
  material.material_name = name
150
151
  material.sgnum = _material.sgnum
151
152
  material.lattice_parameters = [
@@ -20,25 +20,23 @@ from CHAP import CHAPBaseModel
20
20
  class FoxdenRequestConfig(CHAPBaseModel):
21
21
  """FOXDEN HTTP request base configuration class.
22
22
 
23
- :param url: URL of service.
24
- :type url: str
25
23
  :param did: FOXDEN dataset identifier (did).
26
24
  :type did: string, optional
27
- :param query: FOXDEN query.
28
- :type query: string, optional
29
- :param method: HTTP request method (not case sensitive),
30
- defaults to `'POST'`.
31
- :type method: Literal['DELETE', 'GET', 'POST', 'PUT'], optional
32
- # :param scope: FOXDEN scope (not case sensitive).
33
- # :type scope: Literal['read', 'write'], optional
34
- # :param idx: Ask Valentin, currently it's ignored
35
- # :type idx: int, optional
36
25
  :param limit: Maximum number of returned records,
37
26
  defaults to `10`.
38
27
  :type limit: int, optional
28
+ :param query: FOXDEN query.
29
+ :type query: string, optional
39
30
  :param verbose: Verbose output flag, defaults to `False`.
40
31
  :type verbose: bool, optional
41
32
  """
33
+ # :param method: HTTP request method (not case sensitive),
34
+ # defaults to `'POST'`.
35
+ # :type method: Literal['DELETE', 'GET', 'POST', 'PUT'], optional
36
+ # :param scope: FOXDEN scope (not case sensitive).
37
+ # :type scope: Literal['read', 'write'], optional
38
+ # :param idx: Ask Valentin, currently it's ignored
39
+ # :type idx: int, optional
42
40
  # Mimics golib.services.data.ServiceQuery
43
41
  did: Optional[constr(
44
42
  strict=True, strip_whitespace=True, to_lower=True)] = None
@@ -254,76 +254,83 @@ class GiwaxsConversionProcessor(Processor):
254
254
  data_curved, q_par, q_perp, q_par_rect, q_perp_rect,
255
255
  return_maps=False, normalize=True):
256
256
  """
257
- data_rect = curved_to_rect(...):
258
- distributes counts from a curvilinear grid (data_curved),
259
- e.g. x-ray data collected in angular space, into a
260
- rectilinear grid (reciprocal space).
257
+ ::
258
+
259
+ data_rect = curved_to_rect(...):
260
+ distributes counts from a curvilinear grid
261
+ (data_curved), e.g. x-ray data collected in angular
262
+ space, into a rectilinear grid (reciprocal space).
261
263
 
262
- data_rect, norm, xmap, ymap, xwid, ywid =
263
- curved_to_rect(..., return_maps=True):
264
- distributes counts from a curvilinear grid (data_curved),
265
- e.g. x-ray data collected in angular space, into a
266
- rectilinear grid (reciprocal space).
264
+ data_rect, norm, xmap, ymap, xwid, ywid =
265
+ curved_to_rect(..., return_maps=True):
266
+ distributes counts from a curvilinear grid
267
+ (data_curved), e.g. x-ray data collected in angular
268
+ space, into a rectilinear grid (reciprocal space).
267
269
 
268
- q_par, q_perp, and data_curved are M x N following the normal
269
- convention where the the first & second index corrspond to
270
- the vertical (y) and horizontal (x) locations of the
271
- scattering pattern.
272
- q_par, q_perp represent the q coordinates of the center of
273
- pixels whose intensities are stored in data_curved.
274
- Reiterating the convention above, q_par and q_perp vary
275
- primarilly along the 2nd and 1st index, respectively.
276
- q_par_rect and q_perp_rect are evenly-spaced, monotonically
277
- increasing, arrays determining the new grid.
270
+ q_par, q_perp, and data_curved are M x N following the
271
+ normal convention where the the first & second index
272
+ corrspond to the vertical (y) and horizontal (x)
273
+ locations of the scattering pattern.
274
+ q_par, q_perp represent the q coordinates of the center of
275
+ pixels whose intensities are stored in data_curved.
276
+ Reiterating the convention above, q_par and q_perp vary
277
+ primarilly along the 2nd and 1st index, respectively.
278
+ q_par_rect and q_perp_rect are evenly-spaced, monotonically
279
+ increasing, arrays determining the new grid.
278
280
 
279
- data_rect : the new matrix with intensity from data_curved
280
- disctributed into a regular grid defined by
281
- q_par_rect, q_perp_rect.
282
- norm : a matrix with the same shape of data_rect representing
283
- the area of the pixel in the original angular units.
284
- It should be used to normalize the resulting array as
285
- norm_z = data_rect / norm.
286
-
287
- Algorithm:
288
- Step 1 : Compute xmap, ymap, which containt the values of
289
- q_par and q_perp, but represented in pixel units of
290
- the target coordinates q_par_rect, q_perp_rect.
291
- In other words, xmap(i,j) = 3.4 means that
292
- q_par(i,j) lands 2/5 of the q_distance between
293
- q_par_rect(3) and q_par_rect(4). Intensity in
294
- qpar(i,j) should thus be distributed in a 2:3 ratio
295
- among neighboring mini-columns of pixels 3 and 4.
296
- Step 2 : Use the procedure described by Barna et al
297
- (RSI v.70, p. 2927, 1999) to distribute intensity
298
- from each source pixel i,j into each of 9
299
- destination pixels around the xmap(i,j) and
300
- ymap(i,j). Keep track of how many source "pixels"
301
- are placed into each bin in the variable, "norm".
302
- Note also that if xmap(i,j)-floor(xmap(i,j)) > 0.5,
303
- the "center" pixel of the 9 destination pixels is
304
- floor(xmap+0.5).
305
- (Outside this function): The normalized intensity in each
306
- new pixel can be obtained asI = data_rect./norm, but
307
- with the caveat that zero values of "norm" should be
308
- changed to ones first, norm(data_rect == 0) = 1.0.
309
-
310
- Example Usage:
311
- 1. Compute the values of q_par and q_perp for each pixel in
312
- the image z (according to scattering geometry).
313
- 2. Set or determing a good target grid, e.g.:
314
- min_qpar, max_qpar = q_par.mix(), q_par.max()
315
- min_qperp, max_qperp = q_perp.mix(), q_perp.max()
316
- q_par_rect, q_par_step = np.linspace(min_qpar ,
317
- max_qpar, image_dim[1], retstep=True)
318
- q_perp_rect, q_perp_step = np.linspace(min_qperp,
319
- max_qperp, image_dim[0], retstep=True)
320
- 3. data_rect = curved_to_rect(data_curved, q_par, q_perp,
321
- q_par_rect, q_perp_rect)
322
- 4. plt.imshow(data_rect, extent = [
323
- q_par_rect[0], q_par_rect[-1],
324
- q_perp_rect[-1], q_perp_rect[0]])
325
- xlabel(r'q$_\parallel$'' [\u212b$^{-1}$]')
326
- ylabel(r'q$_\perp$'' [\u212b$^{-1}$]')
281
+ data_rect : the new matrix with intensity from data_curved
282
+ disctributed into a regular grid defined by
283
+ q_par_rect, q_perp_rect.
284
+ norm : a matrix with the same shape of data_rect
285
+ representing the area of the pixel in the original
286
+ angular units. It should be used to normalize the
287
+ resulting array as norm_z = data_rect / norm.
288
+
289
+ Algorithm:
290
+ Step 1 : Compute xmap, ymap, which containt the values
291
+ of q_par and q_perp, but represented in pixel
292
+ units of the target coordinates q_par_rect,
293
+ q_perp_rect.
294
+ In other words, xmap(i,j) = 3.4 means that
295
+ q_par(i,j) lands 2/5 of the q_distance between
296
+ q_par_rect(3) and q_par_rect(4). Intensity in
297
+ qpar(i,j) should thus be distributed in a 2:3
298
+ ratio among neighboring mini-columns of pixels
299
+ 3 and 4.
300
+ Step 2 : Use the procedure described by Barna et al
301
+ (RSI v.70, p. 2927, 1999) to distribute
302
+ intensity from each source pixel i,j into each
303
+ of 9 destination pixels around the xmap(i,j)
304
+ and ymap(i,j). Keep track of how many source
305
+ "pixels" are placed into each bin in the
306
+ variable, "norm". Note also that if
307
+ xmap(i,j)-floor(xmap(i,j)) > 0.5,
308
+ the "center" pixel of the 9 destination pixels
309
+ is floor(xmap+0.5).
310
+ (Outside this function): The normalized intensity in
311
+ each new pixel can be obtained as
312
+ I = data_rect./norm, but with the caveat that zero
313
+ values of "norm" should be changed to ones first,
314
+ norm(data_rect == 0) = 1.0.
315
+
316
+ Example Usage:
317
+ 1. Compute the values of q_par and q_perp for each
318
+ pixel in the image z (according to scattering
319
+ geometry).
320
+ 2. Set or determing a good target grid, e.g.:
321
+ min_qpar, max_qpar = q_par.mix(), q_par.max()
322
+ min_qperp, max_qperp = q_perp.mix(), q_perp.max()
323
+ q_par_rect, q_par_step = np.linspace(min_qpar ,
324
+ max_qpar, image_dim[1], retstep=True)
325
+ q_perp_rect, q_perp_step = np.linspace(min_qperp,
326
+ max_qperp, image_dim[0], retstep=True)
327
+ 3. data_rect = curved_to_rect(data_curved, q_par,
328
+ q_perp, q_par_rect, q_perp_rect)
329
+ 4. plt.imshow(data_rect, extent = [
330
+ q_par_rect[0], q_par_rect[-1],
331
+ q_perp_rect[-1], q_perp_rect[0]])
332
+ xlabel(r'q$_\parallel$'' [\u212b$^{-1}$]')
333
+ ylabel(r'q$_\perp$'' [\u212b$^{-1}$]')
327
334
  """
328
335
  out_width, out_height = q_par_rect.size, q_perp_rect.size
329
336
 
@@ -5,48 +5,53 @@ File : server.py
5
5
  Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
6
6
  Description: Python server with thread pool and CHAP pipeline
7
7
 
8
- ### Client side:
8
+ ===========
9
+ Client side
10
+ ===========
9
11
  cat /tmp/chap.json
10
12
  {"pipeline": [{"common.PrintProcessor": {}}], "input": 1}
11
13
 
12
- ### curl call to the server with our CHAP pipeline
14
+ ==========================================
15
+ Curl call to the server with CHAP pipeline
16
+ ==========================================
13
17
  curl -X POST -H "Content-type: application/json" -d@/tmp/chap.json http://localhost:5000/pipeline
14
18
  {"pipeline": [{"common.PrintProcessor":{}}], "status":"ok"}
15
19
 
16
- ### Server side:
20
+ ===========
21
+ Server side
22
+ ===========
17
23
  flask --app server run
18
- * Serving Flask app 'server'
19
- * Debug mode: off
24
+
25
+ * Serving Flask app 'server'
26
+ * Debug mode: off
27
+
20
28
  WARNING: This is a development server. Do not use it in a production
21
29
  deployment. Use a production WSGI server instead.
22
- * Running on http://127.0.0.1:5000
30
+
31
+ * Running on http://127.0.0.1:5000
32
+
23
33
  Press CTRL+C to quit
24
- ...
25
-
26
- CHAP.server : Call pipeline args=()
27
- kwds={'pipeline': [{'common.PrintProcessor': {}}]}
28
- CHAP.server : pipeline [{'common.PrintProcessor': {}}]
29
- CHAP.server : Loaded
30
- <CHAP.common.processor.PrintProcessor object at 0x10e0f1ed0>
31
- CHAP.server : Loaded
32
- <CHAP.pipeline.Pipeline object at 0x10e0f1f10> with 1 items
33
-
34
- CHAP.server : Calling "execute" on <CHAP.pipeline.Pipeline
35
- object at 0x10e0f1f10>
36
- Pipeline : Executing "execute"
37
-
38
- Pipeline : Calling "process" on
39
- <CHAP.common.processor.PrintProcessor object at 0x10e0f1ed0>
40
- PrintProcessor : Executing "process" with
41
- type(data)=<class 'NoneType'>
42
- PrintProcessor data :
43
- None
44
- PrintProcessor : Finished "process" in 0.000 seconds
45
-
46
- Pipeline : Executed "execute" in 0.000 seconds
47
- 127.0.0.1 - - [07/Apr/2023 09:11:22] "POST /pipeline HTTP/1.1" 200 -
48
- """
49
34
 
35
+ CHAP output::
36
+
37
+ CHAP.server : Call pipeline args=()
38
+ kwds={'pipeline': [{'common.PrintProcessor': {}}]}
39
+ CHAP.server : pipeline [{'common.PrintProcessor': {}}]
40
+ CHAP.server : Loaded
41
+ <CHAP.common.processor.PrintProcessor object at 0x10e0f1ed0>
42
+ CHAP.server : Loaded
43
+ <CHAP.pipeline.Pipeline object at 0x10e0f1f10> with 1 items
44
+ CHAP.server : Calling "execute" on <CHAP.pipeline.Pipeline
45
+ object at 0x10e0f1f10>
46
+ Pipeline : Executing "execute"
47
+ Pipeline : Calling "process" on
48
+ <CHAP.common.processor.PrintProcessor object at 0x10e0f1ed0>
49
+ PrintProcessor : Executing "process" with
50
+ type(data)=<class 'NoneType'>
51
+ PrintProcessor data : None
52
+ PrintProcessor : Finished "process" in 0.000 seconds
53
+ Pipeline : Executed "execute" in 0.000 seconds
54
+ """
50
55
  # System modules
51
56
  import time
52
57
  from queue import Queue
@@ -6,6 +6,7 @@ from typing import (
6
6
  Optional,
7
7
  )
8
8
  from pydantic import (
9
+ ConfigDict,
9
10
  conint,
10
11
  conlist,
11
12
  confloat,
@@ -40,7 +41,7 @@ class Detector(CHAPBaseModel):
40
41
  pixel_size: conlist(
41
42
  item_type=confloat(gt=0, allow_inf_nan=False),
42
43
  min_length=1, max_length=2)
43
- lens_magnification: confloat(gt=0, allow_inf_nan=False) = 1.0
44
+ lens_magnification: Optional[confloat(gt=0, allow_inf_nan=False)] = 1.0
44
45
 
45
46
 
46
47
  class TomoReduceConfig(CHAPBaseModel):
@@ -208,3 +209,5 @@ class TomoSimConfig(CHAPBaseModel):
208
209
  beam_intensity: Optional[confloat(gt=0, allow_inf_nan=False)] = 1.e9
209
210
  background_intensity: Optional[confloat(gt=0, allow_inf_nan=False)] = 20
210
211
  slit_size: Optional[confloat(gt=0, allow_inf_nan=False)] = 1.0
212
+
213
+ model_config = ConfigDict(arbitrary_types_allowed=True)
@@ -91,19 +91,53 @@ def lorentzian(x, amplitude=1.0, center=0.0, sigma=1.0):
91
91
  def rectangle(
92
92
  x, amplitude=1.0, center1=0.0, sigma1=1.0, center2=1.0,
93
93
  sigma2=1.0, form='linear'):
94
- """Return a rectangle function.
95
-
96
- Starts at 0.0, rises to `amplitude` (at `center1` with width
97
- `sigma1`), then drops to 0.0 (at `center2` with width `sigma2`)
98
- with `form`:
99
- - `'linear'` (default) = ramp_up + ramp_down
100
- - `'atan'`, `'arctan`' = amplitude*(atan(arg1) + atan(arg2))/pi
101
- - `'erf'` = amplitude*(erf(arg1) + erf(arg2))/2.
102
- - `'logisitic'` = amplitude*[1 - 1/(1 + exp(arg1)) -
103
- 1/(1+exp(arg2))]
104
-
105
- where ``arg1 = (x - center1)/sigma1`` and
106
- ``arg2 = -(x - center2)/sigma2``.
94
+ r"""
95
+ Return a rectangle function.
96
+
97
+ Starts at 0.0, rises to ``amplitude`` (at ``center1`` with width
98
+ ``sigma1``), then drops to 0.0 (at ``center2`` with width
99
+ ``sigma2``)
100
+
101
+ :param x: Input values where the function is evaluated.
102
+ :type x: float or numpy.ndarray
103
+ :param amplitude: Maximum height of the rectangle, defaults to 1.0.
104
+ :type amplitude: float, optional
105
+ :param center1: Location of the rising edge, defaults to 0.0.
106
+ :type center1: float, optional
107
+ :param sigma1: Width or smoothness of the rising edge,
108
+ defaults to 1.0.
109
+ :type sigma1: float, optional
110
+ :param center2: Location of the falling edge, defaults to 1.0.
111
+ :type center2: float, optional
112
+ :param sigma2: Width or smoothness of the falling edge,
113
+ defaults to 1.0.
114
+ :type sigma2: float, optional
115
+ :param form: Shape type of the transition edges:
116
+
117
+ - ``'linear'``: Simple ramp-up and ramp-down.
118
+ - ``'atan'`` or ``'arctan'``: Inverse tangent transitions.
119
+ - ``'erf'``: Error function (Gaussian-like) transitions.
120
+ - ``'logistic'``: Sigmoidal (logistic function) transitions.
121
+ :type form: str, optional
122
+
123
+ :returns: The evaluated rectangle function values.
124
+ :rtype: float or numpy.ndarray
125
+
126
+ .. note::
127
+ The output is calculated based on the selected ``form``:
128
+
129
+ - **atan**: $\frac{A}{\pi} [ \arctan(arg_1) + \arctan(arg_2) ]$
130
+ - **erf**:
131
+ $\frac{1}{2} A [ \text{erf}(arg_1) + \text{erf}(arg_2) ]$
132
+ - **logistic**:
133
+ $A [ \frac{1}{1 + \exp(-arg_1)} +
134
+ \frac{1}{1 + \exp(-arg_2)} - 1 ]$
135
+
136
+ The function is constructed using normalized arguments for the
137
+ rising and falling edges:
138
+ $arg_1 = \frac{x - center_1}{\sigma_1}$
139
+ and
140
+ $arg_2 = \frac{center_2 - x}{\sigma_2}$
107
141
  """
108
142
  arg1 = (x - center1)/max(tiny, sigma1)
109
143
  arg2 = (center2 - x)/max(tiny, sigma2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChessAnalysisPipeline
3
- Version: 0.0.17.dev6
3
+ Version: 0.0.17.dev8
4
4
  Summary: CHESS analysis pipeline framework
5
5
  Home-page: https://github.com/CHESSComputing/ChessAnalysisPipeline
6
6
  Author: Keara Soloway, Rolf Verberg, Valentin Kuznetsov
@@ -11,9 +11,9 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: numpy==1.26.4
15
- Requires-Dist: pydantic==2.7.3
16
- Requires-Dist: pyyaml==6.0.3
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pydantic
16
+ Requires-Dist: pyyaml
17
17
 
18
18
  [![DOI](https://zenodo.org/badge/600053436.svg)](https://zenodo.org/badge/latestdoi/600053436)
19
19
  ![pylint](https://github.com/CHESSComputing/ChessAnalysisPipeline/actions/workflows/pylint-check.yml/badge.svg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChessAnalysisPipeline
3
- Version: 0.0.17.dev6
3
+ Version: 0.0.17.dev8
4
4
  Summary: CHESS analysis pipeline framework
5
5
  Home-page: https://github.com/CHESSComputing/ChessAnalysisPipeline
6
6
  Author: Keara Soloway, Rolf Verberg, Valentin Kuznetsov
@@ -11,9 +11,9 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: numpy==1.26.4
15
- Requires-Dist: pydantic==2.7.3
16
- Requires-Dist: pyyaml==6.0.3
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pydantic
16
+ Requires-Dist: pyyaml
17
17
 
18
18
  [![DOI](https://zenodo.org/badge/600053436.svg)](https://zenodo.org/badge/latestdoi/600053436)
19
19
  ![pylint](https://github.com/CHESSComputing/ChessAnalysisPipeline/actions/workflows/pylint-check.yml/badge.svg)
@@ -12,8 +12,7 @@ import os
12
12
  import setuptools
13
13
 
14
14
  # [set version]
15
- version = 'v0.0.17.dev6'
16
- #version = 'v0.0.17'
15
+ version = 'v0.0.17.dev8'
17
16
  # [version set]
18
17
 
19
18
  def datafiles(idir, pattern=None):
@@ -86,8 +85,8 @@ setuptools.setup(
86
85
  ],
87
86
  python_requires='>=3.10',
88
87
  install_requires=[
89
- 'numpy==1.26.4',
90
- 'pydantic==2.7.3',
91
- 'pyyaml==6.0.3',
88
+ 'numpy',
89
+ 'pydantic',
90
+ 'pyyaml',
92
91
  ],
93
92
  )
@@ -1,3 +0,0 @@
1
- numpy==1.26.4
2
- pydantic==2.7.3
3
- pyyaml==6.0.3