Exemple #1
0
def ccFromSCPVOff(pos, pm, parlax, radVel, offDir, offMag):
    """
    Converts spherical to cartesian coordinates, including position, velocity
    and and a local offset along a great circle from the position vector.
    See also ccFromSCPV and ccFromSC.
    
    Inputs:
    - pos(2)    spherical position (degrees);
                pos[1] must be in the range [-90,90]
    - pm(2)     proper motion (arcsec per century)
    - parlax    parallax (arcsec)
    - radVel    radial velocity (km/s, positive receding)
    - offDir    offset direction (degrees):
                dir. of increasing pos[0] = 0, pos[1] = 90
    - offMag    offset magnitude (degrees on the sky)
    
    Returns:
    - p(3)      position vector (au)
    - v(3)      velocity (au per year)
    - offP(3)   offset position vector (au)
    - atInf     true if object is very far away (see Details)
    
    Error Conditions:
    - Raises ValueError if pos[1] is not in the range -90 to 90 deg
    
    Warnings:
    - Negative parallax is silently treated as zero parallax (object at infinity).
    
    Details:
    - See Sph.CCFromSCPV for more information.
    
    History
    2002-08-22 ROwen  Converted to Python from the TCC's sph_SCPVOff2CC 6-1.
    """
    # convert spherical position and velocity to cartesian
    p, v, atInf = ccFromSCPV(pos, pm, parlax, radVel)

    # compute spherical coordinates of the offset position;
    # ignore the case of the offset position being at the pole,
    # as the standard calculations work fine for that case
    # (sets side_bb = 0 and ang_A = ang_C = 90)
    ang_A, side_bb, ang_C, offPosAtPole = angSideAng(90.0 - pos[1],
                                                     90.0 - offDir, offMag)
    offPos = (
        pos[0] + ang_C,
        90.0 - side_bb,
    )

    # convert the offset position to cartesian coordinates
    # (the offset is assumed to be long a great circle,
    # so the magnitude is exactly the same as the un-offset position)
    magP = RO.MathUtil.vecMag(p)
    offP = ccFromSC(offPos, magP)

    return (p, v, offP, atInf)
Exemple #2
0
def ccFromSCPVOff(pos, pm, parlax, radVel, offDir, offMag):
    """
    Converts spherical to cartesian coordinates, including position, velocity
    and and a local offset along a great circle from the position vector.
    See also ccFromSCPV and ccFromSC.
    
    Inputs:
    - pos(2)    spherical position (degrees);
                pos[1] must be in the range [-90,90]
    - pm(2)     proper motion (arcsec per century)
    - parlax    parallax (arcsec)
    - radVel    radial velocity (km/s, positive receding)
    - offDir    offset direction (degrees):
                dir. of increasing pos[0] = 0, pos[1] = 90
    - offMag    offset magnitude (degrees on the sky)
    
    Returns:
    - p(3)      position vector (au)
    - v(3)      velocity (au per year)
    - offP(3)   offset position vector (au)
    - atInf     true if object is very far away (see Details)
    
    Error Conditions:
    - Raises ValueError if pos[1] is not in the range -90 to 90 deg
    
    Warnings:
    - Negative parallax is silently treated as zero parallax (object at infinity).
    
    Details:
    - See Sph.CCFromSCPV for more information.
    
    History
    2002-08-22 ROwen  Converted to Python from the TCC's sph_SCPVOff2CC 6-1.
    """
    # convert spherical position and velocity to cartesian
    p, v, atInf = ccFromSCPV (pos, pm, parlax, radVel)
    
    # compute spherical coordinates of the offset position;
    # ignore the case of the offset position being at the pole,
    # as the standard calculations work fine for that case
    # (sets side_bb = 0 and ang_A = ang_C = 90)
    ang_A, side_bb, ang_C, offPosAtPole = angSideAng (90.0 - pos[1], 90.0 - offDir, offMag)
    offPos = (
        pos[0] + ang_C,
        90.0 - side_bb,
    )
    
    # convert the offset position to cartesian coordinates
    # (the offset is assumed to be long a great circle,
    # so the magnitude is exactly the same as the un-offset position)
    magP = RO.MathUtil.vecMag(p)
    offP = ccFromSC(offPos, magP)
    
    return (p, v, offP, atInf)
Exemple #3
0
def scFromCCPVOff(p, v, offP):
    """
    Converts cartesian position, velocity and offset to spherical coordinates
    (see also SCFromCC and SCFromCCPV).
    
    Inputs:
    - p(3)      position (au)
    - v(3)      velocity (au per year)
    - offP(3)   offset position (au)
    
    Returns:
    - pos(2)    spherical position (degrees)
                ranges: axis 1: [0, 360), axis 2: [-90,90]
    - pm(2)     proper motion (arcsec per century)
    - parlax    parallax (arcsec)
    - radVel    radial velocity (km/s)
    - offDir    offset direction (degrees):
                dir. of increasing pos[0] = 0
                dir. of increasing pos[1] = 90
    - offMag    magnitude of offset (degrees on the sky)
    - atPole    true if at a pole; see "Error Cond." for implications
    
    Error Conditions:
    - Raises ValueError if |p| is too small to safely compute.
        
    - If p is very near a pole, atPole is set true,
      pos[1], pm[0], pm[1] and offDir are set to zero;
      pos[0], parlax, radVel and offMag are still computed correctly
      (pos[0] is +/-90.0, as appropriate).
    
    - If inputs are too large, overflows are possible--roughly if p^2 or v^2 overflows.
    
    History
    2002-08-22 ROwen  Converted to Python from the TCC's sph_CCPVOff2SC 6-1.
    """
    #  convert p and v from cartesian to spherical
    pos, pm, parlax, radVel, atPole = scFromCCPV(p, v)
    
    #  convert offP from cartesian to spherical
    offPos, magOffP, offAtPole = scFromCC(offP)
    
    #  compute offset direction and magnitude
    ang_A, side_bb, ang_C, offAtPole2 = angSideAng(
        90.0 - pos[1], offPos[0] - pos[0], 90.0 - offPos[1],
    )
    offMag = side_bb
    if atPole:
        offDir = 0.0
    else:
        offDir = 90.0 - ang_C

    return (pos, pm, parlax, radVel, offDir, offMag, atPole)