|
1 | 1 | import sys
|
2 | 2 | from argparse import ArgumentParser
|
3 | 3 |
|
| 4 | +from diffpy.labpdfproc.fast_cve import apply_fast_corr, fast_compute_cve |
4 | 5 | from diffpy.labpdfproc.functions import apply_corr, compute_cve
|
5 | 6 | from diffpy.labpdfproc.tools import known_sources, load_metadata, preprocessing_args
|
6 | 7 | from diffpy.utils.parsers.loaddata import loadData
|
@@ -72,6 +73,13 @@ def get_args(override_cli_inputs=None):
|
72 | 73 | action="store_true",
|
73 | 74 | help="Outputs will not overwrite existing file unless --force is specified.",
|
74 | 75 | )
|
| 76 | + p.add_argument( |
| 77 | + "-b", |
| 78 | + "--brute-force", |
| 79 | + action="store_true", |
| 80 | + help="The absorption correction will be computed using brute-force calculation " |
| 81 | + "if this flag is set. Default is using fast calculation. ", |
| 82 | + ) |
75 | 83 | p.add_argument(
|
76 | 84 | "-u",
|
77 | 85 | "--user-metadata",
|
@@ -134,11 +142,20 @@ def main():
|
134 | 142 | metadata=load_metadata(args, filepath),
|
135 | 143 | )
|
136 | 144 |
|
137 |
| - absorption_correction = compute_cve(input_pattern, args.mud, args.wavelength) |
138 |
| - corrected_data = apply_corr(input_pattern, absorption_correction) |
| 145 | + if args.brute_force: |
| 146 | + absorption_correction = compute_cve(input_pattern, args.mud, args.wavelength) |
| 147 | + corrected_data = apply_corr(input_pattern, absorption_correction) |
| 148 | + else: |
| 149 | + if args.mud > 6 or args.mud < 0.5: |
| 150 | + sys.exit( |
| 151 | + "mu*D is out of the acceptable range (0.5 to 6) for fast calculation. " |
| 152 | + "Please rerun with a value within this range or use -b enable brute-force calculation. " |
| 153 | + ) |
| 154 | + absorption_correction = fast_compute_cve(input_pattern, args.mud, args.wavelength) |
| 155 | + corrected_data = apply_fast_corr(input_pattern, absorption_correction) |
| 156 | + |
139 | 157 | corrected_data.name = f"Absorption corrected input_data: {input_pattern.name}"
|
140 | 158 | corrected_data.dump(f"{outfile}", xtype="tth")
|
141 |
| - |
142 | 159 | if args.output_correction:
|
143 | 160 | absorption_correction.dump(f"{corrfile}", xtype="tth")
|
144 | 161 |
|
|
0 commit comments