Coordinate Systems

Transformations

pyspedas.cotrans(name_in=None, name_out=None, time_in=None, data_in=None, coord_in=None, coord_out=None)

Transform data from coord_in to coord_out.

Parameters
  • name_in (str, optional) – Pytplot name for input data.

  • name_out (str, optional) – Pytplot name for output data.

  • time_in (list of float, optional) – Time array. Ignored if name_in is provided.

  • data_in (list of float, optional) – Data in the coord_in system. Ignored if name_in is provided.

  • coord_in (str) – Name of input coordinate system.

  • coord_out (str) – Name of output coordinate system.

Returns

Fills a new pytplot variable with data in the coord_out system.

Return type

Returns 1 for successful completion.

Examples

import pyspedas
pyspedas.themis.state(trange=['2015-10-16', '2015-10-17'], probe='c')

from pyspedas import cotrans
cotrans(name_in='thc_pos_gse', name_out='gsm_data', coord_in='gse', coord_out='gsm')
cotrans(name_in='thc_pos_gse', name_out='sm_data', coord_in='gse', coord_out='sm')
cotrans(name_in='thc_pos_gse', name_out='geo_data', coord_in='gse', coord_out='geo')

from pytplot import tplot
tplot(['gsm_data', 'sm_data', 'geo_data'])

LMN Coordinates

pyspedas.cotrans.gsm2lmn.gsm2lmn(times, Rxyz, Bxyz, swdata=None)

Transforms vector field from GSM to LMN (boundary-normal) coordinate system for the magnetopause using the Shue et al. (1998) magnetopause model

Getting/Setting the Coordinate System

pyspedas.cotrans_get_coord(name)

This function returns the coordinate system of a tplot variable

Parameters

name – str name of the tplot variable

Notes

The coordinate system is stored in the variable’s metadata at:

metadata[‘data_att’][‘coord_sys’]

See cotrans_set_coord to update the coordinate system

Returns

Coordinate system of the tplot variable or None if the coordinate system isn’t set

pyspedas.cotrans_set_coord(name, coord)

This function sets the coordinate system of a tplot variable

Parameters

name – str name of the tplot variable

Notes

The coordinate system is stored in the variable’s metadata at:

metadata[‘data_att’][‘coord_sys’]

See cotrans_get_coord to return the coordinate system

Returns

True/False depending on if the operation was successful

Return type

bool

Support Routines

pyspedas.cotrans.cotrans_lib.get_time_parts(time_in)

Split time into year, doy, hours, minutes, seconds.fsec.

Parameters

time_in (list of float) – Time array.

Returns

  • iyear (array of int) – Year.

  • idoy (array of int) – Day of year.

  • ih (array of int) – Hours.

  • im (array of int) – Minutes.

  • isec (array of float) – Seconds and milliseconds.

pyspedas.cotrans.cotrans_lib.csundir_vect(time_in)

Calculate the direction of the sun.

Parameters

time_in (list of float) – Time array.

Returns

  • gst (list of float) – Greenwich mean sideral time (radians).

  • slong (list of float) – Longitude along ecliptic (radians).

  • sra (list of float) – Right ascension (radians).

  • sdec (list of float) – Declination of the sun (radians).

  • obliq (list of float) – Inclination of Earth’s axis (radians).

pyspedas.cotrans.cotrans_lib.cdipdir(time_in=None, iyear=None, idoy=None)

Compute dipole direction in GEO coordinates.

Parameters
Return type

list of float

Notes

Compute geodipole axis direction from International Geomagnetic Reference Field (IGRF-13) model for time interval 1970 to 2020. For time out of interval, computation is made for nearest boundary. Same as SPEDAS cdipdir.

pyspedas.cotrans.cotrans_lib.cdipdir_vect(time_in=None, iyear=None, idoy=None)

Compute dipole direction in GEO coordinates.

Similar to cdipdir but for arrays.

Parameters
Return type

list of float

Notes

Same as SPEDAS cdipdir_vec.

pyspedas.cotrans.cotrans_lib.tgeigse_vect(time_in, data_in)

GEI to GSE transformation.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – xgei, ygei, zgei cartesian GEI coordinates.

Returns

  • xgse (list of float) – Cartesian GSE coordinates.

  • ygse (list of float) – Cartesian GSE coordinates.

  • zgse (list of float) – Cartesian GSE coordinates.

pyspedas.cotrans.cotrans_lib.subgei2gse(time_in, data_in)

Transform data from GEI to GSE.

Parameters
Returns

Coordinates in GSE.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.tgsegei_vect(time_in, data_in)

GSE to GEI transformation.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – xgei, ygei, zgei cartesian GEI coordinates.

Returns

  • xgei (list of float) – Cartesian GEI coordinates.

  • ygei (list of float) – Cartesian GEI coordinates.

  • zgei (list of float) – Cartesian GEI coordinates.

pyspedas.cotrans.cotrans_lib.subgse2gei(time_in, data_in)

Transform data from GSE to GEI.

Parameters
Returns

Coordinates in GEI.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.tgsegsm_vect(time_in, data_in)

Transform data from GSE to GSM.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – xgse, ygse, zgse cartesian GSE coordinates.

Returns

  • xgsm (list of float) – Cartesian GSM coordinates.

  • ygsm (list of float) – Cartesian GSM coordinates.

  • zgsm (list of float) – Cartesian GSM coordinates.

pyspedas.cotrans.cotrans_lib.subgse2gsm(time_in, data_in)

Transform data from GSE to GSM.

Parameters
Returns

Coordinates in GSM.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.tgsmgse_vect(time_in, data_in)

Transform data from GSM to GSE.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – xgsm, ygsm, zgsm GSM coordinates.

Returns

  • xgse (list of float) – Cartesian GSE coordinates.

  • ygse (list of float) – Cartesian GSE coordinates.

  • zgse (list of float) – Cartesian GSE coordinates.

pyspedas.cotrans.cotrans_lib.subgsm2gse(time_in, data_in)

Transform data from GSM to GSE.

Parameters
Returns

Coordinates in GSE.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.tgsmsm_vect(time_in, data_in)

Transform data from GSM to SM.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – xgsm, ygsm, zgsm GSM coordinates.

Returns

  • xsm (list of float) – Cartesian SM coordinates.

  • ysm (list of float) – Cartesian SM coordinates.

  • zsm (list of float) – Cartesian SM coordinates.

pyspedas.cotrans.cotrans_lib.subgsm2sm(time_in, data_in)

Transform data from GSM to SM.

Parameters
Returns

Coordinates in SM.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.tsmgsm_vect(time_in, data_in)

Transform data from SM to GSM.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – xsm, ysm, zsm SM coordinates.

Returns

pyspedas.cotrans.cotrans_lib.subsm2gsm(time_in, data_in)

Transform data from SM to GSM.

Parameters
Returns

Coordinates in GSM.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.subgei2geo(time_in, data_in)

Transform data from GEI to GEO.

Parameters
Returns

Coordinates in GEO.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.subgeo2gei(time_in, data_in)

Transform data from GEO to GEI.

Parameters
Returns

Coordinates in GEI.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.subgeo2mag(time_in, data_in)

Transform data from GEO to MAG.

Parameters
Returns

Coordinates in MAG.

Return type

Array of float

Notes

Adapted from spedas IDL file geo2mag.pro.

pyspedas.cotrans.cotrans_lib.submag2geo(time_in, data_in)

Transform data from MAG to GEO.

Parameters
Returns

Coordinates in GEO.

Return type

Array of float

Notes

Adapted from spedas IDL file mag2geo.pro.

pyspedas.cotrans.cotrans_lib.ctv_mm_mult(m1, m2)

Vectorized multiplication of two lists of 3x3 matrices.

Parameters
  • m1 (array of float) – Array (3, 3, n). List of n 3x3 matrices.

  • m2 (array of float) – Array (3, 3, n). List of n 3x3 matrices.

Returns

Array (3, 3, n). List of n 3x3 matrices.

Return type

Array of float

Notes

Adapted from spedas IDL file matrix_array_lib.pro.

pyspedas.cotrans.cotrans_lib.j2000_matrix_vec(time_in)

Get the conversion matrix for J2000 coordinates.

Gives a matrix that transforms from mean earth equator and equinox of J2000 into the true earth equator and equinox for the dates and times.

Parameters

time_in (list of float) – Time array.

Returns

Transformation matrix.

Return type

Matrix of float

Notes

Adapted from spedas IDL file spd_make_j2000_matrix_vec.pro.

pyspedas.cotrans.cotrans_lib.ctv_mx_vec_rot(m, v)

Vectorized multiplication of n matrices by n vectors.

Parameters
  • m (array of float) – Array (k, k, n). List of n kxk matrices. Unually, it is 3x3 matrices, ie. k=3.

  • v (array of float) – Array (n, k). List of n vectors.

Returns

Array (n, k). List of n vectors.

Return type

Array of float

Notes

Adapted from spedas IDL file matrix_array_lib.pro.

pyspedas.cotrans.cotrans_lib.subgei2j2000(time_in, data_in)

Transform data from GEI to J2000.

Parameters
Returns

Coordinates in J2000.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.subj20002gei(time_in, data_in)

Transform data from J2000 to GEI.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – Coordinates in J2000.

Returns

Coordinates in GEI.

Return type

Array of float

pyspedas.cotrans.cotrans_lib.subcotrans(time_in, data_in, coord_in, coord_out)

Transform data from coord_in to coord_out.

Calls the other sub functions in this file.

Parameters
  • time_in (list of float) – Time array.

  • data_in (list of float) – Coordinates in coord_in.

  • coord_in (string) – One of GSE, GSM, SM, GEI, GEO, MAG, J2000.

  • coord_out (string) – One of GSE, GSM, SM, GEI, GEO, MAG, J2000.

Returns

Coordinates in coord_out.

Return type

Array of float