def makePixelSteps(self, mmin, mmax):
     if not isinstance(mmin, Vector2D):
         mmin = Vector2D(mmin[0], mmin[1])
     if not isinstance(mmax, Vector2D):
         mmax = Vector2D(mmax[0], mmax[1])
     pixelStart = self.magMapParameters.angleToPixel(mmin)
     pixelEnd = self.magMapParameters.angleToPixel(mmax)
     dx = pixelEnd.x - pixelStart.x
     dy = pixelEnd.y - pixelStart.y
     maxD = max(abs(dx), abs(dy))
     xPixels = np.arange(pixelStart.x, pixelEnd.x, dx / maxD)
     yPixels = np.arange(pixelStart.y, pixelEnd.y, dy / maxD)
     ret = np.ndarray((len(xPixels), 2))
     ret[:, 0] = xPixels
     ret[:, 1] = yPixels
     return ret
 def query_data_length(self, x, y, radius):
     xy = Vector2D(x, y, 'rad')
     xy = self.magMapParameters.angleToPixel(xy)
     #         assert radius == self._parameters.queryQuasarRadius, "MagMap cannot query a radius different from that used to generate it."
     x = int(round(xy.x))
     y = int(round(xy.y))
     ret = self.magMapArray[x, y]
     return ret
Ejemplo n.º 3
0
    def vectorFromQString(self, string, unit=None):
        """
        Converts an ordered pair string of the form (x,y) into a Vector2D of x and y.

        """
        x, y = (string.strip('()')).split(',')
        if ' ' in y:
            y = y.split(' ')[0]
        return Vector2D(float(x), float(y), unit)
Ejemplo n.º 4
0
 def getApparentVelocity(self, pos, v):
     ev = EarthVelocity
     apparentV = ev.to_cartesian() - v
     posInSky = pos.galactic
     phi, theta = (posInSky.l.to('rad').value,
                   math.pi / 2 - posInSky.b.to('rad').value)
     vx = apparentV.x * math.cos(theta) * math.cos(
         phi) + apparentV.y * math.cos(theta) * math.sin(
             phi) - apparentV.z * math.sin(theta)
     vy = apparentV.y * math.cos(phi) - apparentV.x * math.sin(phi)
     ret = Vector2D(vx.value, vy.value, 'km/s')
     return ret
Ejemplo n.º 5
0
    def get_center_coords(self, params=None):
        '''Calculates and returns the location of a ray sent out from the center of the screen after 
        projecting onto the Source Plane.'''
        # Pulling parameters out of parameters class
        if not self._center:
            parameters = params or self.parameters
            dS = parameters.quasar.angDiamDist.value
            dLS = parameters.dLS.value
            shearMag = parameters.galaxy.shear.magnitude
            shearAngle = parameters.galaxy.shear.angle.value
            centerX = parameters.galaxy.position.to('rad').x
            centerY = parameters.galaxy.position.to('rad').y
            sis_constant = np.float64(
                4 * math.pi * parameters.galaxy.velocityDispersion**2 *
                (const.c**-2).to('s2/km2').value * dLS / dS)
            pi2 = math.pi / 2
            # Calculation variables
            resx = 0
            resy = 0
            # Calculation is Below
            incident_angle_x = 0.0
            incident_angle_y = 0.0
            try:
                # SIS
                deltaR_x = incident_angle_x - centerX
                deltaR_y = incident_angle_y - centerY
                r = math.sqrt(deltaR_x * deltaR_x + deltaR_y * deltaR_y)
                if r == 0.0:
                    resx += deltaR_x
                    resy += deltaR_y
                else:
                    resx += deltaR_x * sis_constant / r
                    resy += deltaR_y * sis_constant / r

                # Shear
                phi = 2 * (pi2 - shearAngle) - math.atan2(deltaR_y, deltaR_x)
                resx += shearMag * r * math.cos(phi)
                resy += shearMag * r * math.sin(phi)
                resx = deltaR_x - resx
                resy = deltaR_y - resy
            except ZeroDivisionError:
                resx = 0.0
                resy = 0.0
            self._center = Vector2D(resx, resy, 'rad')
        return self._center
Ejemplo n.º 6
0
 def setROI(self, start, end):
     vstart = Vector2D(start[0], start[1])
     vend = Vector2D(end[0], end[1])
     self._modelRef.specify_light_curve(vstart, vend)
     self.signals['set_ROI'].emit(start, end)
Ejemplo n.º 7
0
	def __init__(self,data,query_points):
		self._data = data.flatten()
		start = query_points[0]
		end = query_points[-1]
		self._start = Vector2D(start[0],start[1],'rad')
		self._end = Vector2D(end[0],end[1],'rad')