Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Refactor smear to smear-pdf
  • Loading branch information
Sparks29032 committed Jun 23, 2025
commit 215c5e51ac2dddefa1139342f6423721c5a4bc00
30 changes: 23 additions & 7 deletions src/diffpy/morph/morphapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,25 @@ def custom_error(self, msg):
"--smear",
type="float",
metavar="SMEAR",
help="Smear peaks with a Gaussian of width SMEAR.",
help="""Smear the peaks with a Guassian of width SMEAR.
This is done by convolving the function with a Gaussian with standard
deviation SMEAR. If both --smear and --smear-pdf are enabled, only
--smear-pdf will be applied.""",
)
group.add_option(
"--smear-pdf",
type="float",
metavar="SMEAR",
help="""Convert PDF to RDF. Then, smear peaks with a Gaussian of
width SMEAR. Convert back to PDF. If both --smear and --smear-pdf are
enabled, only --smear-pdf will be applied.""",
)
group.add_option(
"--slope",
type="float",
dest="baselineslope",
help="""Slope of the baseline. This is used when applying the smear
factor. It will be estimated if not provided.""",
help="""Slope of the baseline. This is used with the option --smear-pdf
to convert from the PDF to RDF. It will be estimated if not provided.""",
)
group.add_option(
"--hshift",
Expand Down Expand Up @@ -468,8 +479,8 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
config["vshift"] = vshift_in
refpars.append("vshift")
# Smear
if opts.smear is not None:
smear_in = opts.smear
if opts.smear_pdf is not None:
smear_in = opts.smear_pdf
chain.append(helpers.TransformXtalPDFtoRDF())
chain.append(morphs.MorphSmear())
chain.append(helpers.TransformXtalRDFtoPDF())
Expand All @@ -480,6 +491,11 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
if opts.baselineslope is None:
config["baselineslope"] = -0.5
refpars.append("baselineslope")
elif opts.smear is not None:
smear_in = opts.smear
chain.append(morphs.MorphSmear())
refpars.append("smear")
config["smear"] = smear_in
# Size
radii = [opts.radius, opts.pradius]
nrad = 2 - radii.count(None)
Expand Down Expand Up @@ -742,7 +758,7 @@ def multiple_targets(parser, opts, pargs, stdout_flag=True):
morph_inputs = {
"scale": opts.scale,
"stretch": opts.stretch,
"smear": opts.smear,
"smear": opts.smear_pdf,
}
morph_inputs.update({"hshift": opts.hshift, "vshift": opts.vshift})

Expand Down Expand Up @@ -925,7 +941,7 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True):
morph_inputs = {
"scale": opts.scale,
"stretch": opts.stretch,
"smear": opts.smear,
"smear": opts.smear_pdf,
}
morph_inputs.update({"hshift": opts.hshift, "vshift": opts.vshift})

Expand Down