forked from Luiskitsu/diffpy.morph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorphshift.py
More file actions
66 lines (52 loc) · 1.77 KB
/
morphshift.py
File metadata and controls
66 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
##############################################################################
#
# diffpy.morph by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2010 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Chris Farrow
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
#
##############################################################################
"""class MorphShift -- shift the morph
"""
import numpy
from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, Morph
class MorphShift(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.
"""
# Define input output types
summary = "Shift morph by specified amount"
xinlabel = LABEL_RA
yinlabel = LABEL_GR
xoutlabel = LABEL_RA
youtlabel = LABEL_GR
parnames = ["hshift", "vshift"]
def morph(self, x_morph, y_morph, x_target, y_target):
"""Apply the shifts."""
try:
hshift = self.hshift
except AttributeError:
hshift = 0
try:
vshift = self.vshift
except AttributeError:
vshift = 0
Morph.morph(self, x_morph, y_morph, x_target, y_target)
r = self.x_morph_in - hshift
self.y_morph_out = numpy.interp(r, self.x_morph_in, self.y_morph_in)
self.y_morph_out += vshift
return self.xyallout
# End of class MorphShift