Example #1
0
def get_pos_bodies(et,
                   name_bodies,
                   units='radec',
                   wcs=False,
                   frame='J2000',
                   abcorr='LT',
                   name_observer='New Horizons'):

    "Get an array of points for a list of bodies, seen from an observer at the given ET."
    "Result is in RA / Dec radians. If units='pixels', then it is in x y pixels, based on the supplied wcs."
    "name_bodies may be scalar or vector."

    num_bodies = np.size(
        name_bodies
    )  # Return 1 if scalar, 2 if pair, etc; len() gets confused on strings.

    ra = np.zeros(num_bodies)
    dec = np.zeros(num_bodies)

    if num_bodies == 1 and (hbt.is_array(name_bodies) == False):
        arr = np.array([name_bodies])
    else:
        arr = name_bodies
    quit
    #    i = 0
    for i, name_body in enumerate(arr):
        st, ltime = cspice.spkezr(name_body, et, frame, abcorr, name_observer)
        radius, ra[i], dec[i] = cspice.recrad(st[0:3])

    if (units == 'pixels'):
        x, y = wcs.wcs_world2pix(ra * r2d, dec * r2d, 0)  # Convert to pixels
        return x, y

    return ra, dec  # Return in radians
Example #2
0
def get_pos_ring(et,
                 num_pts=100,
                 radius=122000,
                 name_body='Jupiter',
                 units='radec',
                 wcs=False,
                 frame='J2000',
                 abcorr='LT+S'):

    "Get an array of points for a ring, at a specified radius, seen from observer at the given ET."
    "Result is in RA / Dec radians. If units='pixels', then it is in x y pixels, based on the supplied wcs."

    # Now calculate the ring points...

    #    radii_ring = np.array([1220000., 129000.])  # Inner and outer radius to plot
    num_pts_ring = 100

    ring_lon = np.linspace(0, 2. * np.pi, num_pts_ring)
    ra_ring = np.zeros(num_pts_ring)
    dec_ring = np.zeros(num_pts_ring)

    rot = cspice.pxform('IAU_' + name_body, frame,
                        et)  # Get matrix from arg1 to arg2

    st, ltime = cspice.spkezr(name_body, et, frame, abcorr, name_observer)
    pos = st[0:3]
    #    vel = st[3:6] # velocity, km/sec, of jupiter

    for j in range(num_pts_ring):
        xyz = np.zeros(3)
        xyz = np.array(
            (radius * np.cos(ring_lon[j]), radius * np.sin(ring_lon[j]), 0.))

        d_j2000_xyz = np.dot(
            rot, xyz)  # Manual says that this is indeed matrix multiplication
        j2000_xyz = 0 * d_j2000_xyz
        j2000_xyz[0:3] = d_j2000_xyz[0:3]  # Looks like this is just copying it

        rho_planet = pos  # Position of planet
        rho_ring = rho_planet + j2000_xyz  # Vector obs-ring
        #        dist_ring     = cspice.vnorm(rho_ring)*1000 # Convert to km... CHECK UNITS!

        range_out, ra, dec = cspice.recrad(
            rho_ring)  # 'range' is a protected keyword in python!

        ra_ring[j] = ra  # save RA, Dec as radians
        dec_ring[j] = dec

    if (units == 'pixels'):
        x_ring, y_ring = wcs.wcs_world2pix(ra_ring * r2d, dec_ring * r2d,
                                           0)  # Convert to pixels
        return xring, yring

    return ra_ring, dec_ring
Example #3
0
def correct_stellab(radec, vel):
    "Corect for stellar aberration."
    "radec is array (n,2) in radians. velocity in km/sec. Both should be in J2K coords."

    radec_abcorr = radec.copy()    
    for i in range(np.shape(radec)[0]):
        pos_i = cspice.radrec(1., radec[i,0], radec[i,1])
        pos_i_abcorr = cspice.stelab(pos_i, vel)
        rang, radec_abcorr[i,0], radec_abcorr[i,1] = cspice.recrad(pos_i_abcorr)

    return radec_abcorr
Example #4
0
def correct_stellab(radec, vel):
    "Corect for stellar aberration."
    "radec is array (n,2) in radians. velocity in km/sec. Both should be in J2K coords."

    radec_abcorr = radec.copy()
    for i in range(np.shape(radec)[0]):
        pos_i = cspice.radrec(1., radec[i, 0], radec[i, 1])
        pos_i_abcorr = cspice.stelab(pos_i, vel)
        rang, radec_abcorr[i, 0], radec_abcorr[i,
                                               1] = cspice.recrad(pos_i_abcorr)

    return radec_abcorr
Example #5
0
def get_jring_points_radec(et, num_pts=100, radius = 122000):
    "Get an array of points of RA, Dec for the Jupiter ring, at a specified radius, seen from NH at the given ET."
    
# Now calculate the ring points...

    radii_ring = np.array([1220000., 129000.])  # Inner and outer radius to plot
    num_pts_ring = 100
    
    ring_lon = np.linspace(0, 2. * np.pi, num_pts_ring)
    ra_ring  = np.zeros(num_pts_ring)
    dec_ring = np.zeros(num_pts_ring)
    
    frame = 'J2000'
    abcorr = 'LT'
#    rot = cspice.pxform('IAU_Jupiter', frame, et) # Get matrix from arg1 to arg2
    rot = [[1,0,0],[0,1,0],[0,0,1]]
    
    st,ltime = cspice.spkezr('Jupiter', et, frame, abcorr, 'New Horizons')
    pos = st[0:3]
    vel = st[3:6] # velocity, km/sec, of jupiter
    
    for radius_ring in radii_ring:
        for j in range(num_pts_ring):
            xyz = np.zeros(3)
            xyz = np.array((radius_ring * np.cos(ring_lon[j]), radius_ring * np.sin(ring_lon[j]), 0.))
            
            d_j2000_xyz = np.dot(rot,xyz)  # Manual says that this is indeed matrix multiplication
            j2000_xyz = 0 * d_j2000_xyz
            j2000_xyz[0:3] = d_j2000_xyz[0:3] # Looks like this is just copying it

            rho_planet    = pos                     # Position of planet
            rho_ring      = rho_planet + j2000_xyz  # Vector obs-ring
            dist_ring     = cspice.vnorm(rho_ring)*1000 # Convert to km... CHECK UNITS!
            
            range_out, ra, dec = cspice.recrad(rho_ring) # 'range' is a protected keyword in python!
            
            ra_ring[j] = ra     # save RA, Dec as radians
            dec_ring[j] = dec
                
    return ra_ring, dec_ring