Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/implementors/imageviewer/createmap.py: 24%
29 statements
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
1import math
3import numpy as np
5from daiquiri.core.components import ComponentActor
6from daiquiri.core.utils import worker
9class CreatemapActor(ComponentActor):
10 name = "createmap"
12 def method(self, **kwargs):
13 evperbin = kwargs["spectra"]["conversion"]["scale"]
14 offset = kwargs["spectra"]["conversion"]["zero"]
16 pts = kwargs["spectra"]["npoints"]
17 avail = kwargs["spectra"]["npoints_avail"]
19 spectra = kwargs["spectra"]["data"]
21 def generate():
22 maps = []
23 for s in spectra:
24 spec = []
25 mca = kwargs["spectra"]["data"][s]["data"]
27 for r in kwargs["rois"]:
28 roi = []
29 for p in range(pts):
30 if p < avail:
31 start = max(0, math.floor((r["start"] - offset) / evperbin))
32 end = min(
33 math.ceil((r["end"] - offset) / evperbin), len(mca[p])
34 )
35 roi.append(int(np.sum(mca[p][start:end])))
37 else:
38 roi.append(-1)
40 spec.append({"maproiid": r["maproiid"], "data": roi})
42 maps.append({"det": s, "maps": spec})
44 return maps
46 return worker(generate)