Mercurial > repos > rv43 > tomo
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/read_image.py Thu Jul 28 16:05:24 2022 +0000 @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import logging + +import sys +import argparse +import numpy as np + +def __main__(): + + # Parse command line arguments + parser = argparse.ArgumentParser( + description='Read a reconstructed image') + parser.add_argument('-i', '--input_image', + help='Reconstructed image file') + parser.add_argument('-l', '--log', + type=argparse.FileType('w'), + default=sys.stdout, + help='Log file') + args = parser.parse_args() + + # Set basic log configuration + logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' + log_level = 'INFO' + level = getattr(logging, log_level.upper(), None) + if not isinstance(level, int): + raise ValueError(f'Invalid log_level: {log_level}') + logging.basicConfig(format=logging_format, level=level, force=True, + handlers=[logging.StreamHandler()]) + + logging.info(f'input_image = {args.input_image}') + logging.debug(f'log = {args.log}') + logging.debug(f'is log stdout? {args.log is sys.stdout}') + + # Load image + f = np.load(args.input_image) + logging.info(f'f shape = {f.shape}') + +if __name__ == "__main__": + __main__() +