ChessAnalysisPipeline 0.0.2__py3-none-any.whl → 0.0.4__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.

Potentially problematic release.


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

Files changed (47) hide show
  1. CHAP/__init__.py +3 -0
  2. CHAP/common/__init__.py +19 -0
  3. CHAP/common/models/__init__.py +2 -0
  4. CHAP/common/models/integration.py +515 -0
  5. CHAP/common/models/map.py +535 -0
  6. CHAP/common/processor.py +644 -0
  7. CHAP/common/reader.py +119 -0
  8. CHAP/common/utils/__init__.py +37 -0
  9. CHAP/common/utils/fit.py +2613 -0
  10. CHAP/common/utils/general.py +1225 -0
  11. CHAP/common/utils/material.py +231 -0
  12. CHAP/common/utils/scanparsers.py +785 -0
  13. CHAP/common/writer.py +96 -0
  14. CHAP/edd/__init__.py +7 -0
  15. CHAP/edd/models.py +215 -0
  16. CHAP/edd/processor.py +321 -0
  17. CHAP/edd/reader.py +5 -0
  18. CHAP/edd/writer.py +5 -0
  19. CHAP/inference/__init__.py +3 -0
  20. CHAP/inference/processor.py +68 -0
  21. CHAP/inference/reader.py +5 -0
  22. CHAP/inference/writer.py +5 -0
  23. CHAP/pipeline.py +1 -1
  24. CHAP/processor.py +11 -818
  25. CHAP/reader.py +18 -113
  26. CHAP/saxswaxs/__init__.py +6 -0
  27. CHAP/saxswaxs/processor.py +5 -0
  28. CHAP/saxswaxs/reader.py +5 -0
  29. CHAP/saxswaxs/writer.py +5 -0
  30. CHAP/sin2psi/__init__.py +7 -0
  31. CHAP/sin2psi/processor.py +5 -0
  32. CHAP/sin2psi/reader.py +5 -0
  33. CHAP/sin2psi/writer.py +5 -0
  34. CHAP/tomo/__init__.py +5 -0
  35. CHAP/tomo/models.py +125 -0
  36. CHAP/tomo/processor.py +2009 -0
  37. CHAP/tomo/reader.py +5 -0
  38. CHAP/tomo/writer.py +5 -0
  39. CHAP/writer.py +17 -167
  40. {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/METADATA +1 -1
  41. ChessAnalysisPipeline-0.0.4.dist-info/RECORD +50 -0
  42. CHAP/async.py +0 -56
  43. ChessAnalysisPipeline-0.0.2.dist-info/RECORD +0 -17
  44. {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/LICENSE +0 -0
  45. {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/WHEEL +0 -0
  46. {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/entry_points.txt +0 -0
  47. {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/top_level.txt +0 -0
CHAP/common/reader.py ADDED
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env python
2
+ '''
3
+ File : reader.py
4
+ Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
5
+ Description: Module for Writers used in multiple experiment-specific workflows.
6
+ '''
7
+
8
+ # system modules
9
+ import argparse
10
+ import json
11
+ import logging
12
+ import sys
13
+ from time import time
14
+
15
+ # local modules
16
+ from CHAP import Reader
17
+
18
+ class BinaryFileReader(Reader):
19
+ def _read(self, filename):
20
+ '''Return a content of a given file name
21
+
22
+ :param filename: name of the binart file to read from
23
+ :return: the content of `filename`
24
+ :rtype: binary
25
+ '''
26
+ with open(filename, 'rb') as file:
27
+ data = file.read()
28
+ return(data)
29
+
30
+ class MultipleReader(Reader):
31
+ def read(self, readers):
32
+ '''Return resuts from multiple `Reader`s.
33
+
34
+ :param readers: a dictionary where the keys are specific names that are
35
+ used by the next item in the `Pipeline`, and the values are `Reader`
36
+ configurations.
37
+ :type readers: list[dict]
38
+ :return: The results of calling `Reader.read(**kwargs)` for each item
39
+ configured in `readers`.
40
+ :rtype: list[dict[str,object]]
41
+ '''
42
+
43
+ t0 = time()
44
+ self.logger.info(f'Executing "read" with {len(readers)} Readers')
45
+
46
+ data = []
47
+ for reader_config in readers:
48
+ reader_name = list(reader_config.keys())[0]
49
+ reader_class = getattr(sys.modules[__name__], reader_name)
50
+ reader = reader_class()
51
+ reader_kwargs = reader_config[reader_name]
52
+
53
+ data.extend(reader.read(**reader_kwargs))
54
+
55
+ self.logger.info(f'Finished "read" in {time()-t0:.3f} seconds\n')
56
+
57
+ return(data)
58
+
59
+ class NexusReader(Reader):
60
+ def _read(self, filename, nxpath='/'):
61
+ '''Return the NeXus object stored at `nxpath` in the nexus file
62
+ `filename`.
63
+
64
+ :param filename: name of the NeXus file to read from
65
+ :type filename: str
66
+ :param nxpath: path to a specific loaction in the NeXus file to read
67
+ from, defaults to `'/'`
68
+ :type nxpath: str, optional
69
+ :raises nexusformat.nexus.NeXusError: if `filename` is not a NeXus
70
+ file or `nxpath` is not in `filename`.
71
+ :return: the NeXus structure indicated by `filename` and `nxpath`.
72
+ :rtype: nexusformat.nexus.NXobject
73
+ '''
74
+
75
+ from nexusformat.nexus import nxload
76
+
77
+ nxobject = nxload(filename)[nxpath]
78
+ return(nxobject)
79
+
80
+ class URLReader(Reader):
81
+ def _read(self, url, headers={}):
82
+ '''Make an HTTPS request to the provided URL and return the results.
83
+ Headers for the request are optional.
84
+
85
+ :param url: the URL to read
86
+ :type url: str
87
+ :param headers: headers to attach to the request, defaults to `{}`
88
+ :type headers: dict, optional
89
+ :return: the content of the response
90
+ :rtype: object
91
+ '''
92
+
93
+ import requests
94
+
95
+ resp = requests.get(url, headers=headers)
96
+ data = resp.content
97
+
98
+ self.logger.debug(f'Response content: {data}')
99
+
100
+ return(data)
101
+
102
+ class YAMLReader(Reader):
103
+ def _read(self, filename):
104
+ '''Return a dictionary from the contents of a yaml file.
105
+
106
+ :param filename: name of the YAML file to read from
107
+ :return: the contents of `filename`
108
+ :rtype: dict
109
+ '''
110
+
111
+ import yaml
112
+
113
+ with open(filename) as file:
114
+ data = yaml.safe_load(file)
115
+ return(data)
116
+
117
+ if __name__ == '__main__':
118
+ from CHAP.reader import main
119
+ main()
@@ -0,0 +1,37 @@
1
+ from CHAP.common.utils.fit import (Fit,
2
+ FitMap,
3
+ FitMultipeak)
4
+ from CHAP.common.utils.material import Material
5
+
6
+ # def create_mask(data, bounds, exclude_bounds=True, current_mask=None):
7
+ # '''Return a boolean array that masks out the values in `bounds` when applied
8
+ # to `data`.
9
+
10
+ # :param data: the array for which a mask will be constructed
11
+ # :type data: Union[list, numpy.ndarray]
12
+ # :param bounds: a range of values in `data` (min, max) that the mask will
13
+ # exclude (or include if `exclude_bounds=False`).
14
+ # :type bounds: tuple
15
+ # :param exclude_bounds: should applying the mask to `data` exclude (`True`)
16
+ # or include (`False`) the value ranges in `bounds`, defaults to `True`
17
+ # :type exclude_bounds: True, optional
18
+ # :param current_mask: an existing mask array for `data` that will be "or"-ed
19
+ # with the mask constructed from `bounds` before returning, defaults to
20
+ # None
21
+ # :type current_mask: numpy.ndarray(dtype=numpy.bool_), optional
22
+ # :return: a boolean mask array for `data`.
23
+ # :rtype: numpy.ndarray(dtype=numpy.bool_)
24
+ # '''
25
+
26
+ # import numpy as np
27
+
28
+ # min_, max_ = bounds
29
+ # if exclude_bounds:
30
+ # mask = np.logical_or(data < min_, data > max_)
31
+ # else:
32
+ # mask = np.logical_and(data > min_, data < max_)
33
+
34
+ # if current_mask is not None:
35
+ # mask = np.logical_or(mask, current_mask)
36
+
37
+ # return(mask)