diffpy.pdfmorph.morphs package

Definition of morphs.

Submodules

diffpy.pdfmorph.morphs.morphishape module

class MorphISphere – apply inverse spherical shape function class MorphISpheroid – apply inverse spheroidal shape function

class diffpy.pdfmorph.morphs.morphishape.MorphISphere(config=None)[source]

Bases: Morph

Apply inverse spherical characteristic function to the morph

Configuration Variables

iradius

The radius of the sphere.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply a scale factor.

parnames = ['iradius']
summary = 'Apply inverse spherical characteristic function to morph'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'
class diffpy.pdfmorph.morphs.morphishape.MorphISpheroid(config=None)[source]

Bases: Morph

Apply inverse spherical characteristic function to the morph

Configuration Variables

iradius

The equatorial radius of the spheroid.

ipradius

The polar radius of the spheroid.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply a scale factor.

parnames = ['iradius', 'ipradius']
summary = 'Apply inverse spheroidal characteristic function to morph'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'

diffpy.pdfmorph.morphs.morphchain module

MorphChain – Chain of morphs executed in order.

class diffpy.pdfmorph.morphs.morphchain.MorphChain(config, *args)[source]

Bases: list

Class for chaining morphs together.

This class is a queue of morphs that get executed in order via the ‘morph’ method. This class derives from the built-in list, and list methods are used to modify the queue.

This derives from list and relies on its methods where possible.

Instance Attributes

config: dict

All configuration variables.

Properties

x_morph_in

Last morph input x data.

y_morph_in

Last morph input y data.

x_morph_out

Last morph result x data.

y_morph_out

Last morph result y data.

x_target_in

Last target input x data.

y_target_in

Last target input y data.

x_target_out

Last target result x data.

y_target_out

Last target result y data.

xy_morph_in

Tuple of (x_morph_in, y_morph_in) from first morph.

xy_morph_out

Tuple of (x_morph_out, y_morph_out) from last morph.

xy_target_in

Tuple of (x_target_in, y_target_in) from first morph.

xy_target_out

Tuple of (x_target_out, y_target_out) from last morph.

xyallout

Tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out) from last morph.

parnames

Names of parameters collected from morphs (Read only).

Notes

The properties return tuples of None if there are no morphs.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply the chain of morphs to the input data.

Parameters:
  • x_morph – Morphed arrays.

  • y_morph – Morphed arrays.

  • x_target – Target arrays.

  • y_target – Target arrays.

Returns:

A tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out).

Return type:

tuple

Notes

Config may be altered by the morphs.

property parnames
property x_morph_in
property x_morph_out
property x_target_in
property x_target_out
property xy_morph_in
property xy_morph_out
property xy_target_in
property xy_target_out
property xyallout
property y_morph_in
property y_morph_out
property y_target_in
property y_target_out

diffpy.pdfmorph.morphs.morphresolution module

class MorphResolutionDamping – apply resolution broadening to the morph

class diffpy.pdfmorph.morphs.morphresolution.MorphResolutionDamping(config=None)[source]

Bases: Morph

Apply resolution damping and broadening to the morph.

Configuration Variables

qdamp

Peak dampening term.

Notes

See the PDFgui manual for how this is used.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply a resolution damping.

parnames = ['qdamp']
summary = 'Apply resolution damping to the morph'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'R (1/A)'
youtlabel = 'R (1/A)'

diffpy.pdfmorph.morphs.morphshape module

class MorphSphere – apply a spherical shape function to the morph class MorphSpheroid – apply a spheroidal shape function to the morph

class diffpy.pdfmorph.morphs.morphshape.MorphSphere(config=None)[source]

Bases: Morph

Apply a spherical characteristic function to the morph

Configuration Variables

radius

The radius of the sphere.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply a scale factor.

parnames = ['radius']
summary = 'Apply spherical characteristic function to morph'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'
class diffpy.pdfmorph.morphs.morphshape.MorphSpheroid(config=None)[source]

Bases: Morph

Apply a spherical characteristic function to the morph

Configuration Variables

radius

The equatorial radius of the spheroid.

pradius

The polar radius of the spheroid.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply a scale factor.

parnames = ['radius', 'pradius']
summary = 'Apply spheroidal characteristic function to morph'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'

diffpy.pdfmorph.morphs.morphshift module

class MorphShift – shift the morph

class diffpy.pdfmorph.morphs.morphshift.MorphShift(config=None)[source]

Bases: Morph

Shift the morph.

Configuration Variables

vshift

The vertical shift to apply to the morph.

hshift

The horizontal shift to apply to the morph.

Note that a horizontal shift may cause edge effects, since the morph does not know what lies beyond the edge of the signals.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply the shifts.

parnames = ['hshift', 'vshift']
summary = 'Shift morph by specified amount'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'

diffpy.pdfmorph.morphs.morph module

Morph – base class for defining a morph.

class diffpy.pdfmorph.morphs.morph.Morph(config=None)[source]

Bases: object

Base class for implementing a morph given a target.

Adapted from diffpy.pdfgetx to include two sets of arrays that get passed through.

Attributes are taken from config when not found locally. The morph may modify the config dictionary. This is the means by which to communicate automatically modified attributes.

Class Attributes

summary

Short description of a morph.

xinlabel

Descriptive label for the x input array.

yinlabel

Descriptive label for the y input array.

xoutlabel

Descriptive label for the x output array.

youtlabel

Descriptive label for the y output array.

parnames: list

Names of configuration variables.

Instance Attributes

config: dict

All configuration variables.

x_morph_in

Last morph input x data.

y_morph_in

Last morph input y data.

x_morph_out

Last morph result x data.

y_morph_out

Last morph result y data.

x_target_in

Last target input x data.

y_target_in

Last target input y data.

x_target_out

Last target result x data.

y_target_out

Last target result y data.

Properties

xy_morph_in

Tuple of (x_morph_in, y_morph_in).

xy_morph_out

Tuple of (x_morph_out, y_morph_out).

xy_target_in

Tuple of (x_target_in, y_target_in).

xy_target_out

Tuple of (x_target_out, y_target_out).

xyallout

Tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out).

applyConfig(config)[source]

Process any configuration data from a dictionary.

Parameters:

config (dict) – Configuration dictionary.

Return type:

No return value.

checkConfig()[source]

Verify data in self.config. No action by default.

To be overridden in a derived class.

morph(x_morph, y_morph, x_target, y_target)[source]

Morph arrays morphed or target.

Identity operation. This method should be overloaded in a derived class.

Parameters:
  • x_morph – Morphed arrays.

  • y_morph – Morphed arrays.

  • x_target – Target arrays.

  • y_target – Target arrays.

Returns:

A tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out)

Return type:

tuple

parnames = []
plotInputs(xylabels=True)[source]

Plot input arrays using matplotlib.pyplot

Parameters:

xylabels – Flag for updating x and y axes labels.

Returns:

A list of matplotlib line objects.

Return type:

list

plotOutputs(xylabels=True, **plotargs)[source]

Plot output arrays using matplotlib.pyplot

Parameters:
  • xylabels (bool) – Flag for updating x and y axes labels.

  • plotargs – Arguments passed to the pylab plot function. Note that “label” will be ignored.

Returns:

A list of matplotlib line objects.

Return type:

list

summary = 'identity transformation'
xinlabel = 'x'
xoutlabel = 'x'
property xy_morph_in

Return a tuple of morph input arrays

property xy_morph_out

Return a tuple of morph output arrays

property xy_target_in

Return a tuple of target input arrays

property xy_target_out

Return a tuple of target output arrays

property xyallout

Return a tuple of all output arrays

yinlabel = 'y'
youtlabel = 'y'

diffpy.pdfmorph.morphs.morphrgrid module

class MorphRGrid – put morph and target on desired grid.

class diffpy.pdfmorph.morphs.morphrgrid.MorphRGrid(config=None)[source]

Bases: Morph

Resample to specified r-grid.

This resamples both the morph and target arrays to be on the specified grid.

Configuration Variables

rmin

The lower-bound on the r-range.

rmax

The upper-bound on the r-range (exclusive within tolerance of 1e-8).

rstep

The r-spacing.

Notes

If any of these is not defined or outside the bounds of the input arrays, then it will be taken to be the most inclusive value from the input arrays. These modified values will be stored as the above attributes.

morph(x_morph, y_morph, x_target, y_target)[source]

Resample arrays onto specified grid.

parnames = ['rmin', 'rmax', 'rstep']
summary = 'Interplolate data onto specified grid'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'

diffpy.pdfmorph.morphs.morphsmear module

class MorphSmear – smear the morph.

class diffpy.pdfmorph.morphs.morphsmear.MorphSmear(config=None)[source]

Bases: Morph

Smear the morph function.

This smears (broadens) the peaks of the morph. Note that this operates on the RDF. Inputs are not automatically converted to the RDF.

Configuration Variables

smear

The smear factor to apply to y_morph_in.

morph(x_morph, y_morph, x_target, y_target)[source]

Resample arrays onto specified grid.

parnames = ['smear']
summary = 'Smear morph by desired amount'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'R (1/A)'
youtlabel = 'R (1/A)'

diffpy.pdfmorph.morphs.morphstretch module

class MorphStretch – stretch the morph.

class diffpy.pdfmorph.morphs.morphstretch.MorphStretch(config=None)[source]

Bases: Morph

Smear the morph function.

This stretches (broadens) the morph.

Configuration Variables

stretch

The stretch factor to apply to y_morph_in. This is applied such that a feature at r is moved to r * (1 + stretch).

morph(x_morph, y_morph, x_target, y_target)[source]

Resample arrays onto specified grid.

parnames = ['stretch']
summary = 'Stretch morph by desired amount'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'

diffpy.pdfmorph.morphs.morphscale module

class MorphScale – scale the morph data

class diffpy.pdfmorph.morphs.morphscale.MorphScale(config=None)[source]

Bases: Morph

Scale the morph.

This scales the morph.

Configuration Variables

scale

The scale to apply to y_target_in.

rtype:

No return.

morph(x_morph, y_morph, x_target, y_target)[source]

Apply a scale factor.

parnames = ['scale']
summary = 'Scale morph by specified amount'
xinlabel = 'r (A)'
xoutlabel = 'r (A)'
yinlabel = 'G (1/A^2)'
youtlabel = 'G (1/A^2)'