Skip to content

Commit 215c5e5

Browse files
committed
Refactor smear to smear-pdf
1 parent 87f1bff commit 215c5e5

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/diffpy/morph/morphapp.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,25 @@ def custom_error(self, msg):
167167
"--smear",
168168
type="float",
169169
metavar="SMEAR",
170-
help="Smear peaks with a Gaussian of width SMEAR.",
170+
help="""Smear the peaks with a Guassian of width SMEAR.
171+
This is done by convolving the function with a Gaussian with standard
172+
deviation SMEAR. If both --smear and --smear-pdf are enabled, only
173+
--smear-pdf will be applied.""",
174+
)
175+
group.add_option(
176+
"--smear-pdf",
177+
type="float",
178+
metavar="SMEAR",
179+
help="""Convert PDF to RDF. Then, smear peaks with a Gaussian of
180+
width SMEAR. Convert back to PDF. If both --smear and --smear-pdf are
181+
enabled, only --smear-pdf will be applied.""",
171182
)
172183
group.add_option(
173184
"--slope",
174185
type="float",
175186
dest="baselineslope",
176-
help="""Slope of the baseline. This is used when applying the smear
177-
factor. It will be estimated if not provided.""",
187+
help="""Slope of the baseline. This is used with the option --smear-pdf
188+
to convert from the PDF to RDF. It will be estimated if not provided.""",
178189
)
179190
group.add_option(
180191
"--hshift",
@@ -468,8 +479,8 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
468479
config["vshift"] = vshift_in
469480
refpars.append("vshift")
470481
# Smear
471-
if opts.smear is not None:
472-
smear_in = opts.smear
482+
if opts.smear_pdf is not None:
483+
smear_in = opts.smear_pdf
473484
chain.append(helpers.TransformXtalPDFtoRDF())
474485
chain.append(morphs.MorphSmear())
475486
chain.append(helpers.TransformXtalRDFtoPDF())
@@ -480,6 +491,11 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
480491
if opts.baselineslope is None:
481492
config["baselineslope"] = -0.5
482493
refpars.append("baselineslope")
494+
elif opts.smear is not None:
495+
smear_in = opts.smear
496+
chain.append(morphs.MorphSmear())
497+
refpars.append("smear")
498+
config["smear"] = smear_in
483499
# Size
484500
radii = [opts.radius, opts.pradius]
485501
nrad = 2 - radii.count(None)
@@ -742,7 +758,7 @@ def multiple_targets(parser, opts, pargs, stdout_flag=True):
742758
morph_inputs = {
743759
"scale": opts.scale,
744760
"stretch": opts.stretch,
745-
"smear": opts.smear,
761+
"smear": opts.smear_pdf,
746762
}
747763
morph_inputs.update({"hshift": opts.hshift, "vshift": opts.vshift})
748764

@@ -925,7 +941,7 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True):
925941
morph_inputs = {
926942
"scale": opts.scale,
927943
"stretch": opts.stretch,
928-
"smear": opts.smear,
944+
"smear": opts.smear_pdf,
929945
}
930946
morph_inputs.update({"hshift": opts.hshift, "vshift": opts.vshift})
931947

0 commit comments

Comments
 (0)