Mercurial > repos > rv43 > tomo
comparison read_image.py @ 49:26f99fdd8d61 draft
"planemo upload for repository https://github.com/rolfverberg/galaxytools commit 4f7738d02f4a3fd91373f43937ed311b6fe11a12"
author | rv43 |
---|---|
date | Thu, 28 Jul 2022 16:05:24 +0000 |
parents | |
children | 97c4e2cbbad9 |
comparison
equal
deleted
inserted
replaced
48:059819ea1f0e | 49:26f99fdd8d61 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 import logging | |
4 | |
5 import sys | |
6 import argparse | |
7 import numpy as np | |
8 | |
9 def __main__(): | |
10 | |
11 # Parse command line arguments | |
12 parser = argparse.ArgumentParser( | |
13 description='Read a reconstructed image') | |
14 parser.add_argument('-i', '--input_image', | |
15 help='Reconstructed image file') | |
16 parser.add_argument('-l', '--log', | |
17 type=argparse.FileType('w'), | |
18 default=sys.stdout, | |
19 help='Log file') | |
20 args = parser.parse_args() | |
21 | |
22 # Set basic log configuration | |
23 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' | |
24 log_level = 'INFO' | |
25 level = getattr(logging, log_level.upper(), None) | |
26 if not isinstance(level, int): | |
27 raise ValueError(f'Invalid log_level: {log_level}') | |
28 logging.basicConfig(format=logging_format, level=level, force=True, | |
29 handlers=[logging.StreamHandler()]) | |
30 | |
31 logging.info(f'input_image = {args.input_image}') | |
32 logging.debug(f'log = {args.log}') | |
33 logging.debug(f'is log stdout? {args.log is sys.stdout}') | |
34 | |
35 # Load image | |
36 f = np.load(args.input_image) | |
37 logging.info(f'f shape = {f.shape}') | |
38 | |
39 if __name__ == "__main__": | |
40 __main__() | |
41 |