Mercurial > repos > kls286 > chap_test_20230328
annotate build/lib/CHAP/models/integration.py @ 1:1016ae8f31ec draft
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
| author | kls286 | 
|---|---|
| date | Tue, 28 Mar 2023 15:16:40 +0000 | 
| parents | cbbe42422d56 | 
| children | 
| rev | line source | 
|---|---|
| 
0
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
1 import copy | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
2 from functools import cache, lru_cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
3 import json | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
4 import logging | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
5 import os | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
6 from time import time | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
7 from typing import Literal, Optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
8 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
9 from msnctools.general import input_menu | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
10 from multiprocessing.pool import ThreadPool | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
11 from nexusformat.nexus import (NXdata, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
12 NXdetector, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
13 NXfield, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
14 NXprocess, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
15 NXroot) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
16 import numpy as np | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
17 from pydantic import (BaseModel, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
18 validator, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
19 constr, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
20 conlist, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
21 conint, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
22 confloat, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
23 FilePath) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
24 import pyFAI, pyFAI.multi_geometry, pyFAI.units | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
25 from pyspec.file.tiff import TiffFile | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
26 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
27 from .map import MapConfig, SpecScans | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
28 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
29 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
30 class Detector(BaseModel): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
31 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
32 Detector class to represent a single detector used in the experiment. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
33 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
34 :param prefix: Prefix of the detector in the SPEC file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
35 :type prefix: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
36 :param poni_file: Path to the poni file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
37 :type poni_file: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
38 :param mask_file: Optional path to the mask file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
39 :type mask_file: str, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
40 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
41 prefix: constr(strip_whitespace=True, min_length=1) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
42 poni_file: FilePath | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
43 mask_file: Optional[FilePath] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
44 @validator('poni_file', allow_reuse=True) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
45 def validate_poni_file(cls, poni_file): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
46 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
47 Validate the poni file by checking if it's a valid PONI file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
48 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
49 :param poni_file: Path to the poni file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
50 :type poni_file: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
51 :raises ValueError: If poni_file is not a valid PONI file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
52 :returns: Absolute path to the poni file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
53 :rtype: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
54 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
55 poni_file = os.path.abspath(poni_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
56 try: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
57 ai = azimuthal_integrator(poni_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
58 except: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
59 raise(ValueError(f'{poni_file} is not a valid PONI file')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
60 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
61 return(poni_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
62 @validator('mask_file', allow_reuse=True) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
63 def validate_mask_file(cls, mask_file, values): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
64 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
65 Validate the mask file. If a mask file is provided, it checks if it's a valid TIFF file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
66 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
67 :param mask_file: Path to the mask file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
68 :type mask_file: str or None | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
69 :param values: A dictionary of the Detector fields. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
70 :type values: dict | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
71 :raises ValueError: If mask_file is provided and it's not a valid TIFF file. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
72 :raises ValueError: If `'poni_file'` is not provided in `values`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
73 :returns: Absolute path to the mask file or None. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
74 :rtype: str or None | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
75 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
76 if mask_file is None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
77 return(mask_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
78 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
79 mask_file = os.path.abspath(mask_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
80 poni_file = values.get('poni_file') | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
81 if poni_file is None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
82 raise(ValueError('Cannot validate mask file without a PONI file.')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
83 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
84 try: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
85 mask_array = get_mask_array(mask_file, poni_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
86 except BaseException as e: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
87 raise(ValueError(f'Unable to open {mask_file} as a TIFF file')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
88 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
89 return(mask_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
90 @property | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
91 def azimuthal_integrator(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
92 return(azimuthal_integrator(self.poni_file)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
93 @property | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
94 def mask_array(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
95 return(get_mask_array(self.mask_file, self.poni_file)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
96 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
97 @cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
98 def azimuthal_integrator(poni_file:str): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
99 if not isinstance(poni_file, str): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
100 poni_file = str(poni_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
101 return(pyFAI.load(poni_file)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
102 @cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
103 def get_mask_array(mask_file:str, poni_file:str): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
104 if mask_file is not None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
105 if not isinstance(mask_file, str): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
106 mask_file = str(mask_file) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
107 with TiffFile(mask_file) as tiff: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
108 mask_array = tiff.asarray() | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
109 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
110 mask_array = np.zeros(azimuthal_integrator(poni_file).detector.shape) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
111 return(mask_array) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
112 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
113 class IntegrationConfig(BaseModel): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
114 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
115 Class representing the configuration for a raw detector data integration. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
116 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
117 :ivar tool_type: type of integration tool; always set to "integration" | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
118 :type tool_type: str, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
119 :ivar title: title of the integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
120 :type title: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
121 :ivar integration_type: type of integration, one of "azimuthal", "radial", or "cake" | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
122 :type integration_type: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
123 :ivar detectors: list of detectors used in the integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
124 :type detectors: List[Detector] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
125 :ivar radial_units: radial units for the integration, defaults to `'q_A^-1'` | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
126 :type radial_units: str, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
127 :ivar radial_min: minimum radial value for the integration range | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
128 :type radial_min: float, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
129 :ivar radial_max: maximum radial value for the integration range | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
130 :type radial_max: float, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
131 :ivar radial_npt: number of points in the radial range for the integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
132 :type radial_npt: int, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
133 :ivar azimuthal_units: azimuthal units for the integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
134 :type azimuthal_units: str, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
135 :ivar azimuthal_min: minimum azimuthal value for the integration range | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
136 :type azimuthal_min: float, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
137 :ivar azimuthal_max: maximum azimuthal value for the integration range | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
138 :type azimuthal_max: float, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
139 :ivar azimuthal_npt: number of points in the azimuthal range for the integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
140 :type azimuthal_npt: int, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
141 :ivar error_model: error model for the integration, one of "poisson" or "azimuthal" | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
142 :type error_model: str, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
143 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
144 tool_type: Literal['integration'] = 'integration' | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
145 title: constr(strip_whitespace=True, min_length=1) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
146 integration_type: Literal['azimuthal', 'radial', 'cake'] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
147 detectors: conlist(item_type=Detector, min_items=1) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
148 radial_units: str = 'q_A^-1' | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
149 radial_min: confloat(ge=0) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
150 radial_max: confloat(gt=0) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
151 radial_npt: conint(gt=0) = 1800 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
152 azimuthal_units: str = 'chi_deg' | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
153 azimuthal_min: confloat(ge=-180) = -180 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
154 azimuthal_max: confloat(le=360) = 180 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
155 azimuthal_npt: conint(gt=0) = 3600 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
156 error_model: Optional[Literal['poisson', 'azimuthal']] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
157 sequence_index: Optional[conint(gt=0)] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
158 @validator('radial_units', allow_reuse=True) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
159 def validate_radial_units(cls, radial_units): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
160 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
161 Validate the radial units for the integration. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
162 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
163 :param radial_units: unvalidated radial units for the integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
164 :type radial_units: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
165 :raises ValueError: if radial units are not one of the recognized radial units | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
166 :return: validated radial units | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
167 :rtype: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
168 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
169 if radial_units in pyFAI.units.RADIAL_UNITS.keys(): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
170 return(radial_units) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
171 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
172 raise(ValueError(f'Invalid radial units: {radial_units}. Must be one of {", ".join(pyFAI.units.RADIAL_UNITS.keys())}')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
173 @validator('azimuthal_units', allow_reuse=True) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
174 def validate_azimuthal_units(cls, azimuthal_units): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
175 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
176 Validate that `azimuthal_units` is one of the keys in the | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
177 `pyFAI.units.AZIMUTHAL_UNITS` dictionary. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
178 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
179 :param azimuthal_units: The string representing the unit to be validated. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
180 :type azimuthal_units: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
181 :raises ValueError: If `azimuthal_units` is not one of the keys in `pyFAI.units.AZIMUTHAL_UNITS` | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
182 :return: The original supplied value, if is one of the keys in `pyFAI.units.AZIMUTHAL_UNITS`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
183 :rtype: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
184 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
185 if azimuthal_units in pyFAI.units.AZIMUTHAL_UNITS.keys(): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
186 return(azimuthal_units) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
187 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
188 raise(ValueError(f'Invalid azimuthal units: {azimuthal_units}. Must be one of {", ".join(pyFAI.units.AZIMUTHAL_UNITS.keys())}')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
189 def validate_range_max(range_name:str): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
190 """Validate the maximum value of an integration range. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
191 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
192 :param range_name: The name of the integration range (e.g. radial, azimuthal). | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
193 :type range_name: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
194 :return: The callable that performs the validation. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
195 :rtype: callable | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
196 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
197 def _validate_range_max(cls, range_max, values): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
198 """Check if the maximum value of the integration range is greater than its minimum value. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
199 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
200 :param range_max: The maximum value of the integration range. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
201 :type range_max: float | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
202 :param values: The values of the other fields being validated. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
203 :type values: dict | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
204 :raises ValueError: If the maximum value of the integration range is not greater than its minimum value. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
205 :return: The validated maximum range value | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
206 :rtype: float | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
207 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
208 range_min = values.get(f'{range_name}_min') | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
209 if range_min < range_max: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
210 return(range_max) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
211 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
212 raise(ValueError(f'Maximum value of integration range must be greater than minimum value of integration range ({range_name}_min={range_min}).')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
213 return(_validate_range_max) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
214 _validate_radial_max = validator('radial_max', allow_reuse=True)(validate_range_max('radial')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
215 _validate_azimuthal_max = validator('azimuthal_max', allow_reuse=True)(validate_range_max('azimuthal')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
216 def validate_for_map_config(self, map_config:MapConfig): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
217 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
218 Validate the existence of the detector data file for all scan points in `map_config`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
219 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
220 :param map_config: The `MapConfig` instance to validate against. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
221 :type map_config: MapConfig | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
222 :raises RuntimeError: If a detector data file could not be found for a scan point occurring in `map_config`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
223 :return: None | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
224 :rtype: None | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
225 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
226 for detector in self.detectors: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
227 for scans in map_config.spec_scans: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
228 for scan_number in scans.scan_numbers: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
229 scanparser = scans.get_scanparser(scan_number) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
230 for scan_step_index in range(scanparser.spec_scan_npts): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
231 # Make sure the detector data file exists for all scan points | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
232 try: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
233 detector_data_file = scanparser.get_detector_data_file(detector.prefix, scan_step_index) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
234 except: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
235 raise(RuntimeError(f'Could not find data file for detector prefix {detector.prefix} on scan number {scan_number} in spec file {scans.spec_file}')) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
236 def get_azimuthal_adjustments(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
237 """To enable a continuous range of integration in the azimuthal direction | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
238 for radial and cake integration, obtain adjusted values for this | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
239 `IntegrationConfig`'s `azimuthal_min` and `azimuthal_max` values, the | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
240 angle amount by which those values were adjusted, and the proper location | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
241 of the discontinuity in the azimuthal direction. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
242 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
243 :return: Adjusted chi_min, adjusted chi_max, chi_offset, chi_discontinuity | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
244 :rtype: tuple[float,float,float,float] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
245 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
246 return(get_azimuthal_adjustments(self.azimuthal_min, self.azimuthal_max)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
247 def get_azimuthal_integrators(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
248 """Get a list of `AzimuthalIntegrator`s that correspond to the detector | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
249 configurations in this instance of `IntegrationConfig`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
250 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
251 The returned `AzimuthalIntegrator`s are (if need be) artificially rotated | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
252 in the azimuthal direction to achieve a continuous range of integration | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
253 in the azimuthal direction. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
254 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
255 :returns: A list of `AzimuthalIntegrator`s appropriate for use by this | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
256 `IntegrationConfig` tool | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
257 :rtype: list[pyFAI.azimuthalIntegrator.AzimuthalIntegrator] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
258 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
259 chi_min, chi_max, chi_offset, chi_disc = self.get_azimuthal_adjustments() | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
260 return(get_azimuthal_integrators(tuple([detector.poni_file for detector in self.detectors]), chi_offset=chi_offset)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
261 def get_multi_geometry_integrator(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
262 """Get a `MultiGeometry` integrator suitable for use by this instance of | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
263 `IntegrationConfig`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
264 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
265 :return: A `MultiGeometry` integrator | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
266 :rtype: pyFAI.multi_geometry.MultiGeometry | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
267 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
268 poni_files = tuple([detector.poni_file for detector in self.detectors]) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
269 radial_range = (self.radial_min, self.radial_max) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
270 azimuthal_range = (self.azimuthal_min, self.azimuthal_max) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
271 return(get_multi_geometry_integrator(poni_files, self.radial_units, radial_range, azimuthal_range)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
272 def get_azimuthally_integrated_data(self, spec_scans:SpecScans, scan_number:int, scan_step_index:int): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
273 """Return azimuthally-integrated data for the scan step specified. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
274 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
275 :param spec_scans: An instance of `SpecScans` containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
276 :type spec_scans: SpecScans | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
277 :param scan_number: The number of the scan containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
278 :type scan_number: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
279 :param scan_step_index: The index of the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
280 :type scan_step_index: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
281 :return: A 1D array of azimuthally-integrated raw detector intensities. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
282 :rtype: np.ndarray | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
283 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
284 detector_data = spec_scans.get_detector_data(self.detectors, scan_number, scan_step_index) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
285 integrator = self.get_multi_geometry_integrator() | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
286 lst_mask = [detector.mask_array for detector in self.detectors] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
287 result = integrator.integrate1d(detector_data, lst_mask=lst_mask, npt=self.radial_npt, error_model=self.error_model) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
288 if result.sigma is None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
289 return(result.intensity) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
290 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
291 return(result.intensity, result.sigma) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
292 def get_radially_integrated_data(self, spec_scans:SpecScans, scan_number:int, scan_step_index:int): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
293 """Return radially-integrated data for the scan step specified. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
294 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
295 :param spec_scans: An instance of `SpecScans` containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
296 :type spec_scans: SpecScans | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
297 :param scan_number: The number of the scan containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
298 :type scan_number: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
299 :param scan_step_index: The index of the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
300 :type scan_step_index: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
301 :return: A 1D array of radially-integrated raw detector intensities. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
302 :rtype: np.ndarray | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
303 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
304 # Handle idiosyncracies of azimuthal ranges in pyFAI | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
305 # Adjust chi ranges to get a continuous range of iintegrated data | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
306 chi_min, chi_max, chi_offset, chi_disc = self.get_azimuthal_adjustments() | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
307 # Perform radial integration on a detector-by-detector basis. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
308 I_each_detector = [] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
309 variance_each_detector = [] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
310 integrators = self.get_azimuthal_integrators() | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
311 for i,(integrator,detector) in enumerate(zip(integrators,self.detectors)): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
312 detector_data = spec_scans.get_detector_data([detector], scan_number, scan_step_index)[0] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
313 result = integrator.integrate_radial(detector_data, self.azimuthal_npt, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
314 unit=self.azimuthal_units, azimuth_range=(chi_min,chi_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
315 radial_unit=self.radial_units, radial_range=(self.radial_min,self.radial_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
316 mask=detector.mask_array) #, error_model=self.error_model) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
317 I_each_detector.append(result.intensity) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
318 if result.sigma is not None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
319 variance_each_detector.append(result.sigma**2) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
320 # Add the individual detectors' integrated intensities together | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
321 I = np.nansum(I_each_detector, axis=0) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
322 # Ignore data at values of chi for which there was no data | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
323 I = np.where(I==0, np.nan, I) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
324 if len(I_each_detector) != len(variance_each_detector): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
325 return(I) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
326 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
327 # Get the standard deviation of the summed detectors' intensities | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
328 sigma = np.sqrt(np.nansum(variance_each_detector, axis=0)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
329 return(I, sigma) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
330 def get_cake_integrated_data(self, spec_scans:SpecScans, scan_number:int, scan_step_index:int): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
331 """Return cake-integrated data for the scan step specified. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
332 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
333 :param spec_scans: An instance of `SpecScans` containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
334 :type spec_scans: SpecScans | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
335 :param scan_number: The number of the scan containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
336 :type scan_number: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
337 :param scan_step_index: The index of the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
338 :type scan_step_index: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
339 :return: A 2D array of cake-integrated raw detector intensities. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
340 :rtype: np.ndarray | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
341 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
342 detector_data = spec_scans.get_detector_data(self.detectors, scan_number, scan_step_index) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
343 integrator = self.get_multi_geometry_integrator() | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
344 lst_mask = [detector.mask_array for detector in self.detectors] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
345 result = integrator.integrate2d(detector_data, lst_mask=lst_mask, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
346 npt_rad=self.radial_npt, npt_azim=self.azimuthal_npt, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
347 method='bbox', | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
348 error_model=self.error_model) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
349 if result.sigma is None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
350 return(result.intensity) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
351 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
352 return(result.intensity, result.sigma) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
353 def get_integrated_data(self, spec_scans:SpecScans, scan_number:int, scan_step_index:int): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
354 """Return integrated data for the scan step specified. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
355 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
356 :param spec_scans: An instance of `SpecScans` containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
357 :type spec_scans: SpecScans | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
358 :param scan_number: The number of the scan containing the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
359 :type scan_number: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
360 :param scan_step_index: The index of the scan step requested. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
361 :type scan_step_index: int | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
362 :return: An array of integrated raw detector intensities. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
363 :rtype: np.ndarray | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
364 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
365 if self.integration_type == 'azimuthal': | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
366 return(self.get_azimuthally_integrated_data(spec_scans, scan_number, scan_step_index)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
367 elif self.integration_type == 'radial': | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
368 return(self.get_radially_integrated_data(spec_scans, scan_number, scan_step_index)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
369 elif self.integration_type == 'cake': | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
370 return(self.get_cake_integrated_data(spec_scans, scan_number, scan_step_index)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
371 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
372 @property | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
373 def integrated_data_coordinates(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
374 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
375 Return a dictionary of coordinate arrays for navigating the dimension(s) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
376 of the integrated data produced by this instance of `IntegrationConfig`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
377 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
378 :return: A dictionary with either one or two keys: 'azimuthal' and/or | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
379 'radial', each of which points to a 1-D `numpy` array of coordinate | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
380 values. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
381 :rtype: dict[str,np.ndarray] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
382 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
383 if self.integration_type == 'azimuthal': | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
384 return(get_integrated_data_coordinates(radial_range=(self.radial_min,self.radial_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
385 radial_npt=self.radial_npt)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
386 elif self.integration_type == 'radial': | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
387 return(get_integrated_data_coordinates(azimuthal_range=(self.azimuthal_min,self.azimuthal_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
388 azimuthal_npt=self.azimuthal_npt)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
389 elif self.integration_type == 'cake': | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
390 return(get_integrated_data_coordinates(radial_range=(self.radial_min,self.radial_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
391 radial_npt=self.radial_npt, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
392 azimuthal_range=(self.azimuthal_min,self.azimuthal_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
393 azimuthal_npt=self.azimuthal_npt)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
394 @property | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
395 def integrated_data_dims(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
396 """Return a tuple of the coordinate labels for the integrated data | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
397 produced by this instance of `IntegrationConfig`. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
398 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
399 directions = list(self.integrated_data_coordinates.keys()) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
400 dim_names = [getattr(self, f'{direction}_units') for direction in directions] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
401 return(dim_names) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
402 @property | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
403 def integrated_data_shape(self): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
404 """Return a tuple representing the shape of the integrated data | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
405 produced by this instance of `IntegrationConfig` for a single scan step. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
406 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
407 return(tuple([len(coordinate_values) for coordinate_name,coordinate_values in self.integrated_data_coordinates.items()])) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
408 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
409 @cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
410 def get_azimuthal_adjustments(chi_min:float, chi_max:float): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
411 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
412 Fix chi discontinuity at 180 degrees and return the adjusted chi range, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
413 offset, and discontinuty. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
414 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
415 If the discontinuity is crossed, obtain the offset to artificially rotate | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
416 detectors to achieve a continuous azimuthal integration range. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
417 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
418 :param chi_min: The minimum value of the azimuthal range. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
419 :type chi_min: float | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
420 :param chi_max: The maximum value of the azimuthal range. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
421 :type chi_max: float | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
422 :return: The following four values: the adjusted minimum value of the | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
423 azimuthal range, the adjusted maximum value of the azimuthal range, the | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
424 value by which the chi angle was adjusted, the position of the chi | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
425 discontinuity. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
426 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
427 # Fix chi discontinuity at 180 degrees for now. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
428 chi_disc = 180 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
429 # If the discontinuity is crossed, artificially rotate the detectors to | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
430 # achieve a continuous azimuthal integration range | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
431 if chi_min < chi_disc and chi_max > chi_disc: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
432 chi_offset = chi_max - chi_disc | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
433 else: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
434 chi_offset = 0 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
435 return(chi_min-chi_offset, chi_max-chi_offset, chi_offset, chi_disc) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
436 @cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
437 def get_azimuthal_integrators(poni_files:tuple, chi_offset=0): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
438 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
439 Return a list of `AzimuthalIntegrator` objects generated from PONI files. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
440 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
441 :param poni_files: Tuple of strings, each string being a path to a PONI file. : tuple | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
442 :type poni_files: tuple | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
443 :param chi_offset: The angle in degrees by which the `AzimuthalIntegrator` objects will be rotated, defaults to 0. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
444 :type chi_offset: float, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
445 :return: List of `AzimuthalIntegrator` objects | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
446 :rtype: list[pyFAI.azimuthalIntegrator.AzimuthalIntegrator] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
447 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
448 ais = [] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
449 for poni_file in poni_files: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
450 ai = copy.deepcopy(azimuthal_integrator(poni_file)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
451 ai.rot3 += chi_offset * np.pi/180 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
452 ais.append(ai) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
453 return(ais) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
454 @cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
455 def get_multi_geometry_integrator(poni_files:tuple, radial_unit:str, radial_range:tuple, azimuthal_range:tuple): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
456 """Return a `MultiGeometry` instance that can be used for azimuthal or cake | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
457 integration. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
458 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
459 :param poni_files: Tuple of PONI files that describe the detectors to be | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
460 integrated. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
461 :type poni_files: tuple | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
462 :param radial_unit: Unit to use for radial integration range. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
463 :type radial_unit: str | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
464 :param radial_range: Tuple describing the range for radial integration. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
465 :type radial_range: tuple[float,float] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
466 :param azimuthal_range:Tuple describing the range for azimuthal integration. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
467 :type azimuthal_range: tuple[float,float] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
468 :return: `MultiGeometry` instance that can be used for azimuthal or cake | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
469 integration. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
470 :rtype: pyFAI.multi_geometry.MultiGeometry | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
471 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
472 chi_min, chi_max, chi_offset, chi_disc = get_azimuthal_adjustments(*azimuthal_range) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
473 ais = copy.deepcopy(get_azimuthal_integrators(poni_files, chi_offset=chi_offset)) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
474 multi_geometry = pyFAI.multi_geometry.MultiGeometry(ais, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
475 unit=radial_unit, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
476 radial_range=radial_range, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
477 azimuth_range=(chi_min,chi_max), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
478 wavelength=sum([ai.wavelength for ai in ais])/len(ais), | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
479 chi_disc=chi_disc) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
480 return(multi_geometry) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
481 @cache | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
482 def get_integrated_data_coordinates(azimuthal_range:tuple=None, azimuthal_npt:int=None, radial_range:tuple=None, radial_npt:int=None): | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
483 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
484 Return a dictionary of coordinate arrays for the specified radial and/or | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
485 azimuthal integration ranges. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
486 | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
487 :param azimuthal_range: Tuple specifying the range of azimuthal angles over | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
488 which to generate coordinates, in the format (min, max), defaults to | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
489 None. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
490 :type azimuthal_range: tuple[float,float], optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
491 :param azimuthal_npt: Number of azimuthal coordinate points to generate, | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
492 defaults to None. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
493 :type azimuthal_npt: int, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
494 :param radial_range: Tuple specifying the range of radial distances over | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
495 which to generate coordinates, in the format (min, max), defaults to | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
496 None. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
497 :type radial_range: tuple[float,float], optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
498 :param radial_npt: Number of radial coordinate points to generate, defaults | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
499 to None. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
500 :type radial_npt: int, optional | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
501 :return: A dictionary with either one or two keys: 'azimuthal' and/or | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
502 'radial', each of which points to a 1-D `numpy` array of coordinate | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
503 values. | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
504 :rtype: dict[str,np.ndarray] | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
505 """ | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
506 integrated_data_coordinates = {} | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
507 if azimuthal_range is not None and azimuthal_npt is not None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
508 integrated_data_coordinates['azimuthal'] = np.linspace(*azimuthal_range, azimuthal_npt) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
509 if radial_range is not None and radial_npt is not None: | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
510 integrated_data_coordinates['radial'] = np.linspace(*radial_range, radial_npt) | 
| 
 
cbbe42422d56
planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
 
kls286 
parents:  
diff
changeset
 | 
511 return(integrated_data_coordinates) | 
