Ejemplo n.º 1
0
    def _validateRaDec(self, position):

        site = self.getManager().getProxy("/Site/0")
        lst = site.LST()
        latitude = site["latitude"]

        altAz = Position.raDecToAltAz(position, latitude, lst)

        return self._validateAltAz(altAz)
Ejemplo n.º 2
0
    def _validateRaDec(self, position):

        site = self.getManager().getProxy("/Site/0")
        lst = site.LST()
        latitude = site["latitude"]

        altAz = Position.raDecToAltAz(position,
                                      latitude,
                                      lst)

        return self._validateAltAz(altAz)
Ejemplo n.º 3
0
	def computeExtinctionWithLST(self,flux, lstArr):
		altArr = []
		aTuple = self.ra, self.dec
		raDec = Position(aTuple)
		for lst in lstArr:
			#this returns the altitude and azimuth
			altAz = raDec.raDecToAltAz(raDec, self.latitude, lst)
			#Get the altitude
			altArr.append(altAz.alt)
		print flux
		print altArr
		return self.computeExtinctionCoefficient(flux, altArr)
Ejemplo n.º 4
0
 def test_altAzRaDec(self):
     
     altAz = Position.fromAltAz('20:30:40', '222:11:00')
     lat = Coord.fromD(0)
     o = ephem.Observer()
     o.lat = '0:0:0'
     o.long = '0:0:0'
     o.date = dt.now(tz.tzutc())
     lst = float(o.sidereal_time())
     raDec = Position.altAzToRaDec(altAz, lat, lst)
     
     altAz2 = Position.raDecToAltAz(raDec, lat, lst)
     assert equal(altAz.alt.toR(),altAz2.alt.toR()) & equal(altAz.az.toR(),altAz2.az.toR())
Ejemplo n.º 5
0
 def test_altAzRaDec(self):
     
     altAz = Position.fromAltAz('20:30:40', '222:11:00')
     lat = Coord.fromD(0)
     o = ephem.Observer()
     o.lat = '0:0:0'
     o.long = '0:0:0'
     o.date = dt.now(tz.tzutc())
     lst = float(o.sidereal_time())
     raDec = Position.altAzToRaDec(altAz, lat, lst)
     
     altAz2 = Position.raDecToAltAz(raDec, lat, lst)
     assert equal(altAz.alt.toR(),altAz2.alt.toR()) & equal(altAz.az.toR(),altAz2.az.toR())
Ejemplo n.º 6
0
    def solve_dome_azimuth(self, telescope_pos, lst, nloops=10):

        # Find the altitude and azimuth of the current pointing
        # This should be valid in either hemisphere
        pos = Position.raDecToAltAz(telescope_pos, self.site_latitude, lst)
        telaz, telalt, ha = pos.az.R, pos.alt.R, CoordUtil.raToHa(
            telescope_pos.ra, lst).R

        # Find the reference point on the optical axis in dome coordinates
        # z: vertical
        # y: north - south
        # x: east - west
        # theta: altitude of the polar axis from the horizontal plane
        # phi: rotation of dec axis about polar axis

        # Meaning of x and y compared to sky depends on the hemisphere!
        # z: always + up
        # y: always + toward N for +lat or S for -lat
        # x: maintains right-handed coordinate system with z and y
        #  thus x is + to E for +lat and to W for -lat
        # theta: always positive from the horizontal plane to the pole
        # phi: rotation about polar axis
        #  and is +90 for a horizontal axis with OTA toward +x
        #  and is   0 for OTA over mount with dec axis counterweight down
        #  and is -90 for a horizontal axis with OTA toward -x

        # We have a German equatorial and the origin changes with ha
        # Assign phi based on an assumption about the basis derived from the ha
        phi = ha

        # Assign theta
        theta = abs(self.site_latitude.R)

        # Find the dome coordinates of the OTA reference point for a German equatorial
        # This works in either hemisphere
        x0 = self.mount_dec_length * sin(phi)
        y0 = -self.mount_dec_length * cos(phi) * sin(
            theta) + self.mount_dec_offset
        z0 = self.mount_dec_length * cos(phi) * cos(
            theta) + self.mount_dec_height

        # (x,y,z) is on the optical axis
        # Iterate to make this point also lie on the dome surface
        # Begin iteration assuming the zero point is at the center of the dome
        # Telescope azimuth is measured from the direction to the pole

        d = 0.
        r = self.dome_radius

        if self.site_latitude.R <= 0.:
            telaz2 = telaz - pi
            # between (0, 2pi):
            if telaz2 > 2 * pi:
                telaz2 -= 2 * pi
            elif telaz2 < 0:
                telaz2 += 2 * pi

            telalt2 = telalt

        # Iterate for convergence

        n = 0
        while n < nloops:
            d -= r - self.dome_radius
            rp = self.dome_radius + d
            x = x0 + rp * cos(telalt2) * sin(telaz2)
            y = y0 + rp * cos(telalt2) * cos(telaz2)
            z = z0 + rp * sin(telalt2)
            r = sqrt(x * x + y * y + z * z)

            # Repeat the calculation correcting the assumed OTA path length each time
            # This converges quickly  so just do a few loops and assume it is ok

            # print "n, r, rp: ", n, r, rp

            n += 1

        # Use (x,y,0) from the interation to find the azimuth of the dome
        # Azimuth is N (0), E (90), S (180), W (270) in both hemispheres
        # However x and y are different in the hemispheres so we fix that here

        zeta = atan2(x, y)
        if (zeta > -2. * pi) and (zeta < 2. * pi):
            if self.site_latitude.R <= 0.:
                zeta += pi
        else:
            zeta = telaz

        if zeta < 0:
            zeta = zeta + 2 * pi
        elif zeta > 2 * pi:
            zeta - 2 * pi

        return zeta * 180 / pi
Ejemplo n.º 7
0
 def raDecToAltAz(self, raDec):
     return Position.raDecToAltAz(raDec, self['latitude'],
                                  self.LST_inRads())
Ejemplo n.º 8
0
    def raDecToAltAz(self, raDec,lst_inRads=None):
		if not lst_inRads:
			lst_inRads = self.LST_inRads()
		return Position.raDecToAltAz(raDec, self['latitude'], lst_inRads)
Ejemplo n.º 9
0
 def raDecToAltAz(self, raDec):
     return Position.raDecToAltAz(raDec, self['latitude'], self.LST_inRads())
Ejemplo n.º 10
0
 def raDecToAltAz(self, raDec, lst_inRads=None):
     if not lst_inRads:
         lst_inRads = self.LST_inRads()
     return Position.raDecToAltAz(raDec, self['latitude'], lst_inRads)
Ejemplo n.º 11
0
    def solve_dome_azimuth(self, telescope_pos, lst, nloops=10):

        # Find the altitude and azimuth of the current pointing
        # This should be valid in either hemisphere
        pos = Position.raDecToAltAz(telescope_pos, self.site_latitude, lst)
        telaz, telalt, ha = pos.az.R, pos.alt.R, CoordUtil.raToHa(telescope_pos.ra, lst).R

        # Find the reference point on the optical axis in dome coordinates
        # z: vertical
        # y: north - south
        # x: east - west
        # theta: altitude of the polar axis from the horizontal plane
        # phi: rotation of dec axis about polar axis

        # Meaning of x and y compared to sky depends on the hemisphere!
        # z: always + up
        # y: always + toward N for +lat or S for -lat
        # x: maintains right-handed coordinate system with z and y
        #  thus x is + to E for +lat and to W for -lat
        # theta: always positive from the horizontal plane to the pole
        # phi: rotation about polar axis
        #  and is +90 for a horizontal axis with OTA toward +x
        #  and is   0 for OTA over mount with dec axis counterweight down
        #  and is -90 for a horizontal axis with OTA toward -x


        # We have a German equatorial and the origin changes with ha
        # Assign phi based on an assumption about the basis derived from the ha
        phi = ha

        # Assign theta
        theta = abs(self.site_latitude.R)

        # Find the dome coordinates of the OTA reference point for a German equatorial
        # This works in either hemisphere
        x0 = self.mount_dec_length * sin(phi)
        y0 = -self.mount_dec_length * cos(phi) * sin(theta) + self.mount_dec_offset
        z0 = self.mount_dec_length * cos(phi) * cos(theta) + self.mount_dec_height

        # (x,y,z) is on the optical axis
        # Iterate to make this point also lie on the dome surface
        # Begin iteration assuming the zero point is at the center of the dome
        # Telescope azimuth is measured from the direction to the pole

        d = 0.
        r = self.dome_radius

        if self.site_latitude.R <= 0.:
            telaz2 = telaz - pi
            # between (0, 2pi):
            if telaz2 > 2 * pi:
                telaz2 -= 2 * pi
            elif telaz2 < 0:
                telaz2 += 2 * pi

            telalt2 = telalt

        # Iterate for convergence

        n = 0
        while n < nloops:
            d -= r - self.dome_radius
            rp = self.dome_radius + d
            x = x0 + rp * cos(telalt2) * sin(telaz2)
            y = y0 + rp * cos(telalt2) * cos(telaz2)
            z = z0 + rp * sin(telalt2)
            r = sqrt(x * x + y * y + z * z)

            # Repeat the calculation correcting the assumed OTA path length each time
            # This converges quickly  so just do a few loops and assume it is ok

            # print "n, r, rp: ", n, r, rp

            n += 1

        # Use (x,y,0) from the interation to find the azimuth of the dome
        # Azimuth is N (0), E (90), S (180), W (270) in both hemispheres
        # However x and y are different in the hemispheres so we fix that here

        zeta = atan2(x, y)
        if (zeta > - 2. * pi) and (zeta < 2. * pi):
            if self.site_latitude.R <= 0.:
                zeta += pi
        else:
            zeta = telaz

        if zeta < 0:
            zeta = zeta + 2 * pi
        elif zeta > 2 * pi:
            zeta - 2 * pi

        return zeta * 180 / pi