File: auto_reducer.py

package info (click to toggle)
refnx 0.1.60-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,972 kB
  • sloc: python: 37,056; cpp: 1,015; ansic: 185; makefile: 180; sh: 130; lisp: 89; xml: 34
file content (34 lines) | stat: -rwxr-xr-x 1,011 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Auto reduce reflectometry files
"""
#!/usr/bin/env python
import os
import sys
import time
import argparse
from refnx.reduce import AutoReducer


def dir_path(path):
    if os.path.isdir(path):
        return path
    else:
        raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Auto-reduce reflectometry files.")
    parser.add_argument("file_list", nargs='+')
    parser.add_argument("-p", "--path", type=dir_path, default="./", help="path to datafiles")
    parser.add_argument("-s", "--scale", help="scale factor",
                        type=float, default=1.0)
    args = parser.parse_args()
    files = args.file_list
    pth = args.path
    files = [os.path.join(pth, file) for file in files]
    print(f"Path: {pth}")
    print(f"Reducing against: {files}, with scale: {args.scale}")
    ar = AutoReducer(files, data_folder=pth, scale=args.scale)

    while True:
        time.sleep(10.)