-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFormatSEReBICpedestal.py
42 lines (31 loc) · 1.31 KB
/
FormatSEReBICpedestal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# FormatSEReBICpedestal.py
from __future__ import annotations
# Experimental format for TIA .ser files used by FEI microscope at eBIC. This
# version adds a pedestal level to the image data as determined by the
# environment variable ADD_PEDESTAL. A warning will be issued to counter
# against the use of this format by mistake
import logging
import os
from dxtbx.format.FormatSEReBIC import FormatSEReBIC
logger = logging.getLogger("dials")
class FormatSEReBICpedestal(FormatSEReBIC):
def __init__(self, image_file, **kwargs):
from dxtbx import IncorrectFormatError
if not self.understand(image_file):
raise IncorrectFormatError(self, image_file)
FormatSEReBIC.__init__(self, image_file, **kwargs)
self.pedestal = os.environ.get("ADD_PEDESTAL", 0)
self.pedestal = float(self.pedestal)
logger.info(
"WARNING: Using FormatSEReBICpedestal. The value {0} will "
"be added to all pixels".format(self.pedestal)
)
def get_raw_data(self, index):
raw_data = super(FormatSEReBICpedestal, self).get_raw_data(index).as_double()
raw_data += self.pedestal
return raw_data
if __name__ == "__main__":
import sys
for arg in sys.argv[1:]:
print(FormatSEReBICpedestal.understand(arg))