spacepy.coordinates.Coords

class spacepy.coordinates.Coords(data, dtype, carsph[, units, ticks])[source]

A class holding spatial coordinates in Cartesian/spherical in units of Re and degrees

Note

Although other units may be specified and will be carried through, most functions throughout SpacePy assume distances in Re and angles in degrees, regardless of specified units.

Coordinate transforms are based on the IRBEM library; its manual may prove useful. For a good reference on heliospheric and magnetospheric coordinate systems, see Franz & Harper, “Heliospheric Coordinate Systems”, Planet. Space Sci., 50, pp 217-233, 2002 (https://doi.org/10.1016/S0032-0633(01)00119-2).

Parameters
datalist or ndarray, dim = (n,3)

coordinate points [X,Y,Z] or [rad, lat, lon]

dtypestring

coordinate system; possible values are:

  • GDZ (Geodetic; WGS84),

  • GEO (Geographic Coordinate System),

  • GSM (Geocentric Solar Magnetospheric),

  • GSE (Geocentric Solar Ecliptic),

  • SM (Solar Magnetic),

  • GEI (Geocentric Equatorial Inertial; True-of-Date),

  • MAG (Geomagnetic Coordinate System),

  • SPH (Spherical Coordinate System),

  • RLL (Radius, Latitude, Longitude; Geodetic)

carsphstring

Cartesian or spherical, ‘car’ or ‘sph’

unitslist of strings, optional

standard are [‘Re’, ‘Re’, ‘Re’] or [‘Re’, ‘deg’, ‘deg’] depending on the carsph content. See note.

ticksTicktock instance, optional

used for coordinate transformations (see a.convert)

Returns
outCoords instance

instance with a.data, a.carsph, etc.

Examples

>>> from spacepy import coordinates as coord
>>> cvals = coord.Coords([[1,2,4],[1,2,2]], 'GEO', 'car')
>>> cvals.x  # returns all x coordinates
array([1, 1])
>>> from spacepy.time import Ticktock
>>> cvals.ticks = Ticktock(['2002-02-02T12:00:00', '2002-02-02T12:00:00'], 'ISO') # add ticks
>>> newcoord = cvals.convert('GSM', 'sph')
>>> newcoord

append(other)

Append another Coords instance to the current one

convert(returntype, returncarsph)

Create a new Coords instance with new coordinate types

from_skycoord(skycoord)

Create a Coords instance from an Astropy SkyCoord instance

append(other)[source]

Append another Coords instance to the current one

Parameters
otherCoords instance

Coords instance to append

convert(returntype, returncarsph)[source]

Create a new Coords instance with new coordinate types

Parameters
returntypestring

coordinate system, possible are GDZ, GEO, GSM, GSE, SM, GEI, MAG, SPH, RLL

returncarsphstring

coordinate type, possible ‘car’ for Cartesian and ‘sph’ for spherical

Returns
outCoords object

Coords object in the new coordinate system

Examples

>>> from spacepy.coordinates import Coords
>>> y = Coords([[1,2,4],[1,2,2]], 'GEO', 'car')
>>> from spacepy.time import Ticktock
>>> y.ticks = Ticktock(['2002-02-02T12:00:00', '2002-02-02T12:00:00'], 'ISO')
>>> x = y.convert('SM','car')
>>> x
Coords( [[ 0.81134097  2.6493305   3.6500375 ]
 [ 0.92060408  2.30678864  1.68262126]] ), dtype=SM,car, units=['Re', 'Re', 'Re']
classmethod from_skycoord(skycoord)[source]

Create a Coords instance from an Astropy SkyCoord instance

Parameters
skycoordastropy.coordinates.SkyCoord

The coordinate to be converted

Returns
outCoords instance

The converted coordinate

Notes

This method requires Astropy to be installed.

This method uses the GEO coordinate frame as the common frame between the two libraries.

to_skycoord()[source]

Create an Astropy SkyCoord instance based on this instance

Returns
outastropy.coordinates.SkyCoord

This coordinate as an Astropy SkyCoord

Notes

This method requires Astropy to be installed.

This method uses the GEO coordinate frame as the common frame between the two libraries.