from sunpy.coordinates import frames from astropy.coordinates import * # Sorry for * import, heh from astropy import units as u sc = SkyCoord(1*u.deg, 1*u.deg, 3*u.km, frame='heliographicstonyhurst', dateobs='2011/01/01T00:00:45') print(sc) print(sc.frame) print(sc.hlon) # An attribute of the representation of frame. print(sc.dateobs) # A FrameAttribute derived attribute of the frame. sc2 = SkyCoord(CartesianRepresentation(1*u.km, 1*u.km, 1*u.km), frame='heliographicstonyhurst', dateobs='2011/01/01T00:00:45') print(sc2) # note how it prints in default representation. print(sc2.represent_as(CartesianRepresentation)) # close to our original parameters. print(sc2.represent_as(CylindricalRepresentation)) # why? because I can. sc_setrepr = SkyCoord(1*u.deg, 1*u.deg, frame='heliographicstonyhurst', dateobs='2011/01/01T00:00:45') sc_setrepr.representation = 'cartesian' # this changes the representation in which the SkyCoord object is printed, but does *not* change the underlying default rep. # Doing sc.x/sc.y/sc.z would yield an error. print(sc_setrepr) print(sc.transform_to('heliographiccarrington')) print(sc.transform_to('heliocentric')) print(sc.transform_to('helioprojective')) print(sc.transform_to('heliographicstonyhurst')) import numpy.testing as npt sc3 = sc.transform_to('heliocentric').transform_to('helioprojective').transform_to('heliographicstonyhurst') print('\n') print((sc.hlon, sc3.hlon)) print((sc.hlat, sc3.hlat)) print((sc.rad, sc3.rad)) # Values are close. sc = SkyCoord(1*u.deg, 1*u.deg, frame='heliographicstonyhurst', dateobs='2011/01/01T00:00:45') print(sc) # note how rad and L0,B0 magically appear. from sunpy.coordinates.frames import HelioProjective frame = SkyCoord(HelioProjective(1*u.deg, 1*u.deg, zeta=1*u.km, dateobs='2012/02/02T00:00:50')) print(frame) # unfortunately, as zeta is a frame property object, SkyCoord cannot recognize it firsthand. sc = SkyCoord([1,2,3]*u.deg, [3,2,1]*u.deg, [1,1,1]*u.km, frame='heliographicstonyhurst', dateobs='2011/01/01T00:00:45') # cool array type inputs print(sc) print(sc2.position_angle(sc3)) # calculates the position angle between this SkyCoord and another. print(sc.separation(sc3)) # calculates on-sky separation. Extra keyword args such as 'dateobs' must be the same in both SkyCoords. print(sc.separation_3d(sc3)) # calculates the 3D separation. Can not be used on 2D frames. Keywordargs condition applies.