|
1 | 1 | import sys
|
2 | 2 | from argparse import ArgumentParser
|
3 |
| -from pathlib import Path |
4 | 3 |
|
5 | 4 | from diffpy.labpdfproc.functions import apply_corr, compute_cve
|
6 |
| -from diffpy.labpdfproc.tools import known_sources, load_user_metadata, set_output_directory, set_wavelength |
| 5 | +from diffpy.labpdfproc.tools import ( |
| 6 | + known_sources, |
| 7 | + load_user_metadata, |
| 8 | + set_input_lists, |
| 9 | + set_output_directory, |
| 10 | + set_wavelength, |
| 11 | +) |
7 | 12 | from diffpy.utils.parsers.loaddata import loadData
|
8 | 13 | from diffpy.utils.scattering_objects.diffraction_objects import XQUANTITIES, Diffraction_object
|
9 | 14 |
|
@@ -89,45 +94,46 @@ def get_args(override_cli_inputs=None):
|
89 | 94 |
|
90 | 95 | def main():
|
91 | 96 | args = get_args()
|
| 97 | + args = set_input_lists(args) |
92 | 98 | args.output_directory = set_output_directory(args)
|
93 | 99 | args.wavelength = set_wavelength(args)
|
94 | 100 | args = load_user_metadata(args)
|
95 | 101 |
|
96 |
| - filepath = Path(args.input_file) |
97 |
| - outfilestem = filepath.stem + "_corrected" |
98 |
| - corrfilestem = filepath.stem + "_cve" |
99 |
| - outfile = args.output_directory / (outfilestem + ".chi") |
100 |
| - corrfile = args.output_directory / (corrfilestem + ".chi") |
| 102 | + for filepath in args.input_directory: |
| 103 | + outfilestem = filepath.stem + "_corrected" |
| 104 | + corrfilestem = filepath.stem + "_cve" |
| 105 | + outfile = args.output_directory / (outfilestem + ".chi") |
| 106 | + corrfile = args.output_directory / (corrfilestem + ".chi") |
101 | 107 |
|
102 |
| - if outfile.exists() and not args.force_overwrite: |
103 |
| - sys.exit( |
104 |
| - f"Output file {str(outfile)} already exists. Please rerun " |
105 |
| - f"specifying -f if you want to overwrite it." |
106 |
| - ) |
107 |
| - if corrfile.exists() and args.output_correction and not args.force_overwrite: |
108 |
| - sys.exit( |
109 |
| - f"Corrections file {str(corrfile)} was requested and already " |
110 |
| - f"exists. Please rerun specifying -f if you want to overwrite it." |
111 |
| - ) |
| 108 | + if outfile.exists() and not args.force_overwrite: |
| 109 | + sys.exit( |
| 110 | + f"Output file {str(outfile)} already exists. Please rerun " |
| 111 | + f"specifying -f if you want to overwrite it." |
| 112 | + ) |
| 113 | + if corrfile.exists() and args.output_correction and not args.force_overwrite: |
| 114 | + sys.exit( |
| 115 | + f"Corrections file {str(corrfile)} was requested and already " |
| 116 | + f"exists. Please rerun specifying -f if you want to overwrite it." |
| 117 | + ) |
112 | 118 |
|
113 |
| - input_pattern = Diffraction_object(wavelength=args.wavelength) |
114 |
| - xarray, yarray = loadData(args.input_file, unpack=True) |
115 |
| - input_pattern.insert_scattering_quantity( |
116 |
| - xarray, |
117 |
| - yarray, |
118 |
| - "tth", |
119 |
| - scat_quantity="x-ray", |
120 |
| - name=str(args.input_file), |
121 |
| - metadata={"muD": args.mud, "anode_type": args.anode_type}, |
122 |
| - ) |
| 119 | + input_pattern = Diffraction_object(wavelength=args.wavelength) |
| 120 | + xarray, yarray = loadData(args.input_file, unpack=True) |
| 121 | + input_pattern.insert_scattering_quantity( |
| 122 | + xarray, |
| 123 | + yarray, |
| 124 | + "tth", |
| 125 | + scat_quantity="x-ray", |
| 126 | + name=str(args.input_file), |
| 127 | + metadata={"muD": args.mud, "anode_type": args.anode_type}, |
| 128 | + ) |
123 | 129 |
|
124 |
| - absorption_correction = compute_cve(input_pattern, args.mud, args.wavelength) |
125 |
| - corrected_data = apply_corr(input_pattern, absorption_correction) |
126 |
| - corrected_data.name = f"Absorption corrected input_data: {input_pattern.name}" |
127 |
| - corrected_data.dump(f"{outfile}", xtype="tth") |
| 130 | + absorption_correction = compute_cve(input_pattern, args.mud, args.wavelength) |
| 131 | + corrected_data = apply_corr(input_pattern, absorption_correction) |
| 132 | + corrected_data.name = f"Absorption corrected input_data: {input_pattern.name}" |
| 133 | + corrected_data.dump(f"{outfile}", xtype="tth") |
128 | 134 |
|
129 |
| - if args.output_correction: |
130 |
| - absorption_correction.dump(f"{corrfile}", xtype="tth") |
| 135 | + if args.output_correction: |
| 136 | + absorption_correction.dump(f"{corrfile}", xtype="tth") |
131 | 137 |
|
132 | 138 |
|
133 | 139 | if __name__ == "__main__":
|
|
0 commit comments