Exemplo n.º 1
0
 def test_slalib(self, mjd, config):
     from pyslalib import slalib
     ra = numpy.zeros(len(mjd), 'float')
     dec = numpy.zeros(len(mjd), 'float')
     for i in range(len(mjd)):
         # Calculate sun's (topocentric) position.
         #ra_RAD, dec_RAD, diam = slalib.sla_rdplan(mjd[i], 0,
         #                                          config['longitude']*_deg2rad, config['latitude']*_deg2rad)
         # Sun's (geocentric?) position.
         bary_vel, bary_pos, helio_vel, helio_pos = slalib.sla_evp(
             mjd, 2000)
         sun_pos = -1 * (bary_pos)
         ra_RAD, dec_RAD = slalib.sla_dcc2s(sun_pos)
         ra[i] = ra_RAD * _rad2deg
         dec[i] = dec_RAD * _rad2deg
     print "Sun: Test_slalib results"
     print " ... ra(slalib)"
     print ra
     print "  ... ra(self)"
     print self.ra
     print self.ra.min(), self.ra.max()
     print " ... dec(slalib)"
     print dec
     print " ... dec(self)"
     print self.dec
Exemplo n.º 2
0
 def planet_J2000_geo_to_topo(self, gra, gdec, dist, radi, dut1, longitude, latitude, height):
     jd_utc = self.calc_jd_utc()
     date = jd_utc - 2400000.5 + dut1 / (24. * 3600.)
     jd = jd_utc - 2400000.5 + (self.tai_utc + 32.184) / (24. * 3600.) # reference => http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html
     
     # Spherical to x,y,z 
     v = slalib.sla_dcs2c(gra, gdec)
     for i in range (3):
         v[i] *= dist
     
     # Precession to date. 
     rmat = slalib.sla_prec(2000.0, slalib.sla_epj(jd))
     vgp = slalib.sla_dmxv(rmat, v)
     
     # Geocenter to observer (date). 
     stl = slalib.sla_gmst(date) + longitude
     vgo = slalib.sla_pvobs(latitude, height, stl)
     
     # Observer to planet (date). 
     for i in range (3):
         v[i] = vgp[i] - vgo[i]
     
     disttmp = dist
     dist = math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])
     radi *= disttmp / dist
     
     # Precession to J2000 
     rmat = slalib.sla_prec(slalib.sla_epj(jd), 2000.)
     vgp = slalib.sla_dmxv(rmat, v)
     
     # To RA,Dec. 
     ret = slalib.sla_dcc2s(vgp)
     tra = slalib.sla_dranrm(ret[0])
     tdec = ret[1]
     return [dist, radi, tra, tdec]
Exemplo n.º 3
0
 def calc_planet_coordJ2000(self, ntarg):
     err_code = i = nctr = 3
     c = 2.99792e8
     k_to_au = 6.68459e-9
     
     jd_utc = self.calc_jd_utc()
     jd = jd_utc + (self.tai_utc + 32.184) / (24. * 3600.)  # Convert UTC to Dynamical Time
     if ntarg != 10:
         if ntarg == 11: #for Sun
             n_ntarg = 10
         else:
             n_ntarg = ntarg
         position = self.jpl[0, n_ntarg].compute(jd) # compute planet Barycenter
         position -= self.jpl[0, 3].compute(jd) # compute Earth Barycenter
         position -= self.jpl[3, 399].compute(jd) # compute Earth position
         dist = math.sqrt(position[0] ** 2 + position[1] ** 2 + position[2] ** 2) # [km]
         
         position_1 = self.jpl[0, 3].compute(jd) #Earth position at jd
         position_2 = self.jpl[0, n_ntarg].compute(jd - (dist / c) / (24. * 3600.)) # Target position when the light left
         position = position_2 - position_1
         position -= self.jpl[3, 399].compute(jd)
         dist = math.sqrt(position[0] ** 2 + position[1] ** 2 + position[2] ** 2)
     else: #for Moon
         position = self.jpl[3, 301].compute(jd)
         dist = math.sqrt(position[0] ** 2 + position[1] ** 2 + position[2] ** 2) # [km]
         
         position = self.jpl[3,301].compute(jd - (dist / c) / (24 * 3600.0))
         dist = math.sqrt(position[0] ** 2 + position[1] ** 2 + position[2] ** 2)
     ret = slalib.sla_dcc2s(position)
     ra = ret[0] # radian
     dec = ret[1] # radian
     ra = slalib.sla_dranrm(ra)
     radi = math.asin(self.eqrau[ntarg] / dist)
     dist = dist*k_to_au
     return [ra, dec, dist, radi]
Exemplo n.º 4
0
    def HJD_to_JD(self, time_to_transform):
        """Transform the input time from HJD to JD.

        :param array_like time_to_transform: the numpy array containing the time in HJD you want
        to transform in JD.
        :return: the time in JD
        :rtype: array_like
        """
        AU = self.AU
        light_speed = self.speed_of_light

        time_correction = []
        # DTT=[]


        for time in time_to_transform:

            count = 0
            jd = np.copy(time)

            while count < 3:
                Earth_position = slalib.sla_epv(jd)
                Sun_position = -Earth_position[0]

                Sun_angles = slalib.sla_dcc2s(Sun_position)
                target_angles_in_the_sky = self.target_angles_in_the_sky

                Time_correction = np.sqrt(
                    Sun_position[0] ** 2 + Sun_position[1] ** 2 + Sun_position[
                        2] ** 2) * AU / light_speed * (
                                      np.sin(Sun_angles[1]) * np.sin(
                                          target_angles_in_the_sky[1]) + np.cos(
                                          Sun_angles[1]) * np.cos(
                                          target_angles_in_the_sky[1]) * np.cos(
                                          target_angles_in_the_sky[0] - Sun_angles[0])) / (
                                      3600 * 24.0)
                count = count + 1

        # DTT.append(slalib.sla_dtt(jd)/(3600*24))
        time_correction.append(Time_correction)

        JD = time_to_transform + np.array(time_correction)

        return JD
Exemplo n.º 5
0
    def HJD_to_JD(self, time_to_transform):
        """Transform the input time from HJD to JD.

        :param array_like time_to_transform: the numpy array containing the time in HJD you want
        to transform in JD.
        :return: the time in JD
        :rtype: array_like
        """
        AU = self.AU
        light_speed = self.speed_of_light

        time_correction = []
        # DTT=[]


        for time in time_to_transform:

            count = 0
            jd = np.copy(time)

            while count < 3:
                Earth_position = slalib.sla_epv(jd)
                Sun_position = -Earth_position[0]

                Sun_angles = slalib.sla_dcc2s(Sun_position)
                target_angles_in_the_sky = self.target_angles_in_the_sky

                Time_correction = np.sqrt(
                    Sun_position[0] ** 2 + Sun_position[1] ** 2 + Sun_position[
                        2] ** 2) * AU / light_speed * (
                                      np.sin(Sun_angles[1]) * np.sin(
                                          target_angles_in_the_sky[1]) + np.cos(
                                          Sun_angles[1]) * np.cos(
                                          target_angles_in_the_sky[1]) * np.cos(
                                          target_angles_in_the_sky[0] - Sun_angles[0])) / (
                                      3600 * 24.0)
                count = count + 1

        # DTT.append(slalib.sla_dtt(jd)/(3600*24))
        time_correction.append(Time_correction)

        JD = time_to_transform + np.array(time_correction)

        return JD
Exemplo n.º 6
0
    def calc_planet_coordJ2000(self, ntarg):
        err_code = i = nctr = 3
        c = 2.99792e8
        k_to_au = 6.68459e-9

        jd_utc = self.calc_jd_utc()
        jd = jd_utc + (self.tai_utc + 32.184) / (
            24. * 3600.)  # Convert UTC to Dynamical Time
        if ntarg != 10:
            if ntarg == 11:  #for Sun
                n_ntarg = 10
            else:
                n_ntarg = ntarg
            position = self.jpl[0, n_ntarg].compute(
                jd)  # compute planet Barycenter
            position -= self.jpl[0, 3].compute(jd)  # compute Earth Barycenter
            position -= self.jpl[3, 399].compute(jd)  # compute Earth position
            dist = math.sqrt(position[0]**2 + position[1]**2 +
                             position[2]**2)  # [km]

            position_1 = self.jpl[0, 3].compute(jd)  #Earth position at jd
            position_2 = self.jpl[0, n_ntarg].compute(
                jd - (dist / c) /
                (24. * 3600.))  # Target position when the light left
            position = position_2 - position_1
            position -= self.jpl[3, 399].compute(jd)
            dist = math.sqrt(position[0]**2 + position[1]**2 + position[2]**2)
        else:  #for Moon
            position = self.jpl[3, 301].compute(jd)
            dist = math.sqrt(position[0]**2 + position[1]**2 +
                             position[2]**2)  # [km]

            position = self.jpl[3,
                                301].compute(jd - (dist / c) / (24 * 3600.0))
            dist = math.sqrt(position[0]**2 + position[1]**2 + position[2]**2)
        ret = slalib.sla_dcc2s(position)
        ra = ret[0]  # radian
        dec = ret[1]  # radian
        ra = slalib.sla_dranrm(ra)
        radi = math.asin(self.eqrau[ntarg] / dist)
        dist = dist * k_to_au
        return [ra, dec, dist, radi]
Exemplo n.º 7
0
    def planet_J2000_geo_to_topo(self, gra, gdec, dist, radi, dut1, longitude,
                                 latitude, height):
        jd_utc = self.calc_jd_utc()
        date = jd_utc - 2400000.5 + dut1 / (24. * 3600.)
        jd = jd_utc - 2400000.5 + (self.tai_utc + 32.184) / (
            24. * 3600.
        )  # reference => http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html

        # Spherical to x,y,z
        v = slalib.sla_dcs2c(gra, gdec)
        for i in range(3):
            v[i] *= dist

        # Precession to date.
        rmat = slalib.sla_prec(2000.0, slalib.sla_epj(jd))
        vgp = slalib.sla_dmxv(rmat, v)

        # Geocenter to observer (date).
        stl = slalib.sla_gmst(date) + longitude
        vgo = slalib.sla_pvobs(latitude, height, stl)

        # Observer to planet (date).
        for i in range(3):
            v[i] = vgp[i] - vgo[i]

        disttmp = dist
        dist = math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])
        radi *= disttmp / dist

        # Precession to J2000
        rmat = slalib.sla_prec(slalib.sla_epj(jd), 2000.)
        vgp = slalib.sla_dmxv(rmat, v)

        # To RA,Dec.
        ret = slalib.sla_dcc2s(vgp)
        tra = slalib.sla_dranrm(ret[0])
        tdec = ret[1]
        return [dist, radi, tra, tdec]
Exemplo n.º 8
0
 def test_slalib(self, mjd, config):
     from pyslalib import slalib
     ra = numpy.zeros(len(mjd), 'float')
     dec = numpy.zeros(len(mjd), 'float')
     for i in range(len(mjd)):
         # Calculate sun's (topocentric) position. 
         #ra_RAD, dec_RAD, diam = slalib.sla_rdplan(mjd[i], 0,
         #                                          config['longitude']*_deg2rad, config['latitude']*_deg2rad)
         # Sun's (geocentric?) position.
         bary_vel, bary_pos, helio_vel, helio_pos = slalib.sla_evp(mjd, 2000)
         sun_pos = -1 * (bary_pos)
         ra_RAD, dec_RAD = slalib.sla_dcc2s(sun_pos)
         ra[i] = ra_RAD * _rad2deg
         dec[i] = dec_RAD * _rad2deg
     print "Sun: Test_slalib results"
     print " ... ra(slalib)"
     print ra
     print "  ... ra(self)"
     print self.ra
     print self.ra.min(), self.ra.max()
     print " ... dec(slalib)"    
     print dec
     print " ... dec(self)"
     print self.dec