Skip to content

Commit 3b08462

Browse files
add input argument for z-scan file and function for computing muD from that file
1 parent 17afd13 commit 3b08462

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/diffpy/labpdfproc/labpdfprocapp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ def get_args(override_cli_inputs=None):
124124
),
125125
default=None,
126126
)
127+
p.add_argument(
128+
"-z",
129+
"--z-scan-file",
130+
help="Path to the z-scan file to be loaded to overload the mu*D value.",
131+
default=None,
132+
)
127133
args = p.parse_args(override_cli_inputs)
128134
return args
129135

src/diffpy/labpdfproc/tools.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
from pathlib import Path
33

4+
from diffpy.labpdfproc.mud_calculator import compute_mud
45
from diffpy.utils.tools import get_package_info, get_user_info
56

67
WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54}
@@ -134,6 +135,28 @@ def set_wavelength(args):
134135
return args
135136

136137

138+
def set_mud(args):
139+
"""
140+
Set the mud based on the given input arguments
141+
142+
Parameters
143+
----------
144+
args argparse.Namespace
145+
the arguments from the parser
146+
147+
Returns
148+
-------
149+
args argparse.Namespace
150+
"""
151+
if args.z_scan_file:
152+
filepath = Path(args.z_scan_file).resolve()
153+
if not filepath.is_file():
154+
raise FileNotFoundError(f"Cannot find {args.z_scan_file}. Please specify a valid file path.")
155+
args.z_scan_file = filepath
156+
args.mud = compute_mud(filepath)
157+
return args
158+
159+
137160
def _load_key_value_pair(s):
138161
items = s.split("=")
139162
key = items[0].strip()
@@ -234,6 +257,7 @@ def preprocessing_args(args):
234257
args = set_input_lists(args)
235258
args.output_directory = set_output_directory(args)
236259
args = set_wavelength(args)
260+
args = set_mud(args)
237261
args = load_user_metadata(args)
238262
return args
239263

0 commit comments

Comments
 (0)