Skip to content

Commit

Permalink
enable cli and gui for module
Browse files Browse the repository at this point in the history
  • Loading branch information
KedoKudo committed Oct 3, 2024
1 parent b6473a2 commit cdf0869
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ibeatles/__init__.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
31 changes: 27 additions & 4 deletions src/ibeatles/__main__.py
Original file line number Diff line number Diff line change
@@ -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())
49 changes: 49 additions & 0 deletions tests/data/json/demo_config.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit cdf0869

Please sign in to comment.