Ejemplo n.º 1
0
	def __call__(self):
		self.slocator.set_view_interval(self.viewInterval)
		self.slocator.set_data_interval(self.dataInterval)
		(theta1, phi1), (theta2, phi2) = self.axes.getWcsBbox()
		phiInterval = Interval(Value(phi1), Value(phi2))
		#print "theta interval:", theta1, theta2
		self.slocator.set_view_interval(phiInterval)
		self.slocator.set_data_interval(phiInterval)
		phiValues = self.slocator()
		
		yValues  = []
		step = (theta2-theta1)/self.N
		thetaRange = arange(theta1, theta2+step/2., step)
		thetaRangeZipped = zip(thetaRange[:-1], thetaRange[1:])
		#print "theta", thetaRange
		#print "phi", phiValues
		
		wcs = self.axes.wcs
		(x1, y1), (x2, y2) = self.axes.getWorld()
		
		axis_start = kapu.Vector(x1, y1)
		axis_end = kapu.Vector(x1, y2)
		
		#self.locationMap = {}
		for phi in phiValues:
			if phi >= -90 and phi <= 90:
				print "phi =", phi
				for theta1, theta2 in thetaRangeZipped:
					#print "theta:", theta, phi1, phi2
					#if (theta1 <= 90 or theta1 >= -90) and (theta2 <= 90 or theta2 >= -90):
						p1 = wcs.to_pixel(r180(theta1), r90(phi))
						p2 = wcs.to_pixel(r180(theta2), r90(phi))
						if p1 is not None and p2 is not None:
							w1 = kapu.Vector(p1)
							w2 = kapu.Vector(p2)
							p = lineintersection(axis_start, axis_end, w1, w2)
							#print w1.x, w1.y, w2.x, w2.y
							if p:
								print p.y
								#self.locationMap[p.y] = phi
								yValues.append(p.y)
								break # we only want 1 label
		return array(yValues)
Ejemplo n.º 2
0
	def _getXticks(self, world):
		#(wx1, wy1), (wx2, wy2) = self.container.getWorld()
		#world = self.container.getWorld()
		#x1, x2 = self.wcsLocators.xbounds
		#y1, y2 = self.wcsLocators.ybounds
		#world = (x1, y1), (x2, y2)
		matrix = kapu.Matrix.scaleboxInverse(*world)
		self.p1 = (0, 0)
		self.p2 = (1, 0)
		wp1 = matrix * self.p1
		wp2 = matrix * self.p2
		if True:
			(wcsx1, wcsy1), (wcsx2, wcsy2) = self.wcsLocators.getRange()
			print "range:", self.wcsLocators.getRange()
			#print self._getXticks2(wcsx1, wcsx2)
			wcsxlist = self._getXticks2(wcsx1, wcsx2)
			wcsylist_ = self._getXticks2(wcsy1, wcsy2)
			print "xlist:",wcsxlist
			xticks = []
			xvalues = []
			wcs = self.wcsLocators.wcs
			step = (wcsy2-wcsy1)/self.N
			wcsyrange = arange(wcsy1, wcsy2+step/2., step)
			r = lambda x, y: self.wcsLocators.transformation.reverse(x, y)
			for wcsx in wcsxlist:
				for wcsy1, wcsy2 in zip(wcsyrange[:-1], wcsyrange[1:]):
					p1 = wcs.to_pixel(*r(rnd(wcsx), rnd(wcsy1)))
					p2 = wcs.to_pixel(*r(rnd(wcsx), rnd(wcsy2)))
					print p1, p2
					if p1 is not None and p2 is not None:
						w1 = kapu.Vector(p1)
						w2 = kapu.Vector(p2)
						p = self.lineintersection(wp1, wp2, w1, w2)
						if p:
						#if (w1.y < wy1 and w2.y >= wy1) or (w2.y < wy1 and w1.y >= wy1):
							# todo, intersection
							print p.x
							xticks.append(p.x)
							xvalues.append(wcsx)
			
		#print xticks
		return array(xticks), array(xvalues), []
Ejemplo n.º 3
0
	def __call__(self):
		self.slocator.set_view_interval(self.viewInterval)
		self.slocator.set_data_interval(self.dataInterval)
		(theta1, phi1), (theta2, phi2) = self.axes.getWcsBbox()
		thetaInterval = Interval(Value(theta1), Value(theta2))
		#print "theta interval:", theta1, theta2
		self.slocator.set_view_interval(thetaInterval)
		self.slocator.set_data_interval(thetaInterval)
		thetaValues = self.slocator()
		
		xValues  = []
		step = (phi2-phi1)/self.N
		phiRange = arange(phi1, phi2+step/2., step)
		phiRangeZipped = zip(phiRange[:-1], phiRange[1:])
		#print phiRange
		#print thetaValues
		
		wcs = self.axes.wcs
		(x1, y1), (x2, y2) = self.axes.getWorld()
		
		axis_start = kapu.Vector(x1, y1)
		axis_end = kapu.Vector(x2, y1)
		
		self.locationMap = {}
		for theta in thetaValues:
			for phi1, phi2 in phiRangeZipped:
				#print "theta:", theta, phi1, phi2
				p1 = wcs.to_pixel(theta, phi1)
				p2 = wcs.to_pixel(theta, phi2)
				if p1 is not None and p2 is not None:
					w1 = kapu.Vector(p1)
					w2 = kapu.Vector(p2)
					p = lineintersection(axis_start, axis_end, w1, w2)
					#print w1.x, w1.y, w2.x, w2.y
					if p:
						#print p
						self.locationMap[p.x] = theta
						xValues.append(p.x)
		return array(xValues)
Ejemplo n.º 4
0
def rndv(v):
	x, y = v
	return kapu.Vector(rnd(x), rnd(y))