コード例 #1
0
def test_hcrs_hgs_different_obstime():
    # Test whether the HCRS->HGS transformation handles a change in obstime the same way as forcing
    # a HCRS loopback in Astropy
    time1 = Time('2001-01-01')
    time2 = Time('2001-02-01')

    coord = HCRS(1*u.km, 2*u.km, 3*u.km, representation_type='cartesian', obstime=time1)
    out_frame = HeliographicStonyhurst(obstime=time2)

    sunpy_coord = coord.transform_to(out_frame)
    astropy_coord = coord.transform_to(HCRS(obstime=time2)).transform_to(out_frame)

    assert quantity_allclose(sunpy_coord.cartesian.xyz, astropy_coord.cartesian.xyz)
コード例 #2
0
ファイル: transformations.py プロジェクト: wtbarnes/sunpy
def gei_to_hme(geicoord, hmeframe):
    """
    Convert from Geocentric Earth Equatorial to Heliocentric Mean Ecliptic
    """
    if geicoord.obstime is None:
        raise ConvertError("To perform this transformation, the coordinate"
                           " frame needs a specified `obstime`.")

    # Use an intermediate frame of HME at the GEI observation time
    int_frame = HeliocentricMeanEcliptic(obstime=geicoord.obstime, equinox=geicoord.equinox)

    # Get the Sun-Earth vector in the intermediate frame
    sun_earth = HCRS(_sun_earth_icrf(int_frame.obstime), obstime=int_frame.obstime)
    sun_earth_int = sun_earth.transform_to(int_frame).cartesian

    # Rotate from Earth equatorial to ecliptic
    rot_matrix = _rotation_matrix_obliquity(int_frame.equinox)
    earth_object_int = geicoord.cartesian.transform(rot_matrix)

    # Find the Sun-object vector in the intermediate frame
    sun_object_int = sun_earth_int + earth_object_int
    int_coord = int_frame.realize_frame(sun_object_int)

    # Convert to the final frame through HCRS
    return int_coord.transform_to(HCRS(obstime=int_coord.obstime)).transform_to(hmeframe)
コード例 #3
0
ファイル: transformations.py プロジェクト: yukienomiya/sunpy
def hme_to_gei(hmecoord, geiframe):
    """
    Convert from Heliocentric Mean Ecliptic to Geocentric Earth Equatorial
    """
    if geiframe.obstime is None:
        raise ConvertError("To perform this transformation, the coordinate"
                           " frame needs a specified `obstime`.")

    # Use an intermediate frame of HME at the GEI observation time, through HCRS
    int_frame = HeliocentricMeanEcliptic(obstime=geiframe.obstime,
                                         equinox=geiframe.equinox)
    int_coord = hmecoord.transform_to(
        HCRS(obstime=int_frame.obstime)).transform_to(int_frame)

    # Get the Sun-Earth vector in the intermediate frame
    sun_earth = HCRS(_sun_earth_icrf(int_frame.obstime),
                     obstime=int_frame.obstime)
    sun_earth_int = sun_earth.transform_to(int_frame).cartesian

    # Find the Earth-object vector in the intermediate frame
    earth_object_int = int_coord.cartesian - sun_earth_int

    # Rotate from ecliptic to Earth equatorial
    rot_matrix = matrix_transpose(_rotation_matrix_obliquity(
        int_frame.equinox))
    newrepr = earth_object_int.transform(rot_matrix)

    return geiframe.realize_frame(newrepr)
コード例 #4
0
def test_hcrs_hgs_reversibility():
    # Test whether the HCRS->HGS transformation is reversed by the HGS->HCRS transformation
    time1 = Time('2001-01-01')
    time2 = Time('2001-02-01')

    coord = HCRS(1*u.km, 2*u.km, 3*u.km, representation_type='cartesian', obstime=time1)
    new_coord = coord.transform_to(HeliographicStonyhurst(obstime=time2)).transform_to(coord)

    assert quantity_allclose(coord.cartesian.xyz, new_coord.cartesian.xyz)
コード例 #5
0
def HCI2ECI_pos(Pos_HCI, t):
    
    # Position & velocity relative to the sun
    T = Time(t, format='jd', scale='utc')

    Pos_HCRS = HCI2HCRS(Pos_HCI)
    # TODO. HARD: had to remove it
    #Vel_HCRS_rel = HCI2HCRS(Vel_HCI - EarthVelocity(t))

    Pos_HCRS_SC = HCRS(x=Pos_HCRS[0]*u.m, y=Pos_HCRS[1]*u.m, z=Pos_HCRS[2]*u.m,
        representation_type='cartesian', obstime=T)
    Pos_ECI = np.vstack(Pos_HCRS_SC.transform_to(GCRS(obstime=T)).cartesian.xyz.value)

    return Pos_ECI
コード例 #6
0
ファイル: transformations.py プロジェクト: wtbarnes/sunpy
def _rotation_matrix_hme_to_hee(hmeframe):
    """
    Return the rotation matrix from HME to HEE at the same observation time
    """
    # Get the Sun-Earth vector
    sun_earth = HCRS(_sun_earth_icrf(hmeframe.obstime), obstime=hmeframe.obstime)
    sun_earth_hme = sun_earth.transform_to(hmeframe).cartesian

    # Rotate the Sun-Earth vector about the Z axis so that it lies in the XZ plane
    rot_matrix = _rotation_matrix_reprs_to_xz_about_z(sun_earth_hme)

    # Tilt the rotated Sun-Earth vector so that it is aligned with the X axis
    tilt_matrix = _rotation_matrix_reprs_to_reprs(sun_earth_hme.transform(rot_matrix),
                                                  CartesianRepresentation(1, 0, 0))

    return matrix_product(tilt_matrix, rot_matrix)
コード例 #7
0
ファイル: transformations.py プロジェクト: karangurtu/sunpy
def hee_to_gse(heecoord, gseframe):
    """
    Convert from Heliocentric Earth Ecliptic to Geocentric Solar Ecliptic
    """
    # Use an intermediate frame of HEE at the GSE observation time
    int_frame = HeliocentricEarthEcliptic(obstime=gseframe.obstime)
    int_coord = heecoord.transform_to(int_frame)

    # Get the Sun-Earth vector in the intermediate frame
    sun_earth = HCRS(_sun_earth_icrf(int_frame.obstime), obstime=int_frame.obstime)
    sun_earth_int = sun_earth.transform_to(int_frame).cartesian

    # Find the Earth-object vector in the intermediate frame
    earth_object_int = int_coord.cartesian - sun_earth_int

    # Flip the vector in X and Y, but leave Z untouched
    # (The additional transpose operations are to handle both scalar and array inputs)
    newrepr = CartesianRepresentation((earth_object_int.xyz.T * [-1, -1, 1]).T)

    return gseframe.realize_frame(newrepr)