From d8dd92be2ad7797f2ad28ebd760395638b1b3a4a Mon Sep 17 00:00:00 2001 From: Leszek Grzanka Date: Thu, 12 Dec 2024 17:09:17 +0100 Subject: [PATCH] txt converter update --- pymchelper/run.py | 6 +++--- pymchelper/writers/shieldhit.py | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pymchelper/run.py b/pymchelper/run.py index 7b2eed33b..5b12a0cff 100644 --- a/pymchelper/run.py +++ b/pymchelper/run.py @@ -67,6 +67,9 @@ def main(args=None): default=ImageWriter.default_colormap, type=str) + parser_plotdata = subparsers.add_parser(Converters.plotdata.name, help='converts to plot data') + add_default_options(parser_plotdata) + parser_excel = subparsers.add_parser(Converters.excel.name, help='converts to MS Excel file') add_default_options(parser_excel) @@ -79,9 +82,6 @@ def main(args=None): parser_json = subparsers.add_parser(Converters.json.name, help='converts to JSON file') add_default_options(parser_json) - parser_plotdata = subparsers.add_parser(Converters.plotdata.name, help='converts to plot data') - add_default_options(parser_plotdata) - parser_inspect = subparsers.add_parser(Converters.inspect.name, help='prints metadata') add_default_options(parser_inspect) parser_inspect.add_argument('-d', '--details', diff --git a/pymchelper/writers/shieldhit.py b/pymchelper/writers/shieldhit.py index b36d1c133..596557122 100644 --- a/pymchelper/writers/shieldhit.py +++ b/pymchelper/writers/shieldhit.py @@ -3,6 +3,7 @@ import numpy as np +from pymchelper.estimator import Estimator from pymchelper.shieldhit.detector.detector_type import SHDetType from pymchelper.shieldhit.detector.estimator_type import SHGeoType @@ -111,8 +112,14 @@ def _header_no_of_bins_and_prim(self, estimator): return header - def write(self, estimator): + def write(self, estimator: Estimator): """TODO""" + + if estimator.file_format not in {'bdo2016', 'bdo2019'}: + logger.error("Unsupported file format: %s", estimator.file_format) + logger.error("This converter is designed for SHIELD-HIT12A output files only.") + logger.error("Please use convertmc plotdata converter instead to generate text files.") + # save to single page to a file without number (i.e. output.dat) if len(estimator.pages) == 1: self.write_single_page(estimator.pages[0], self.filename)