Skip to content

add fast_cve to labpdfprocapp.py and some other fixes #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ template = "{tag}"
dev_template = "{tag}"
dirty_template = "{tag}"

[project.scripts]
labpdfproc = "diffpy.labpdfproc.labpdfprocapp:main"

[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
include = ["*"] # package names should match these glob patterns (["*"] by default)
Expand Down
24 changes: 20 additions & 4 deletions src/diffpy/labpdfproc/labpdfprocapp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from argparse import ArgumentParser

from diffpy.labpdfproc.fast_cve import apply_fast_corr, fast_compute_cve
from diffpy.labpdfproc.functions import apply_corr, compute_cve
from diffpy.labpdfproc.tools import known_sources, load_metadata, preprocessing_args
from diffpy.utils.parsers.loaddata import loadData
Expand Down Expand Up @@ -64,14 +65,20 @@ def get_args(override_cli_inputs=None):
action="store_true",
help="The absorption correction will be output to a file if this "
"flag is set. Default is that it is not output.",
default="tth",
)
p.add_argument(
"-f",
"--force-overwrite",
action="store_true",
help="Outputs will not overwrite existing file unless --force is specified.",
)
p.add_argument(
"-b",
"--brute-force",
action="store_true",
help="The absorption correction will be computed using brute-force calculation "
"if this flag is set. Default is using fast calculation. ",
)
p.add_argument(
"-u",
"--user-metadata",
Expand Down Expand Up @@ -134,11 +141,20 @@ def main():
metadata=load_metadata(args, filepath),
)

absorption_correction = compute_cve(input_pattern, args.mud, args.wavelength)
corrected_data = apply_corr(input_pattern, absorption_correction)
if args.brute_force:
absorption_correction = compute_cve(input_pattern, args.mud, args.wavelength)
corrected_data = apply_corr(input_pattern, absorption_correction)
else:
if args.mud > 6 or args.mud < 0.5:
sys.exit(
"mu*D is out of the acceptable range (0.5 to 6) for fast calculation. "
"Please rerun with a value within this range or use -b enable brute-force calculation. "
)
absorption_correction = fast_compute_cve(input_pattern, args.mud, args.wavelength)
corrected_data = apply_fast_corr(input_pattern, absorption_correction)

corrected_data.name = f"Absorption corrected input_data: {input_pattern.name}"
corrected_data.dump(f"{outfile}", xtype="tth")

if args.output_correction:
absorption_correction.dump(f"{corrfile}", xtype="tth")

Expand Down
1 change: 1 addition & 0 deletions src/diffpy/labpdfproc/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def test_load_metadata(mocker, user_filesystem):
"wavelength": 0.71,
"output_directory": str(Path.cwd().resolve()),
"xtype": "tth",
"brute_force": False,
"key": "value",
"username": "cli_username",
"email": "[email protected]",
Expand Down
Loading