import mpl_animators as _animators from sunpy.util.decorators import deprecated from sunpy.visualization.animator.mapsequenceanimator import MapSequenceAnimator __all__ = [ 'LineAnimator', 'ImageAnimator', 'ArrayAnimatorWCS', 'ArrayAnimator', 'BaseFuncAnimator', 'MapSequenceAnimator' ] deprecated_animator = deprecated("3.1", alternative="the new mpl-animators package") @deprecated_animator class BaseFuncAnimator(_animators.BaseFuncAnimator): pass @deprecated_animator class ArrayAnimator(_animators.ArrayAnimator): pass @deprecated_animator class ArrayAnimatorWCS(_animators.ArrayAnimatorWCS): pass @deprecated_animator class ImageAnimator(_animators.ImageAnimator):
# Normalize directional vectors sky_normal /= sky_normal.norm() sun_north_in_sky /= sun_north_in_sky.norm() z_in_sky /= z_in_sky.norm() # Calculate the signed angle between the two projected vectors cos_theta = sun_north_in_sky.dot(z_in_sky) sin_theta = sun_north_in_sky.cross(z_in_sky).dot(sky_normal) angle = np.arctan2(sin_theta, cos_theta).to('deg') # If there is only one time, this function's output should be scalar rather than array if angle.size == 1: angle = angle[0] return Angle(angle) # The following functions are moved in the API to sunpy.coordinates.sun and renamed _old_names = [ 'get_sun_B0', 'get_sun_L0', 'get_sun_P', 'get_sunearth_distance', 'get_sun_orientation' ] _new_module = 'sunpy.coordinates.sun.' _new_names = ['B0', 'L0', 'P', 'earth_distance', 'orientation'] # Create a deprecation hook for each of the functions # Note that the code for each of these functions is still in this module as a private function for old, new in zip(_old_names, _new_names): vars()[old] = deprecated('1.0', name=old, alternative=_new_module + new)(vars()['_' + new])
# -*- coding: utf-8 -*- from sunpy.util.decorators import deprecated from sunpy.visualization.animator.mapsequenceanimator import MapSequenceAnimator __all__ = ['MapCubeAnimator'] MapCubeAnimator = deprecated("0.9.1", message='MapCubeAnimator deprecated in favor of MapSequenceAnimator. \ MapSequence has the same functionality as MapCube.')(MapSequenceAnimator)
class Helioprojective(SunPyBaseCoordinateFrame): """ A coordinate or frame in the Helioprojective Cartesian (HPC) system, which is observer-based. - The origin is the location of the observer. - ``theta_x`` is the angle relative to the plane containing the Sun-observer line and the Sun's rotation axis, with positive values in the direction of the Sun's west limb. - ``theta_y`` is the angle relative to the Sun's equatorial plane, with positive values in the direction of the Sun's north pole. - ``distance`` is the Sun-observer distance. This system is frequently used in a projective form without ``distance`` specified. For observations looking very close to the center of the Sun, where the small-angle approximation is appropriate, ``theta_x`` and ``theta_y`` can be approximated as Cartesian components. A new instance can be created using the following signatures (note that if supplied, ``obstime`` and ``observer`` must be keyword arguments):: Helioprojective(theta_x, theta_y, obstime=obstime, observer=observer) Helioprojective(theta_x, theta_y, distance, obstime=obstime, observer=observer) Parameters ---------- {data} Tx : `~astropy.coordinates.Angle` or `~astropy.units.Quantity` The theta_x coordinate for this object. Not needed if ``data`` is given. Ty : `~astropy.coordinates.Angle` or `~astropy.units.Quantity` The theta_y coordinate for this object. Not needed if ``data`` is given. distance : `~astropy.units.Quantity` The distance coordinate from the observer for this object. Not needed if ``data`` is given. {observer} rsun : `~astropy.units.Quantity` The physical (length) radius of the Sun. Used to calculate the position of the limb for calculating distance from the observer to the coordinate. Defaults to the solar radius. {common} Examples -------- >>> from astropy.coordinates import SkyCoord >>> import sunpy.coordinates >>> import astropy.units as u >>> sc = SkyCoord(0*u.deg, 0*u.deg, 5*u.km, ... obstime="2010/01/01T00:00:00", observer="earth", frame="helioprojective") >>> sc <SkyCoord (Helioprojective: obstime=2010-01-01T00:00:00.000, rsun=695700.0 km, observer=<HeliographicStonyhurst Coordinate for 'earth'>): (Tx, Ty, distance) in (arcsec, arcsec, km) (0., 0., 5.)> >>> sc = SkyCoord(0*u.deg, 0*u.deg, ... obstime="2010/01/01T00:00:00", observer="earth", frame="helioprojective") >>> sc <SkyCoord (Helioprojective: obstime=2010-01-01T00:00:00.000, rsun=695700.0 km, observer=<HeliographicStonyhurst Coordinate for 'earth'>): (Tx, Ty) in arcsec (0., 0.)> >>> sc = SkyCoord(CartesianRepresentation(1*u.AU, 1e5*u.km, -2e5*u.km), ... obstime="2011/01/05T00:00:50", observer="earth", frame="helioprojective") >>> sc <SkyCoord (Helioprojective: obstime=2011-01-05T00:00:50.000, rsun=695700.0 km, observer=<HeliographicStonyhurst Coordinate for 'earth'>): (Tx, Ty, distance) in (arcsec, arcsec, AU) (137.87948623, -275.75878762, 1.00000112)> """ default_representation = SphericalRepresentation frame_specific_representation_info = { SphericalRepresentation: [ RepresentationMapping(reprname='lon', framename='Tx', defaultunit=u.arcsec), RepresentationMapping(reprname='lat', framename='Ty', defaultunit=u.arcsec), RepresentationMapping(reprname='distance', framename='distance', defaultunit=None) ], UnitSphericalRepresentation: [ RepresentationMapping(reprname='lon', framename='Tx', defaultunit=u.arcsec), RepresentationMapping(reprname='lat', framename='Ty', defaultunit=u.arcsec) ], } rsun = Attribute(default=_RSUN.to(u.km)) observer = ObserverCoordinateAttribute(HeliographicStonyhurst) def make_3d(self): """ This method calculates the third coordinate of the Helioprojective frame. It assumes that the coordinate point is on the surface of the Sun. If a point in the frame is off limb then NaN will be returned. Returns ------- new_frame : `~sunpy.coordinates.frames.Helioprojective` A new frame instance with all the attributes of the original but now with a third coordinate. """ # Skip if we already are 3D distance = self.spherical.distance if not (distance.unit is u.one and u.allclose(distance, 1 * u.one)): return self if not isinstance(self.observer, BaseCoordinateFrame): raise ConvertError("Cannot calculate distance to the Sun " f"for observer '{self.observer}' " "without `obstime` being specified.") rep = self.represent_as(UnitSphericalRepresentation) lat, lon = rep.lat, rep.lon alpha = np.arccos(np.cos(lat) * np.cos(lon)).to(lat.unit) c = self.observer.radius**2 - self.rsun**2 b = -2 * self.observer.radius * np.cos(alpha) # Ingore sqrt of NaNs with np.errstate(invalid='ignore'): d = ((-1 * b) - np.sqrt(b**2 - 4 * c)) / 2 return self.realize_frame( SphericalRepresentation(lon=lon, lat=lat, distance=d)) # Support the previous name for make_3d for now calculate_distance = deprecated('1.1', name="calculate_distance", alternative="make_3d")(make_3d)
This module provides Sun-related parameters. """ from sunpy.coordinates import sun as _sun from sunpy.util.decorators import deprecated __all__ = [ "solar_semidiameter_angular_size", "position", "carrington_rotation_number", "true_longitude", "apparent_longitude", "true_latitude", "apparent_latitude", "mean_obliquity_of_ecliptic", "true_rightascension", "true_declination", "true_obliquity_of_ecliptic", "apparent_rightascension", "apparent_declination", "print_params" ] # The names for the functions in sunpy.coordinates.sun _new_module = 'sunpy.coordinates.sun.' _new_names = [ "angular_radius", "sky_position", "carrington_rotation_number", "true_longitude", "apparent_longitude", "true_latitude", "apparent_latitude", "mean_obliquity_of_ecliptic", "true_rightascension", "true_declination", "true_obliquity_of_ecliptic", "apparent_rightascension", "apparent_declination", "print_params" ] # Create a deprecation hook for each of the functions for old, new in zip(__all__, _new_names): vars()[old] = deprecated('1.0', name=old, alternative=_new_module + new)(getattr(_sun, new)) vars( )[old].__module__ = __name__ # so that docs think that the function is local
# -*- coding: utf-8 -*- from sunpy.util.decorators import deprecated from sunpy.visualization.animator.mapsequenceanimator import MapSequenceAnimator __all__ = ['MapCubeAnimator'] MapCubeAnimator = deprecated( "0.9.1", message='MapCubeAnimator deprecated in favor of MapSequenceAnimator. \ MapSequence has the same functionality as MapCube.' )(MapSequenceAnimator)