3
3
from pathlib import Path
4
4
5
5
from diffpy .labpdfproc .functions import apply_corr , compute_cve
6
- from diffpy .labpdfproc .tools import known_sources , load_user_metadata , set_wavelength
6
+ from diffpy .labpdfproc .tools import known_sources , load_user_metadata , set_output_directory , set_wavelength
7
7
from diffpy .utils .parsers .loaddata import loadData
8
8
from diffpy .utils .scattering_objects .diffraction_objects import XQUANTITIES , Diffraction_object
9
9
10
10
11
11
def get_args ():
12
12
p = ArgumentParser ()
13
13
p .add_argument ("mud" , help = "Value of mu*D for your " "sample. Required." , type = float )
14
- p .add_argument ("-i" , "--input-file" , help = "The filename of the " "datafile to load" )
14
+ p .add_argument ("-i" , "--input-file" , help = "The filename of the " "datafile to load. " )
15
15
p .add_argument (
16
16
"-a" ,
17
17
"--anode-type" ,
18
18
help = f"The type of the x-ray source. Allowed values are "
19
- f"{* [known_sources ], }. Either specify a known x - ray source or specify wavelength ",
19
+ f"{* [known_sources ], }. Either specify a known x - ray source or specify wavelength . ",
20
20
default = "Mo" ,
21
21
)
22
22
p .add_argument (
23
23
"-w" ,
24
24
"--wavelength" ,
25
25
help = "X-ray source wavelength in angstroms. Not needed if the anode-type "
26
- "is specified. This wavelength will override the anode wavelength if both are specified" ,
26
+ "is specified. This wavelength will override the anode wavelength if both are specified. " ,
27
27
default = None ,
28
28
type = float ,
29
29
)
30
30
p .add_argument (
31
31
"-o" ,
32
32
"--output-directory" ,
33
- help = "the name of the output directory. If it doesn't exist it "
34
- "will be created. Not currently implemented" ,
33
+ help = "The name of the output directory. If not specified "
34
+ "then corrected files will be written to the current directory."
35
+ "If the specified directory doesn't exist it will be created." ,
35
36
default = None ,
36
37
)
37
38
p .add_argument (
38
39
"-x" ,
39
40
"--xtype" ,
40
- help = f"the quantity on the independent variable axis. allowed "
41
+ help = f"The quantity on the independent variable axis. Allowed "
41
42
f"values: { * XQUANTITIES , } . If not specified then two-theta "
42
43
f"is assumed for the independent variable. Only implemented for "
43
- f"tth currently" ,
44
+ f"tth currently. " ,
44
45
default = "tth" ,
45
46
)
46
47
p .add_argument (
47
48
"-c" ,
48
49
"--output-correction" ,
49
50
action = "store_true" ,
50
- help = "the absorption correction will be output to a file if this "
51
- "flag is set. Default is that it is not output" ,
51
+ help = "The absorption correction will be output to a file if this "
52
+ "flag is set. Default is that it is not output. " ,
52
53
default = "tth" ,
53
54
)
54
55
p .add_argument (
55
56
"-f" ,
56
57
"--force-overwrite" ,
57
58
action = "store_true" ,
58
- help = "outputs will not overwrite existing file unless --force is specified" ,
59
+ help = "Outputs will not overwrite existing file unless --force is specified. " ,
59
60
)
60
61
p .add_argument (
61
62
"-u" ,
@@ -73,23 +74,24 @@ def get_args():
73
74
def main ():
74
75
args = get_args ()
75
76
args = load_user_metadata (args )
77
+ args .output_directory = set_output_directory (args )
76
78
args .wavelength = set_wavelength (args )
77
79
78
80
filepath = Path (args .input_file )
79
81
outfilestem = filepath .stem + "_corrected"
80
82
corrfilestem = filepath .stem + "_cve"
81
- outfile = Path (outfilestem + ".chi" )
82
- corrfile = Path (corrfilestem + ".chi" )
83
+ outfile = args . output_directory / (outfilestem + ".chi" )
84
+ corrfile = args . output_directory / (corrfilestem + ".chi" )
83
85
84
86
if outfile .exists () and not args .force_overwrite :
85
87
sys .exit (
86
- f"output file { str (outfile )} already exists. Please rerun "
87
- f"specifying -f if you want to overwrite it"
88
+ f"Output file { str (outfile )} already exists. Please rerun "
89
+ f"specifying -f if you want to overwrite it. "
88
90
)
89
91
if corrfile .exists () and args .output_correction and not args .force_overwrite :
90
92
sys .exit (
91
- f"corrections file { str (corrfile )} was requested and already "
92
- f"exists. Please rerun specifying -f if you want to overwrite it"
93
+ f"Corrections file { str (corrfile )} was requested and already "
94
+ f"exists. Please rerun specifying -f if you want to overwrite it. "
93
95
)
94
96
95
97
input_pattern = Diffraction_object (wavelength = args .wavelength )
0 commit comments