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/tomo/reader.py ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env python
2
+
3
+ if __name__ == '__main__':
4
+ from CHAP.reader import main
5
+ main()
CHAP/tomo/writer.py ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env python
2
+
3
+ if __name__ == '__main__':
4
+ from CHAP.writer import main
5
+ main()
CHAP/writer.py CHANGED
@@ -52,177 +52,27 @@ class Writer():
52
52
  file.write(data)
53
53
  return(data)
54
54
 
55
- class YAMLWriter(Writer):
56
- def _write(self, data, filename, force_overwrite=False):
57
- '''If `data` is a `dict`, write it to `filename`.
58
-
59
- :param data: the dictionary to write to `filename`.
60
- :type data: dict
61
- :param filename: name of the file to write to.
62
- :type filename: str
63
- :param force_overwrite: flag to allow data in `filename` to be
64
- overwritten if it already exists.
65
- :type force_overwrite: bool
66
- :raises TypeError: if `data` is not a `dict`
67
- :raises RuntimeError: if `filename` already exists and
68
- `force_overwrite` is `False`.
69
- :return: the original input data
70
- :rtype: dict
71
- '''
72
-
73
- import yaml
74
-
75
- if not isinstance(data, (dict, list)):
76
- raise(TypeError(f'{self.__name__}.write: input data must be a dict or list.'))
77
-
78
- if not force_overwrite:
79
- if os.path.isfile(filename):
80
- raise(RuntimeError(f'{self.__name__}: {filename} already exists.'))
81
-
82
- with open(filename, 'w') as outf:
83
- yaml.dump(data, outf, sort_keys=False)
84
-
85
- return(data)
86
-
87
- class ExtractArchiveWriter(Writer):
88
- def _write(self, data, filename):
89
- '''Take a .tar archive represented as bytes in `data` and write the
90
- extracted archive to files.
91
-
92
- :param data: the archive data
93
- :type data: bytes
94
- :param filename: the name of a directory to which the archive files will
95
- be written
96
- :type filename: str
97
- :return: the original `data`
98
- :rtype: bytes
99
- '''
100
-
101
- from io import BytesIO
102
- import tarfile
103
-
104
- tar = tarfile.open(fileobj=BytesIO(data))
105
- tar.extractall(path=filename)
106
-
107
- return(data)
108
-
109
-
110
- class NexusWriter(Writer):
111
- def _write(self, data, filename, force_overwrite=False):
112
- '''Write `data` to a NeXus file
113
-
114
- :param data: the data to write to `filename`.
115
- :param filename: name of the file to write to.
116
- :param force_overwrite: flag to allow data in `filename` to be
117
- overwritten, if it already exists.
118
- :return: the original input data
119
- '''
120
-
121
- from nexusformat.nexus import NXobject
122
- import xarray as xr
123
-
124
- if isinstance(data, NXobject):
125
- nxstructure = data
126
-
127
- elif isinstance(data, xr.Dataset):
128
- nxstructure = self.get_nxdata_from_dataset(data)
129
-
130
- elif isinstance(data, xr.DataArray):
131
- nxstructure = self.get_nxdata_from_dataarray(data)
132
-
133
- else:
134
- raise(TypeError(f'{self.__name__}.write: unknown data format: {type(data).__name__}'))
135
-
136
- mode = 'w' if force_overwrite else 'w-'
137
- nxstructure.save(filename, mode=mode)
138
-
139
- return(data)
140
-
141
-
142
- def get_nxdata_from_dataset(self, dset):
143
- '''Return an instance of `nexusformat.nexus.NXdata` that represents the
144
- data and metadata attributes contained in `dset`.
145
-
146
- :param dset: the input dataset to represent
147
- :type data: xarray.Dataset
148
- :return: `dset` represented as an instance of `nexusformat.nexus.NXdata`
149
- :rtype: nexusformat.nexus.NXdata
150
- '''
151
-
152
- from nexusformat.nexus import NXdata, NXfield
153
-
154
- nxdata_args = {'signal':None, 'axes':()}
155
-
156
- for var in dset.data_vars:
157
- data_var = dset[var]
158
- nxfield = NXfield(data_var.data,
159
- name=data_var.name,
160
- attrs=data_var.attrs)
161
- if nxdata_args['signal'] is None:
162
- nxdata_args['signal'] = nxfield
163
- else:
164
- nxdata_args[var] = nxfield
165
-
166
- for coord in dset.coords:
167
- coord_var = dset[coord]
168
- nxfield = NXfield(coord_var.data,
169
- name=coord_var.name,
170
- attrs=coord_var.attrs)
171
- nxdata_args['axes'] = (*nxdata_args['axes'], nxfield)
172
-
173
- nxdata = NXdata(**nxdata_args)
174
- nxdata.attrs['xarray_attrs'] = json.dumps(dset.attrs)
175
-
176
- return(nxdata)
177
-
178
- def get_nxdata_from_dataarray(self, darr):
179
- '''Return an instance of `nexusformat.nexus.NXdata` that represents the
180
- data and metadata attributes contained in `darr`.
181
-
182
- :param darr: the input dataset to represent
183
- :type darr: xarray.DataArray
184
- :return: `darr` represented as an instance of `nexusformat.nexus.NXdata`
185
- :rtype: nexusformat.nexus.NXdata
186
- '''
187
-
188
- from nexusformat.nexus import NXdata, NXfield
189
-
190
- nxdata_args = {'signal':None, 'axes':()}
191
-
192
- nxdata_args['signal'] = NXfield(darr.data,
193
- name=darr.name,
194
- attrs=darr.attrs)
195
-
196
-
197
- for coord in darr.coords:
198
- coord_var = darr[coord]
199
- nxfield = NXfield(coord_var.data,
200
- name=coord_var.name,
201
- attrs=coord_var.attrs)
202
- nxdata_args['axes'] = (*nxdata_args['axes'], nxfield)
203
-
204
- nxdata = NXdata(**nxdata_args)
205
- nxdata.attrs['xarray_attrs'] = json.dumps(darr.attrs)
206
-
207
- return(nxdata)
208
-
209
-
210
55
  class OptionParser():
211
- '''User based option parser'''
212
- def __init__(self):
213
- self.parser = argparse.ArgumentParser(prog='PROG')
214
- self.parser.add_argument("--data", action="store",
215
- dest="data", default="", help="Input data")
216
- self.parser.add_argument("--filename", action="store",
217
- dest="filename", default="", help="Output file")
218
- self.parser.add_argument("--writer", action="store",
219
- dest="writer", default="Writer", help="Writer class name")
220
- self.parser.add_argument('--log-level', choices=logging._nameToLevel.keys(),
56
+ '''User based option parser'''
57
+ def __init__(self):
58
+ self.parser = argparse.ArgumentParser(prog='PROG')
59
+ self.parser.add_argument(
60
+ '--data', action='store',
61
+ dest='data', default='', help='Input data')
62
+ self.parser.add_argument(
63
+ '--filename', action='store',
64
+ dest='filename', default='', help='Output file')
65
+ self.parser.add_argument(
66
+ '--writer', action='store',
67
+ dest='writer', default='Writer', help='Writer class name')
68
+ self.parser.add_argument(
69
+ '--log-level', choices=logging._nameToLevel.keys(),
221
70
  dest='log_level', default='INFO', help='logging level')
222
71
 
223
- def main():
72
+ def main(opt_parser=OptionParser):
224
73
  '''Main function'''
225
- optmgr = OptionParser()
74
+
75
+ optmgr = opt_parser()
226
76
  opts = optmgr.parser.parse_args()
227
77
  clsName = opts.writer
228
78
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChessAnalysisPipeline
3
- Version: 0.0.2
3
+ Version: 0.0.4
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
@@ -0,0 +1,50 @@
1
+ CHAP/__init__.py,sha256=t3gMEDUIChA7W1XF2zJTisA4hoF2WijDO_EJLlV2EYo,99
2
+ CHAP/pipeline.py,sha256=bmPFPlzmU7GvRa5KBd5zo6u_Rk9qtkG5tgiRvpfwcxg,2156
3
+ CHAP/processor.py,sha256=j3GOvwQufL37gt2YKe2c8tZjEH2OtEUDRkgHpu26dck,4247
4
+ CHAP/reader.py,sha256=12Xn78J06KJ5wzGnCZKSiak8irCtOVX2wtxV7eH3Pb0,3577
5
+ CHAP/runner.py,sha256=MA0Q3KTAnPnw25i1L7XPs4ZkszfRfByD_qBshsokL2A,2412
6
+ CHAP/writer.py,sha256=tDeQIEgTm-p8zH0g8EmqFTiGBFRM_A_Q9PyBjE1vaac,2759
7
+ CHAP/common/__init__.py,sha256=cnkVDvaf3NhnmBAzwuUFpotYv9VWxOVhKwqE0qZLbNQ,991
8
+ CHAP/common/processor.py,sha256=sEiSFqXhskrKVV6BDwGFwWpbAJ0aV1JXz2BO1l3oql4,24425
9
+ CHAP/common/reader.py,sha256=DqKRLfG5PLf2aj039aV2FIN5ZmhR7XkZ6EyPDSLUZqY,3547
10
+ CHAP/common/writer.py,sha256=HwMMCVldjQGb3HK9ysfdyfkUplnrdZjyqHnon0ne3DU,2910
11
+ CHAP/common/models/__init__.py,sha256=wkCmQ08zciMzjbQVBjKZacSPUGICqTFcfJ3VaWYBtNY,106
12
+ CHAP/common/models/integration.py,sha256=q18QpPtI7iLd1Asj3NnKbHmB5YIlLm9crKPmtLT37c0,25169
13
+ CHAP/common/models/map.py,sha256=OXtXhohGrKrPCgkvxrweSDxnYpJf39KXxvvYsE5JBTo,25035
14
+ CHAP/common/utils/__init__.py,sha256=lDyThufb9FjaqtUnZ7vDEyaF0r9S5Wo5Ty4qkjYNZRY,1497
15
+ CHAP/common/utils/fit.py,sha256=-nOPfd6yUnUDNyLjLGJVxOp0ET4fKD-Bwh5C_bLx8bY,127303
16
+ CHAP/common/utils/general.py,sha256=VkGFECXdbB2NicOt9iGhpIJPdvGPc6eHdtiaiqzDM1A,48178
17
+ CHAP/common/utils/material.py,sha256=KQfORTqLbp8p9pWeSYD6mYzzpYncIEfbHVPiZ5E1PrA,10472
18
+ CHAP/common/utils/scanparsers.py,sha256=ZxFgMQrD98vTjXbkqPXpA_xjWhL7Gk0cIBD0mvf67GQ,34386
19
+ CHAP/edd/__init__.py,sha256=0POOQcuL72QQJghdN9LfYHNZCHdAOjYaLYg2ebr_URo,262
20
+ CHAP/edd/models.py,sha256=E3gUBI0bgnR_GoLJE5XkY8bOWs7z44dcK0QaqqP0vXU,8448
21
+ CHAP/edd/processor.py,sha256=AjI9CZyzBDgBNzKb72n1sc_dkH60LY0h5SyXTkTPbUo,13557
22
+ CHAP/edd/reader.py,sha256=md3gt82kjNOR3mMjcsCfqbmWLuPhl6JA6Qk1ek9tItA,96
23
+ CHAP/edd/writer.py,sha256=jQGikOjYx7-MURPqMkDqYw8sig2HauGulUlH1nf-jvY,96
24
+ CHAP/inference/__init__.py,sha256=huci54T9WyoORENtAO-Wq7qdKfQvh8ocaRwOAoov2fo,129
25
+ CHAP/inference/processor.py,sha256=Sl317ovfhAQPeThOe3Es6soHxH-ckusFiX9GPqxhfMw,2648
26
+ CHAP/inference/reader.py,sha256=md3gt82kjNOR3mMjcsCfqbmWLuPhl6JA6Qk1ek9tItA,96
27
+ CHAP/inference/writer.py,sha256=jQGikOjYx7-MURPqMkDqYw8sig2HauGulUlH1nf-jvY,96
28
+ CHAP/saxswaxs/__init__.py,sha256=aVB0vCzeQYr7sQfodr_qE9896aErCY-wcVf2hGoW-vs,196
29
+ CHAP/saxswaxs/processor.py,sha256=C8BXfAvPqoNR_Xpk9CmDOiWY3ZhW4E32SJ2jY3N5WgU,99
30
+ CHAP/saxswaxs/reader.py,sha256=md3gt82kjNOR3mMjcsCfqbmWLuPhl6JA6Qk1ek9tItA,96
31
+ CHAP/saxswaxs/writer.py,sha256=jQGikOjYx7-MURPqMkDqYw8sig2HauGulUlH1nf-jvY,96
32
+ CHAP/sin2psi/__init__.py,sha256=tYTpc0_bhJ9zCwwaILtkekLR7R3SxzkynugY6D3djnE,243
33
+ CHAP/sin2psi/processor.py,sha256=C8BXfAvPqoNR_Xpk9CmDOiWY3ZhW4E32SJ2jY3N5WgU,99
34
+ CHAP/sin2psi/reader.py,sha256=md3gt82kjNOR3mMjcsCfqbmWLuPhl6JA6Qk1ek9tItA,96
35
+ CHAP/sin2psi/writer.py,sha256=jQGikOjYx7-MURPqMkDqYw8sig2HauGulUlH1nf-jvY,96
36
+ CHAP/tomo/__init__.py,sha256=cFq3uemguYhC3y2hKAO60Omoll5p8mWBHdCrCjBWfCA,150
37
+ CHAP/tomo/models.py,sha256=8-sFRVfbMyy-R0p3HdNaJXH1K9YKDgb4JEXehPYuRns,4857
38
+ CHAP/tomo/processor.py,sha256=_TILlIyM4-dy18CTmqJ0xF-MR0x3RKwppW1mt_dcqV0,97527
39
+ CHAP/tomo/reader.py,sha256=md3gt82kjNOR3mMjcsCfqbmWLuPhl6JA6Qk1ek9tItA,96
40
+ CHAP/tomo/writer.py,sha256=jQGikOjYx7-MURPqMkDqYw8sig2HauGulUlH1nf-jvY,96
41
+ MLaaS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ MLaaS/ktrain.py,sha256=SPDUOQgjBDSx7sI8vZNXog9orvSyKmzpe6TdGHol9qM,7467
43
+ MLaaS/mnist_img.py,sha256=ppDtlo6yrNQy0oIhFZVOnLvHJrR3ZPZ3PjZTtJY8l0E,2738
44
+ MLaaS/tfaas_client.py,sha256=zpZ201wwcQBW1XkzDakD9Kl_NRSESAUdbnN6k6Ey15A,14889
45
+ ChessAnalysisPipeline-0.0.4.dist-info/LICENSE,sha256=GrJL25aZivxje_x-zBbeWASvdmgztxv8kBMhIP4XSMo,1075
46
+ ChessAnalysisPipeline-0.0.4.dist-info/METADATA,sha256=KzNtqjPNZkHL92ukFXnF96tA2wv8xvEL5XDKdp-XafM,1219
47
+ ChessAnalysisPipeline-0.0.4.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
48
+ ChessAnalysisPipeline-0.0.4.dist-info/entry_points.txt,sha256=w-KIKdUjmj5GCobrFC4_jexCsFB4yMXYjrsMWrhI6Co,42
49
+ ChessAnalysisPipeline-0.0.4.dist-info/top_level.txt,sha256=BKhggOWLb9dD6oQm1RXrkJPnXm-zJxVzQef1iXYtt2k,11
50
+ ChessAnalysisPipeline-0.0.4.dist-info/RECORD,,
CHAP/async.py DELETED
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env python
2
- #-*- coding: utf-8 -*-
3
- #pylint: disable=
4
- """
5
- File : async.py
6
- Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
7
- Description: AsyncProcessor module
8
- """
9
-
10
- # system modules
11
- import asyncio
12
-
13
- # local modules
14
- from CHAP.processor import Processor, PrintProcessor
15
-
16
-
17
- async def task(mgr, doc):
18
- """
19
- Process given data using provided task manager
20
- """
21
- return mgr.process(doc)
22
-
23
-
24
- async def executeTasks(mgr, docs):
25
- """
26
- Process given set of documents using provided task manager
27
- """
28
- coRoutines = [task(mgr, d) for d in docs]
29
- await asyncio.gather(*coRoutines)
30
-
31
-
32
- class AsyncProcessor(Processor):
33
- """
34
- AsyncProcesor process given data via asyncio module
35
- """
36
- def __init__(self, mgr):
37
- super().__init__()
38
- self.mgr = mgr
39
-
40
- def _process(self, docs):
41
- """
42
- Internal method to process given data documents
43
- """
44
- asyncio.run(executeTasks(self.mgr, docs))
45
-
46
- def example():
47
- """
48
- Helper function to demonstrate usage of AsyncProcessor
49
- """
50
- docs = [1,2,3]
51
- mgr = PrintProcessor()
52
- processor = AsyncProcessor(mgr)
53
- processor.process(docs)
54
-
55
- if __name__ == '__main__':
56
- example()
@@ -1,17 +0,0 @@
1
- CHAP/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- CHAP/async.py,sha256=VSfC0fv339SgRYGwhZ2ChYpZC3flkD1zs3JdpBqpoko,1203
3
- CHAP/pipeline.py,sha256=S_o6Kw3vz-tgLPSF-CSSzsQSyASlR3spALHP3YATqkQ,2158
4
- CHAP/processor.py,sha256=CzcuMSKWzJ6GsI12euarvjcHJ-bW-GsrtCPQJllxC4w,38795
5
- CHAP/reader.py,sha256=uuZlBqfehhnRzHl_H0C0_1u8rzaVpMs2Wq0dKpor-V0,6664
6
- CHAP/runner.py,sha256=MA0Q3KTAnPnw25i1L7XPs4ZkszfRfByD_qBshsokL2A,2412
7
- CHAP/writer.py,sha256=P8jEFuJgHLwDBNd5qvPLce5w0hH-Rzroj39vru3G7l4,7788
8
- MLaaS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- MLaaS/ktrain.py,sha256=SPDUOQgjBDSx7sI8vZNXog9orvSyKmzpe6TdGHol9qM,7467
10
- MLaaS/mnist_img.py,sha256=ppDtlo6yrNQy0oIhFZVOnLvHJrR3ZPZ3PjZTtJY8l0E,2738
11
- MLaaS/tfaas_client.py,sha256=zpZ201wwcQBW1XkzDakD9Kl_NRSESAUdbnN6k6Ey15A,14889
12
- ChessAnalysisPipeline-0.0.2.dist-info/LICENSE,sha256=GrJL25aZivxje_x-zBbeWASvdmgztxv8kBMhIP4XSMo,1075
13
- ChessAnalysisPipeline-0.0.2.dist-info/METADATA,sha256=ZCX-n7Cass_Kk6bDslYFmJEu9x62J9AAWbA4ViG6QgI,1219
14
- ChessAnalysisPipeline-0.0.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
15
- ChessAnalysisPipeline-0.0.2.dist-info/entry_points.txt,sha256=w-KIKdUjmj5GCobrFC4_jexCsFB4yMXYjrsMWrhI6Co,42
16
- ChessAnalysisPipeline-0.0.2.dist-info/top_level.txt,sha256=BKhggOWLb9dD6oQm1RXrkJPnXm-zJxVzQef1iXYtt2k,11
17
- ChessAnalysisPipeline-0.0.2.dist-info/RECORD,,