本文整理汇总了Python中Transform.getQChi方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.getQChi方法的具体用法?Python Transform.getQChi怎么用?Python Transform.getQChi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.getQChi方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addPeaksCakeImage
# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import getQChi [as 别名]
def addPeaksCakeImage(image,qLower,qUpper,numQ,chiLower,chiUpper,
numChi,peakList,calibrationData,color,
smallestRangeQLower,smallestRangeQUpper,smallestRangeChiLower,smallestRangeChiUpper):
draw = ImageDraw.Draw(image)
unZoomWidth = 2.5
# scale the length of the xs. For example, zoomed in to 50% means will
# cause the xs to be drawn with double the length.
numTimesZoomInQ = abs((smallestRangeQUpper-smallestRangeQLower)/ \
(qUpper-qLower))
numTimesZoomInChi = abs((smallestRangeChiUpper-smallestRangeChiLower)/ \
(chiUpper-chiLower))
scalingFactor = min(numTimesZoomInQ,numTimesZoomInChi)
halflength = unZoomWidth*scalingFactor
for x,y,qReal,qFit,chi,width in peakList:
# for each peak, we want to take the true x,y value of
# where the peak is on the image and figure out where
# it belongs on the cake data.
qTemp,chiTemp = Transform.getQChi(calibrationData,x,y)
# if our chi range begins in the negative, we might have to place
# our chi values in their 360 degree rotated values. Note that
# getQChi always returns chi between 0 and 360
if (chiTemp-360) > chiLower and \
(chiTemp-360) < chiUpper:
chiTemp -= 360
cakeX = (numQ-1)*(qTemp-qLower)/(qUpper-qLower)
cakeY = (numChi-1)*(chiTemp-chiLower)/(chiUpper-chiLower)
# add in new lines if they would be visible
if cakeX >= 0 and cakeX < numQ and \
cakeY >= 0 and cakeY < numChi:
draw.line( (cakeX-halflength,cakeY-halflength) +
(cakeX+halflength,cakeY+halflength),fill=color)
draw.line( (cakeX+halflength,cakeY-halflength) +
(cakeX-halflength,cakeY+halflength),fill=color)
示例2: getSmallestRange
# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import getQChi [as 别名]
def getSmallestRange(self,calibrationData):
""" Get Smallest Range picks the smallest
range in the image which contains
the whole diffraction image.
If the center of the beam is inside the
diffraction data, we know that there will
be some of all chi so chi should very
from -180 to 180. Furthermore, we
know that Q will vary from 0 to its max
which will be on a corner. So
in that case, we can just look in the
corners to find the largets Q value.
If the center of the image is ouside the
diffraction data, that all we know is
that the extremum will be somewhere on
the edge of the image. In that case, we
have to loop through the entire border
to find the extremum
"""
# check if it has already been calculated
if self.lastCalibrationDataGetSmallsetRange != None:
if calibrationData == self.lastCalibrationDataGetSmallsetRange:
return self.lastRangeGetSmallestRange
else:
self.lastCalibrationDataGetSmallsetRange = None
self.lastRangeGetSmallestRange = None
# store value in case it changes.
self.lastCalibrationDataGetSmallsetRange = copy.deepcopy(calibrationData)
if calibrationData.getCenterX()['val'] < 0 or \
calibrationData.getCenterX()['val'] > self.theDiffractionData.size-1 or \
calibrationData.getCenterY()['val'] < 0 or \
calibrationData.getCenterY()['val'] > self.theDiffractionData.size-1:
qLower = None
qUpper = None
chiLower = None
chiUpper = None
for temp in range(self.theDiffractionData.size):
# go around each edge of the image, finding the most extreme q and chi values
q0,chi0 = Transform.getQChi(calibrationData,0,temp)
q1,chi1 = Transform.getQChi(calibrationData,self.theDiffractionData.size-1,temp)
q2,chi2 = Transform.getQChi(calibrationData,temp,0)
q3,chi3 = Transform.getQChi(calibrationData,temp,self.theDiffractionData.size-1)
lowerQ = min(q0,q1,q2,q3)
higherQ = max(q0,q1,q2,q3)
if qLower==None or lowerQ < qLower: qLower = lowerQ
if qUpper==None or higherQ > qUpper: qUpper = higherQ
if chi0 > 180: chi0 -=360
if chi1 > 180: chi1 -=360
if chi2 > 180: chi2 -=360
if chi3 > 180: chi3 -=360
lowerChi = min(chi0,chi1,chi2,chi3)
higherChi = max(chi0,chi1,chi2,chi3)
if chiLower==None or lowerChi < chiLower: chiLower = lowerChi
if chiUpper==None or higherChi > chiUpper: chiUpper = higherChi
tempRange = {'qLower':qLower,'qUpper':qUpper,'chiLower':chiLower,'chiUpper':chiUpper}
self.lastRangeGetSmallestRange = tempRange
return tempRange
else:
q0,chi0 = Transform.getQChi(calibrationData,0,0)
q1,chi1 = Transform.getQChi(calibrationData,0,self.theDiffractionData.size-1)
q2,chi2 = Transform.getQChi(calibrationData,self.theDiffractionData.size-1,0)
q3,chi3 = Transform.getQChi(calibrationData,self.theDiffractionData.size-1,
self.theDiffractionData.size-1)
qUpper = max(q0,q1,q2,q3)
qUpper = float(str(qUpper)[:8])
tempRange = {'qLower':0,'qUpper':qUpper,'chiLower':-180,'chiUpper':180}
self.lastRangeGetSmallestRange = tempRange
return tempRange