Exemple #1
0
def _make_sunpy_graph():
    """
    Culls down the full transformation graph for SunPy purposes and returns the string version
    """
    # Frames to keep in the transformation graph
    keep_list = [
        'icrs', 'hcrs', 'heliocentrictrueecliptic', 'heliocentricmeanecliptic',
        'heliographic_stonyhurst', 'heliographic_carrington', 'heliocentric',
        'helioprojective', 'heliocentricearthecliptic',
        'geocentricsolarecliptic', 'heliocentricinertial',
        'geocentricearthequatorial', 'gcrs', 'precessedgeocentric',
        'geocentrictrueecliptic', 'geocentricmeanecliptic', 'cirs', 'altaz',
        'itrs'
    ]

    global frame_transform_graph
    backup_graph = deepcopy(frame_transform_graph)

    small_graph = deepcopy(frame_transform_graph)
    cull_list = [
        name for name in small_graph.get_names() if name not in keep_list
    ]
    cull_frames = [small_graph.lookup_name(name) for name in cull_list]

    for frame in cull_frames:
        # Remove the part of the graph where the unwanted frame is the source frame
        if frame in small_graph._graph:
            del small_graph._graph[frame]

        # Remove all instances of the unwanted frame as the destination frame
        for entry in small_graph._graph:
            if frame in small_graph._graph[entry]:
                del (small_graph._graph[entry])[frame]

    # Clean up the node list
    for name in cull_list:
        small_graph._cached_names.pop(name)

    _add_astropy_node(small_graph)

    # Overwrite the main transform graph
    frame_transform_graph = small_graph

    docstr = make_transform_graph_docs()

    # Restore the main transform graph
    frame_transform_graph = backup_graph

    # Make adjustments to the graph
    docstr = _tweak_graph(docstr)

    return docstr
                                                      x_axis)
    else:
        rot_matrix_list = [
            _make_rotation_matrix_from_reprs(vect, x_axis)
            for vect in hgs_x_axis_detilt
        ]
        rot_matrix = np.stack(rot_matrix_list)

    return matrix_product(rot_matrix, _SUN_DETILT_MATRIX)


@frame_transform_graph.transform(DynamicMatrixTransform,
                                 HeliographicStonyhurst, HCRS)
def hgs_to_hcrs(hgscoord, hcrsframe):
    """
    Convert from Heliographic Stonyhurst to HCRS.
    """
    return matrix_transpose(hcrs_to_hgs(hcrsframe, hgscoord))


@frame_transform_graph.transform(FunctionTransform, HeliographicStonyhurst,
                                 HeliographicStonyhurst)
def hgs_to_hgs(from_coo, to_frame):
    if np.all(from_coo.obstime == to_frame.obstime):
        return to_frame.realize_frame(from_coo.data)
    else:
        return from_coo.transform_to(HCRS).transform_to(to_frame)


__doc__ += make_transform_graph_docs()
Exemple #3
0
    hgs_x_axis_detilt = CartesianRepresentation((sun_earth_detilt.xyz.T * [1, 1, 0]).T)

    # The above vector, which is in the Sun's equatorial plane, is also the X axis of HGS
    x_axis = CartesianRepresentation(1, 0, 0)
    if hgsframe.obstime.isscalar:
        rot_matrix = _make_rotation_matrix_from_reprs(hgs_x_axis_detilt, x_axis)
    else:
        rot_matrix_list = [_make_rotation_matrix_from_reprs(vect, x_axis) for vect in hgs_x_axis_detilt]
        rot_matrix = np.stack(rot_matrix_list)

    return matrix_product(rot_matrix, _SUN_DETILT_MATRIX)


@frame_transform_graph.transform(DynamicMatrixTransform, HeliographicStonyhurst, HCRS)
def hgs_to_hcrs(hgscoord, hcrsframe):
    """
    Convert from Heliographic Stonyhurst to HCRS.
    """
    return matrix_transpose(hcrs_to_hgs(hcrsframe, hgscoord))


@frame_transform_graph.transform(FunctionTransform, HeliographicStonyhurst, HeliographicStonyhurst)
def hgs_to_hgs(from_coo, to_frame):
    if np.all(from_coo.obstime == to_frame.obstime):
        return to_frame.realize_frame(from_coo.data)
    else:
        return from_coo.transform_to(HCRS).transform_to(to_frame)


__doc__ += make_transform_graph_docs()
Exemple #4
0
        coordinate systems.
    """
    name = 'GSE'
    default_representation = coords.CartesianRepresentation
    obstime = coords.TimeAttribute(default=None)


@coords.frame_transform_graph.transform(coords.AffineTransform,
                                        HeliocentricEarthEcliptic,
                                        GeocentricSolarEcliptic)
@transform_graph.transform(coords.AffineTransform, HeliocentricEarthEcliptic,
                           GeocentricSolarEcliptic)
def hee_to_gse(hee_coord, gse_frame):
    '''
    Convert from HEE to GSE coordinates.
    '''
    obstime = hee_coord.obstime
    r_earth_sun = sunpy.coordinates.sun.earth_distance(time=obstime)
    # Rotate 180deg around the z-axis
    R = np.array([[-1, 0, 0], [0, -1, 0], [0, 0, 1]])
    # Offset so centre is at Earth
    offset = coords.CartesianRepresentation(r_earth_sun, 0 * u.m, 0 * u.m)
    return R, offset


__doc__ += """
Transformation graph
--------------------
"""
__doc__ += astropy_frames.make_transform_graph_docs(transform_graph)
Exemple #5
0
    "OrbitSkyOffsetFrame",
    "OrbitOffsetFrame",
]

##############################################################################
# IMPORTS

from astropy.coordinates.baseframe import frame_transform_graph

from . import orbitoffset, orbitskyoffset
from .orbitoffset import OrbitOffsetFrame
from .orbitskyoffset import OrbitSkyOffsetFrame

# TODO: Astropy < 3.1.2 does not have make_transform_graph_docs
try:
    from astropy.coordinates.builtin_frames import make_transform_graph_docs
except ImportError:
    pass
else:
    _transform_graph_docs = make_transform_graph_docs(frame_transform_graph)

    # Here, we override the module docstring so that sphinx renders the
    # transform graph without the developer documentation in the main
    # docstring above.
    __doc__ = _transform_graph_docs

# /try

##############################################################################
# END