本文整理汇总了Python中pyaid.number.NumericUtils.NumericUtils.toValueUncertainty方法的典型用法代码示例。如果您正苦于以下问题:Python NumericUtils.toValueUncertainty方法的具体用法?Python NumericUtils.toValueUncertainty怎么用?Python NumericUtils.toValueUncertainty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.number.NumericUtils.NumericUtils
的用法示例。
在下文中一共展示了NumericUtils.toValueUncertainty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __unicode__
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def __unicode__(self):
isPy2 = bool(sys.version < '3')
return '<%s (%s, %s)>' % (
self.__class__.__name__,
NumericUtils.toValueUncertainty(self.x, self.xUnc, asciiLabel=isPy2).label,
NumericUtils.toValueUncertainty(self.y, self.yUnc, asciiLabel=isPy2).label)
示例2: _calculateDeviation
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def _calculateDeviation(
self, track, value, uncertainty, highMeasuredUncertainty, measured,
prefix, label
):
if not measured:
return None
out = dict()
measuredUncertainty = measured*(
0.12 if highMeasuredUncertainty else 0.06)
v = NumericUtils.toValueUncertainty(value, uncertainty)
mv = NumericUtils.toValueUncertainty(measured, measuredUncertainty)
unc = math.sqrt(v.uncertainty**2 + mv.uncertainty**2)
deviation = v.value - mv.value
out['%sDev' % prefix] = deviation/measured
try:
out['%sDelta' % prefix] = abs(deviation)/unc
except ZeroDivisionError:
self.logger.write([
'[ERROR]: Track without %s uncertainty' % label,
'TRACK: %s (%s)' % (track.fingerprint, track.uid) ])
raise
return out
示例3: test_weightedAverage
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def test_weightedAverage(self):
""" doc... """
values = [
NumericUtils.toValueUncertainty(11.0, 1.0),
NumericUtils.toValueUncertainty(12.0, 1.0),
NumericUtils.toValueUncertainty(10.0, 3.0) ]
result = NumericUtils.weightedAverage(*values)
self.assertEqual(result.value, 11.4, 'Value Match')
self.assertEqual(result.uncertainty, 0.7, 'Value Match')
示例4: test_toValueUncertainty
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def test_toValueUncertainty(self):
"""test_toValueUncertainty doc..."""
value = NumericUtils.toValueUncertainty(math.pi, 0.00456)
self.assertEqual(value.value, 3.142, 'Values do not match %s' % value.label)
self.assertEqual(value.uncertainty, 0.005, 'Uncertainties do not match %s' % value.label)
value = NumericUtils.toValueUncertainty(100.0*math.pi, 42.0)
self.assertEqual(value.value, 310.0, 'Values do not match %s' % value.label)
self.assertEqual(value.uncertainty, 40.0, 'Uncertainties do not match %s' % value.label)
value = NumericUtils.toValueUncertainty(0.001*math.pi, 0.000975)
self.assertEqual(value.value, 0.003, 'Values do not match %s' % value.label)
self.assertEqual(value.uncertainty, 0.001, 'Uncertainties do not match %s' % value.label)
示例5: _postAnalyze
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def _postAnalyze(self):
"""_postAnalyze doc..."""
self._csv.save()
meanDiff = NumericUtils.getMeanAndDeviation(self._diffs)
self.logger.write('Rotation %s' % meanDiff.label)
self._paths.append(self._makePlot(
label='Rotation Differences',
data=self._diffs,
histRange=[-180, 180]))
self._paths.append(self._makePlot(
label='Rotation Differences',
data=self._diffs,
histRange=[-180, 180],
isLog=True))
circs = []
circsUnc = []
diffs = []
diffsUnc = []
entries = self.owner.getStage('lengthWidth').entries
for entry in entries:
track = entry['track']
if track.uid not in self.deviations:
# Skip those tracks with no deviation value (solo tracks)
continue
diffDeg = self.deviations[track.uid]
diffs.append(abs(diffDeg.value))
diffsUnc.append(diffDeg.uncertainty)
# Compute the circularity of the track from its aspect ratio. If
# the aspect is less than or equal to 1.0 use the aspect value
# directly. However, if the value is greater than one, take the
# reciprocal so that large and small aspect ratios can be compared
# equally.
aspect = entry['aspect']
if aspect.value > 1.0:
a = 1.0/aspect.raw
aspect = NumericUtils.toValueUncertainty(a, a*(aspect.rawUncertainty/aspect.raw))
circs.append(abs(aspect.value - 1.0))
circsUnc.append(aspect.uncertainty)
pl = self.plot
self.owner.createFigure('circular')
pl.errorbar(x=circs, y=diffs, xerr=circsUnc, yerr=diffsUnc, fmt='.')
pl.xlabel('Aspect Circularity')
pl.ylabel('Rotation Deviation')
pl.title('Rotation Deviation and Aspect Circularity')
self._paths.append(self.owner.saveFigure('circular'))
self.mergePdfs(self._paths)
self._paths = []
示例6: zValue
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def zValue(self):
""" Returns the z value as an uncertainty named tuple in units of meters
"""
r = math.pi/180.0*float(self.rotation)
rUnc = math.pi/180.0*float(self.rotationUncertainty)
wUnc = self.widthUncertainty
lUnc = self.lengthUncertainty
zUnc = lUnc*abs(math.cos(r)) + wUnc*abs(math.sin(r)) \
+ rUnc*abs(wUnc*math.cos(r) - lUnc*math.sin(r))
return NumericUtils.toValueUncertainty(0.01*float(self.z), zUnc)
示例7: slope
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def slope(self):
""" Returns the slope of the line as a ValueUncertainty named tuple. """
s = self.start
e = self.end
deltaX = e.x - s.x
deltaY = e.y - s.y
try:
slope = deltaY/deltaX
unc = abs(1.0/deltaX)*(s.yUnc + e.yUnc) + abs(slope/deltaX)*(s.xUnc + e.xUnc)
return NumericUtils.toValueUncertainty(slope, unc)
except Exception:
return None
示例8: distanceTo
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def distanceTo(self, position):
"""distanceBetween doc..."""
xDelta = self.x - position.x
yDelta = self.y - position.y
distance = math.sqrt(xDelta*xDelta + yDelta*yDelta)
# Use the absolute value because the derivatives in error propagation are always
# absolute values
xDelta = abs(xDelta)
yDelta = abs(yDelta)
try:
error = (xDelta*(self.xUnc + position.xUnc)
+ yDelta*(self.yUnc + position.yUnc) )/distance
except ZeroDivisionError:
error = 1.0
return NumericUtils.toValueUncertainty(distance, error)
示例9: getDensityDistributionTrace
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def getDensityDistributionTrace(data, columnName, errorColumnName, **kwargs):
minVal = (data[columnName] - 3.0*data[errorColumnName]).min()
maxVal = (data[columnName] + 3.0*data[errorColumnName]).max()
values = []
for index, row in data.iterrows():
values.append(NumericUtils.toValueUncertainty(
value=row[columnName],
uncertainty=row[errorColumnName] ))
dd = DensityDistribution(values=values)
xValues = np.linspace(minVal, maxVal, 200)
yValues = dd.createDistribution(xValues)
return plotlyGraph.Scatter(
x=xValues,
y=yValues,
**kwargs), dd
示例10: _analyzeTrack
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def _analyzeTrack(self, track, series, trackway, sitemap):
""" Performs analysis on each track. A dictionary is created to be
added to the entries list. That dictionary contains track,
wDev (the fractional difference in width between that estimated
from the map and that measured in the field), ldev (the
corresponding fractional difference in length), and if either of
those field measurements are missing, the corresponding counter is
incremented.
"""
data = dict(track=track)
result = self._calculateDeviation(
track=track,
value=track.width,
uncertainty=track.widthUncertainty,
measured=track.widthMeasured,
highMeasuredUncertainty=track.hasImportFlag(
ImportFlagsEnum.HIGH_WIDTH_UNCERTAINTY),
prefix='w',
label='Width')
if result:
data.update(result)
result = self._calculateDeviation(
track=track,
value=track.length,
uncertainty=track.lengthUncertainty,
measured=track.lengthMeasured,
highMeasuredUncertainty=track.hasImportFlag(
ImportFlagsEnum.HIGH_LENGTH_UNCERTAINTY),
prefix='l',
label='Length')
if result:
data.update(result)
aspect = track.width/track.length
wErr = track.widthUncertainty/track.width
lErr = track.lengthUncertainty/track.length
aspectUnc = abs(aspect)*math.sqrt(wErr*wErr + lErr*lErr)
value = NumericUtils.toValueUncertainty(aspect, aspectUnc)
data['aspect'] = value
self.entries.append(data)
示例11: _calculateSparseness
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def _calculateSparseness(cls, spacings, reference):
""" Calculates the relative sparseness from the series spacings list and the reference
spacing. """
out = []
for data in spacings:
# For each entry in the tests, normalize that value to the most complete (highest
# track count) series to create a relative sparseness rating
diff = data.value - reference.value
absDiff = abs(diff)
dVal = reference.value
sign = 0.0 if absDiff == 0.0 else diff/absDiff
unc = abs(data.uncertainty/dVal) + abs(dVal*sign - absDiff)/(dVal*dVal)
out.append(NumericUtils.toValueUncertainty(
value=100.0*absDiff/dVal,
uncertainty=100.0*unc))
return ListUtils.sortObjectList(out, 'value')
示例12: _logUnresolvableTrack
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def _logUnresolvableTrack(self, track, sitemap, message):
"""_logUnresolvableTrack doc..."""
measured = NumericUtils.toValueUncertainty(
value=track.snapshotData.get(SnapshotDataEnum.PACE),
uncertainty=self.MEASURED_UNCERTAINTY)
self.ignored += 1
self.logger.write([
'[ERROR]: %s' % message,
'TRACK: %s [%s]' % (track.fingerprint, track.uid),
'PACE[field]: %s' % measured.label ])
self._errorCsv.addRow({
'uid':track.uid,
'fingerprint':track.fingerprint,
'measured':measured.label })
sitemap.cache.get('drawing').circle(
track.positionValue.toMayaTuple(), 10,
stroke='none', fill='red', fill_opacity=0.5)
示例13: _calculateAverageSpacing
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def _calculateAverageSpacing(cls, series):
""" Determines the average spacing of the tracks in the track series for use as a
comparative measure of sparseness to the other track series in the trackway. If the
series is not ready or does not have a sufficient number of tracks, this method will
return None.
:param: series | TrackSeries
The series on which to determine the average spacing.
:return: ValueUncertainty
A value uncertainty instance that represents the average spacing of the series,
or None if it's the calculation is aborted. """
if not series.isReady:
# Skip trackways with invalid series
return None
tracks = series.tracks
if not tracks or len(tracks) < 2:
# Ignore series with less than two tracks
return None
length = 0.0
uncs = []
for i in ListUtils.range(len(tracks) - 1):
line = LineSegment2D(
start=tracks[i].positionValue,
end=tracks[i + 1].positionValue)
spacing = line.length
length += spacing.value
uncs.append(spacing.uncertainty)
unc = NumericUtils.sqrtSumOfSquares(*uncs)
return NumericUtils.toValueUncertainty(
value=length/float(len(tracks)),
uncertainty=unc/float(len(tracks)) )
示例14: distanceToPoint
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def distanceToPoint(self, point):
""" Calculates the smallest distance between the specified point and this line segment
using the standard formulation as described in:
http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line#Line_defined_by_two_points """
length = self.length
if not length:
raise ValueError('Cannot calculate point distance. Invalid line segment.')
s = self.start
e = self.end
deltaX = e.x - s.x
deltaY = e.y - s.y
if deltaX == 0.0:
# Vertical Line
distance = abs(s.x - point.x)
elif deltaY == 0.0:
# Horizontal line
distance = abs(s.y - point.y)
else:
distance = abs(deltaY*point.x - deltaX*point.y - s.x*e.y + e.x*s.y)/length.raw
B = deltaY*point.x - deltaX*point.y - s.x*e.y + e.x*s.y
AbsB = abs(B)
D = math.sqrt(deltaX*deltaX + deltaY*deltaY)
DPrime = 1.0/math.pow(deltaX*deltaX + deltaY*deltaY, 3.0/2.0)
bBD = B/(AbsB*D)
pointXErr = point.xUnc*abs(deltaY*B/(AbsB*D))
pointYErr = point.yUnc*abs(deltaX*B/(AbsB*D))
startXErr = s.xUnc*abs(AbsB*DPrime + bBD*(point.y - e.y))
startYErr = s.yUnc*abs(AbsB*DPrime + bBD*(e.x - point.x))
endXErr = e.xUnc*abs(bBD*(s.y - point.y) - AbsB*DPrime)
endYErr = e.yUnc*abs(bBD*(point.x - s.x) - AbsB*DPrime)
error = pointXErr + pointYErr + startXErr + startYErr + endXErr + endYErr
return NumericUtils.toValueUncertainty(distance, error)
示例15: lengthValue
# 需要导入模块: from pyaid.number.NumericUtils import NumericUtils [as 别名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import toValueUncertainty [as 别名]
def lengthValue(self):
return NumericUtils.toValueUncertainty(
self.length, self.lengthUncertainty)