def calculate_segments(self, nbins): points = np.zeros((nbins+1, 2)) points[:, 1] = np.linspace(-self.width / 2., self.width / 2., nbins+1) rot = math2d.angle_matrix(self.angle) points = np.dot(points, rot) points[:, 0] += self.center[0] points[:, 1] += self.center[1] return math2d.create_segments_from_points(points)
def radon_transform(self, angles=[0]): if type(self.detector) is not DetectorPlane: raise TypeError('self.detector is not DetectorPlane') detector_centers = (self.detector.segments[:, 0, :] + self.detector.segments[:, 1, :]) / 2. radon = np.zeros((np.size(detector_centers, 0), len(angles))) source_bins = np.inner(detector_centers, math2d.angle_matrix(180.))[::-1] for i, angle in enumerate(angles): print i, len(angles) rot = math2d.angle_matrix(angle) rot_source = np.inner(source_bins, rot) rot_detector = np.inner(detector_centers, rot) for j in xrange(len(rot_detector)): radon[j, i] = self.attenuation_length(rot_source[j], rot_detector[j]) return radon
def calculate_segments(self, nbins): points = np.zeros((nbins + 1, 2)) points[:, 1] = np.linspace(-self.width / 2., self.width / 2., nbins + 1) rot = math2d.angle_matrix(self.angle) points = np.dot(points, rot) points[:, 0] += self.center[0] points[:, 1] += self.center[1] return math2d.create_segments_from_points(points)