diff --git a/src/ibeatles/__init__.py b/src/ibeatles/__init__.py index bea73851..78f8489e 100644 --- a/src/ibeatles/__init__.py +++ b/src/ibeatles/__init__.py @@ -1,7 +1,7 @@ import os from qtpy.uic import loadUi -from src.ibeatles import ui +from ibeatles import ui root = os.path.dirname(os.path.realpath(__file__)) refresh_image = os.path.join(root, "icons/refresh.png") diff --git a/src/ibeatles/__main__.py b/src/ibeatles/__main__.py index c9a5dc1f..5ff1ecd0 100644 --- a/src/ibeatles/__main__.py +++ b/src/ibeatles/__main__.py @@ -1,8 +1,31 @@ -from .ibeatles import main +#!/usr/bin/env python +"""Module entry""" import sys +import argparse +from pathlib import Path +from ibeatles.ibeatles import main as gui_main +from ibeatles.app.cli import main as cli_main -__file__ = "ibeatles.py" -__main__ = "iBeatles" -sys.exit(main(sys.argv)) +def main(): + parser = argparse.ArgumentParser(description="iBeatles - Bragg Edge Analysis Tool") + parser.add_argument("--no-gui", action="store_true", help="Run in CLI mode") + parser.add_argument( + "config", nargs="?", help="Path to the configuration file for CLI mode" + ) + parser.add_argument("--log", type=Path, help="Path to the log file (optional)") + + args = parser.parse_args() + + if args.no_gui: + if not args.config: + print("Error: Configuration file is required for CLI mode.") + sys.exit(1) + cli_main(args.config, args.log) + else: + gui_main(sys.argv) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/data/json/demo_config.json b/tests/data/json/demo_config.json new file mode 100644 index 00000000..00d7a51f --- /dev/null +++ b/tests/data/json/demo_config.json @@ -0,0 +1,49 @@ +{ + "raw_data": { + "raw_data_dir": "/Users/8cz/SNS/SNAP/IPTS-26171/shared/mcp_transfer/corrected/Inconel_Sample", + "raw_data_extension": ".fits" + }, + "open_beam": { + "open_beam_data_dir": "/Users/8cz/SNS/SNAP/IPTS-26171/shared/mcp_transfer/corrected/Inconel_OB", + "open_beam_data_extension": ".fits" + }, + "normalization": { + "sample_background": [ + { "x0": 10, "y0": 10, "width": 50, "height": 50}, + { "x0": 0, "y0": 0, "width": 3, "height": 3} + ], + "moving_average": { + "active": true, + "dimension": "2D", + "size": { + "y": 3, + "x": 3 + }, + "type": "Box" + }, + "processing_order": "Moving average, Normalization" + }, + "analysis": { + "material": { + "element": "Fe" + }, + "pixel_binning": { + "x0": 0, + "y0": 0, + "width": 100, + "height": 100, + "bins_size": 1 + }, + "fitting": { + "lambda_min": 0.5, + "lambda_max": 5.0 + }, + "strain_mapping": {}, + "distance_source_detector_in_m": 10.0, + "detector_offset_in_us": 4500.0 + }, + "output": { + "normalized_data_dir": "/Users/8cz/tmp/ibeatles_dev/normalized", + "analysis_results_dir": "/Users/8cz/tmp/ibeatles_dev/analysis" + } +}