This page was created by the IDL library routine `mk_html_help2`.

Last modified: Sun Oct 19 03:17:44 2025.

# Directory Listing of Routines

# general/cotrans

- AGSM2GSE
- COTRANS
- COTRANS_GET_COORD
- COTRANS_LIB[1]
- COTRANS_LIB[2]
- COTRANS_LIB[2]
- COTRANS_LIB[3]
- COTRANS_LIB[4]
- COTRANS_LIB[5]
- COTRANS_LIB[6]
- COTRANS_LIB[7]
- COTRANS_LIB[8]
- COTRANS_LIB[9]
- COTRANS_LIB[10]
- COTRANS_LIB[11]
- COTRANS_LIB[12]
- COTRANS_LIB[13]
- COTRANS_LIB[14]
- COTRANS_LIB[15]
- COTRANS_LIB[16]
- COTRANS_LIB[17]
- COTRANS_LIB[18]
- COTRANS_LIB[19]
- COTRANS_LIB[20]
- COTRANS_LIB[21]
- COTRANS_LIB[22]
- COTRANS_LIB[23]
- COTRANS_LIB[24]
- COTRANS_LIB[25]
- COTRANS_LIB[26]
- COTRANS_LIB[27]
- COTRANS_LIB[28]
- COTRANS_SET_COORD
- GEO2MAG
  Convert from geographic to geomagnetic coordinates
- GSE2AGSM
- HDZ2GEO
- MAG2GEO.PRO
  Convert from geomagnetic to geographic coordinates
- SM2MLT
  Converts a Cartesian vector in SM coordinates to Magnetic Local Time (MLT)
- SPD_COTRANS_UPDATE_DLIMITS
- SPD_COTRANS_VALIDATE_TRANSFORM
- SPD_GET_NUT_ANGLES_VEC
- SPD_MAKE_J2000_MATRIX_VEC
- SPD_SET_COORD
- SPG2SSL
- TGSM2MLT
  Allows a user to convert position data in a tplot variable

# Routine Descriptions

## AGSM2GSE

[Next Routine] [List of Routines]

     Procedure: agsm2gse

     Purpose:
          Converts between aberrated GSM coordinates and GSE coordinates

     Inputs:
          in_data: structure containing data to be transformed in AGSM coordinates

     Output:
          out_data: structure containing the transformed data in GSE coordinates

     Keywords:
          sw_velocity (optional): vector containing solar wind velocity data, [Vx, Vy, Vz] in GSE coordinates
          rotation_angle (optional): angle to rotate about the Z axis to point into the solar wind (degrees)

     Notes:
         Either the solar wind velocity (/sw_velocity) or rotation angle (/rotation_angle) keyword
         needs to be defined to do the transformation

     Examples:
        In the following example, the data to be transformed into GSE coordinates
          is in a standard tplot variable named 'position_agsm'.

        get_data, 'position_agsm', data=position_agsm

        ; load solar wind velocity data using OMNI (GSE coordinates, km/s)
        omni_hro_load, varformat=['Vx', 'Vy', 'Vz']

        ; remove NaNs from the solar wind velocity
        tdeflag, ['OMNI_HRO_1min_Vx', 'OMNI_HRO_1min_Vy', 'OMNI_HRO_1min_Vz'], 'remove_nan'

        ; get the IDL structures containing the velocity components
        get_data, 'OMNI_HRO_1min_Vx_deflag', data=Vx_data
        get_data, 'OMNI_HRO_1min_Vy_deflag', data=Vy_data
        get_data, 'OMNI_HRO_1min_Vz_deflag', data=Vz_data

        option 1:
            ; do the transformation to aberrated GSM (aGSM) using a rotation angle
            agsm2gse, position_agsm, gse_pos_from_angle, rotation_angle=4.0

        option 2:
            ; do the transformation to aberrated GSM (aGSM) using solar wind velocity loaded from OMNI
            agsm2gse, position_agsm, gse_pos_from_vel, sw_velocity = [[Vx_data.Y], [Vy_data.Y], [Vz_data.Y]]

     $LastChangedBy: egrimes $
     $LastChangedDate: 2018-02-05 14:11:03 -0800 (Mon, 05 Feb 2018) $
     $LastChangedRevision: 24646 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/agsm2gse.pro $

(See general/cotrans/agsm2gse.pro)

## COTRANS

[Previous Routine] [Next Routine] [List of Routines]

    procedure: cotrans, name_in, name_out [, time]

    Purpose: geophysical coordinate transformations

             GEI<-->GSE;
             GSE<-->GSM;
             GSM<-->SM;
             GEI<-->GEO;
             GEO<-->MAG;
             GEI<-->J2000;

             interpolates the spinphase, right ascension, declination
             updates coord_sys attribute of output tplot variable.

    inputs

       name_in 	... data in the input coordinate system (t-plot variable name,
                                                            or array)
       name_out    ... variable name for output            (t-plot variable name,
                                                            or array)
       time        ... optional input: array of times for input values, if provided
                       then the first parameter is an array, and the second
                       parameter is a named variable to contain the output array.

    keywords:
       TRANSFORMATIONS

    	/GEI2GSE
    	/GSE2GEI

    	/GSE2GSM
    	/GSM2GSE

     /GSM2SM
     /SM2GSM

     /GEI2GEO
     /GEO2GEI

     /GEO2MAG
     /MAG2GEO

     /GEI2J2000
     /J20002GEI

     /IGNORE_DLIMITS: set so it won't require the coordinate
    system of the input tplot variable to match the coordinate
    system from which the data is being converted

    Examples:

          cotrans,'tha_fgl_gse','tha_fgl_gsm',/GSE2GSM
          cotrans,'tha_fgl_gsm','tha_fgl_gse',/GSM2GSE

          cotrans,'tha_fgl_gse','tha_fgl_gei',/GSE2GEI
          cotrans,'tha_fgl_gei','tha_fgl_gse',/GEI2GSE

          cotrans,'tha_fgl_gsm','tha_fgl_sm',/GSM2SM
          cotrans,'tha_fgl_sm','tha_fgl_gsm',/SM2GSM

    Notes: under construction!!
           clrussell, 03-30-12, added GEO2MAG and MAG2GEO conversions

    Written by: Hannes Schwarzl & Patrick Cruce(pcruce@igpp.ucla.edu)

     $LastChangedBy: egrimes $
     $LastChangedDate: 2015-09-22 08:59:06 -0700 (Tue, 22 Sep 2015) $
     $LastChangedRevision: 18869 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/cotrans.pro $

(See general/cotrans/cotrans.pro)

## COTRANS_GET_COORD

[Previous Routine] [Next Routine] [List of Routines]

    	Function: COTRANS_GET_COORD

    	Purpose:  determine the coordinate system of data by
                     examining the contents of it's DLIMIT structure.

    	Calling Sequence:
    		tplot_var = 'tha_eff'
    		get_data, tplot_var, data=d, limit=l, dlimit=dl
    		coord = cotrans_get_coord( dl)
                   ; -- or --
                   coord = cotrans_get_coord('tha_eff')

    	Arguements:
    		DL, Anonymous STRUCT, or tplot variable name.

    	Notes:
    		None.

     $LastChangedBy: kenb-mac $
     $LastChangedDate: 2007-05-01 15:11:55 -0700 (Tue, 01 May 2007) $
     $LastChangedRevision: 622 $
     $URL $

(See general/cotrans/cotrans_get_coord.pro)

## COTRANS_LIB[10]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGSE2GEI

    Purpose: transforms data from GSE to GEI

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!  will run faster in the near future!!
     $URL $

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[11]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGSE2GSM

    Purpose: transforms data from GSE to GSM

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!  will run faster in the near future!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[12]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGSM2GSE

    Purpose: transforms data from GSM to GSE

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!  will run faster in the near future!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[13]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGSM2SM

    Purpose: transforms data from GSM to SM

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[14]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subSM2GSM

    Purpose: transforms data from SM to GSM

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[15]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGEI2GEO

    Purpose: transforms data from GEI to GEO

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[16]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGEO2GEI

    Purpose: transforms data from GEO to GEI

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[17]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subGEO2MAG

    Purpose: transforms data from GEO to MAG

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[18]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subMAG2GEO

    Purpose: transforms data from MAG to GEO

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[19]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: csundir_vect

    Purpose: calculates the direction of the sun
             (vectorized version of csundir from ROCOTLIB by
              Patrick Robert)

    INPUTS: integer time

    output :      gst      greenwich mean sideral time (radians)
                  slong    longitude along ecliptic (radians)
                  sra      right ascension (radians)
                  sdec     declination of the sun (radians)
                  obliq    inclination of Earth's axis (radians)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[1]

[Previous Routine] [Next Routine] [List of Routines]

    pro sub_GSE2aGSM

    Purpose: transforms data from GSE to aberrated GSM coordinates

    keywords:
       /aGSM2GSE : inverse transformation
    Example:
          sub_GSE2aGSM,tha_fglc_gse,tha_fglc_agsm

          sub_GSE2aGSM,tha_fglc_agsm,tha_fglc_gse,/aGSM2GSE

    Notes: Same as sub_GSE2GSM, with "aberrated GSM" in the output message. The actual aberration
           occurs in the higher level routine, gse2agsm

     $LastChangedBy: nikos $
     $LastChangedDate: 2025-02-27 20:48:10 -0800 (Thu, 27 Feb 2025) $
     $LastChangedRevision: 33158 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/cotrans_lib.pro $

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[20]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: tgeigse_vect

    Purpose: GEI to GSE transformation
             (vectorized version of tgeigse from ROCOTLIB by
              Patrick Robert)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[21]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: tgsegei_vect

    Purpose: GSE to GEI transformation
             (vectorized version of tgsegei from ROCOTLIB by
              Patrick Robert)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[22]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: tgsegsm_vect

    Purpose: GSE to GSM transformation
             (vectorized version of tgsegsm from ROCOTLIB by
              Patrick Robert)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[23]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: tgsmgse_vect

    Purpose: GSM to GSE transformation
             (vectorized version of tgsmgse from ROCOTLIB by
              Patrick Robert)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[24]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: tgsmsm_vect

    Purpose: GSM to SM transformation
             (vectorized version of tgsmsma from ROCOTLIB by
              Patrick Robert)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[25]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: tsmgsm_vect

    Purpose: SM to GSM transformation
             (vectorized version of tsmagsm from ROCOTLIB by
              Patrick Robert)

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[26]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: cdipdir_vect

    Purpose: calls cdipdir from ROCOTLIB in a vectorized environment

    Notes: under construction!!;
     faster algorithm (for loop across all points avoided) Hannes 05/25/2007

     $URL $

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[27]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: cdipdir

    Purpose: cdipdir from ROCOTLIB. direction of Earth's magnetic axis in GEO

    Notes: under construction!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[28]

[Previous Routine] [Next Routine] [List of Routines]

     PROCEDURE cotrans_lib
       Loads the cotrans_lib library and sets configurations.

     USAGE
       Call cotrans_lib at the beginning of any routine
       that needs to use any cotrans_lib routines, to ensure
       that they are compiled.  Configurations are valid until the next call
       to cotrans_lib.

     KEYWORDS
        /nolimit_igrf configure cotrans_lib to remove the arbitrary
                      5-year limit on extrapolation of IGRF model.
                      This also isolates dprint code.
                      NOTE: the configuration will be reset
                      to 0 if cotrans_lib is called without keywords.  This is
                      for backwards compatibility:  any routine that calls
                      cotrans_lib without keywords will get the standard behavior,
                      regardless of how cotrans_lib was previously configured.

                      Note: Use this keyword at your own risk - extrapolating
                      these coefficients too far into the future can produce
                      non-physical results

      Written by Hannes Leinweber
      Modified by Ken Bromund: added /nolimit_igrf configuration

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[2]

[Previous Routine] [Next Routine] [List of Routines]

    pro sub_GSE2GSM

    Purpose: transforms data from GSE to GSM

    keywords:
       /GSM2GSE : inverse transformation
    Example:
          sub_GSE2GSM,tha_fglc_gse,tha_fglc_gsm

          sub_GSE2GSM,tha_fglc_gsm,tha_fglc_gse,/GSM2GSE

    Notes: under construction!!  will run faster in the near future!!

    Written by Hannes Schwarzl

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[2]

[Previous Routine] [Next Routine] [List of Routines]

    pro: sub_GEI2GSE

    Purpose: transforms THEMIS fluxgate magnetometer data from GEI to GSE

    keywords:
       /GSE2GEI : inverse transformation
    Example:
          sub_GEI2GSE,tha_fglc_gei,tha_fglc_gse

          sub_GEI2GSE,tha_fglc_gse,tha_fglc_gei,/GSE2GEI

    Notes: under construction!!  will run faster in the near future!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[3]

[Previous Routine] [Next Routine] [List of Routines]

    pro sub_GSM2SM

    Purpose: transforms data from GSM to SM

    keywords:
       /SM2GSM : inverse transformation
    Example:
          sub_GSM2SM,tha_fglc_gsm,tha_fglc_sm

          sub_GSM2SM,tha_fglc_sm,tha_fglc_gsm,/SM2GSM

    Notes: under construction!!  will run faster in the near future!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[4]

[Previous Routine] [Next Routine] [List of Routines]

    pro sub_GEI2GEO

    Purpose: transforms data from GEI to GEO

    keywords:
       /GEO2GEI : inverse transformation
    Example:
          sub_GEI2GEO,tha_fglc_gei,tha_fglc_geo

          sub_GEI2GEO,tha_fglc_geo,tha_fglc_gei,/GEO2GEI

    Notes:

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[5]

[Previous Routine] [Next Routine] [List of Routines]

    pro sub_GEO2MAG

    Purpose: transforms data from GEO to MAG

    keywords:
       /MAG2GEO : inverse transformation
    Example:
          sub_GEO2MAG,tha_fglc_geo,tha_fglc_mag

          sub_GEO2MAG,tha_fglc_mag,tha_fglc_geo,/MAG2GEO

    Notes:

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[6]

[Previous Routine] [Next Routine] [List of Routines]

    proceddure: subGEI2J2000

    Purpose: transforms data from GEI TOD to J2000

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[7]

[Previous Routine] [Next Routine] [List of Routines]

    procedure: subJ20002GEI

    Purpose: transforms data from J2000 to GEI TOD

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[8]

[Previous Routine] [Next Routine] [List of Routines]

    pro: sub_GEI2J2000

    Purpose: transforms data from GEI to J2000

    keywords:
       /J20002GEI : inverse transformation

(See general/cotrans/cotrans_lib.pro)

## COTRANS_LIB[9]

[Previous Routine] [Next Routine] [List of Routines]

    proceddure: subGEI2GSE

    Purpose: transforms data from GEI to GSE

    INPUTS: TIMES as time_struct, DATA_in as nx3 array

    keywords:

    Example:

    Notes: under construction!!  will run faster in the near future!!

(See general/cotrans/cotrans_lib.pro)

## COTRANS_SET_COORD

[Previous Routine] [Next Routine] [List of Routines]

    	Function: COTRANS_SET_COORD

    	Purpose:  set the coordinate system of data by
                     setting the data_att structure of its DLIMIT structure.

    	Calling Sequence:
    		tplot_var = 'tha_eff'
    		get_data, tplot_var, data=d, limit=l, dlimit=dl
    		coord = cotrans_set_coord, dl, 'gei'
    		store_data, tplot_var, data=d, limit=l, dlimit=dl

    	Arguements:
    		DL, Anonymous STRUCT.

    	Notes:
    		None.

     $LastChangedBy: kenb-mac $
     $LastChangedDate: 2007-08-01 22:08:30 -0700 (Wed, 01 Aug 2007) $
     $LastChangedRevision: 1318 $
     $URL $

(See general/cotrans/cotrans_set_coord.pro)

## GEO2MAG

[Previous Routine] [Next Routine] [List of Routines]

     NAME:
           geo2mag

     PURPOSE:
           Convert from geographic to geomagnetic coordinates

     CALLING SEQUENCE:
           geo2mag, data_in, data_out, time

     INPUT:
           time = an array [n] of double precision time in seconds from 1970-Jan-01/00:00:00.000
           data_in = an array [n,3] of position data in km. in GEO coordinates or a tplot variable

     KEYWORD INPUTS:
           None

     OUTPUT:
           data_out = an array [n,3] of the input data in MAG coordinates

     EXAMPLE:
        if data_in is a tplot variable:
           IDL> geo2mag, data_in, data_out
        otherwise:
           IDL> geo2mag, data_in, data_out, time

     NOTES:

           The algorithm and rotational matrices were developed by Pascal Saint-Hilaire
           (Saint-Hilaire@astro.phys.ethz.ch), May 2002

     MODIFICATION HISTORY:

(See general/cotrans/geo2mag.pro)

## GSE2AGSM

[Previous Routine] [Next Routine] [List of Routines]

     Procedure: gse2agsm

     Purpose:
          Converts between GSE coordinates and aberrated GSM coordinates

     Inputs:
          in_data: structure containing data to be transformed in GSE coordinates

     Output:
          out_data: structure containing the transformed data in aberrated GSM coordinates

     Keywords:
          sw_velocity (optional): vector containing solar wind velocity data, [Vx, Vy, Vz] in GSE coordinates
          rotation_angle (optional): angle to rotate about the Z axis to point into the solar wind (degrees)

     Notes:
         Either the solar wind velocity (/sw_velocity) or rotation angle (/rotation_angle) keyword
         needs to be defined to do the transformation

     Examples:
        In the following example, the data to be transformed into aGSM coordinates
          is in a standard tplot variable named 'position_gse'.

        get_data, 'position_gse', data=position_gse

        ; load solar wind velocity data using OMNI (GSE coordinates, km/s)
        omni_hro_load, varformat=['Vx', 'Vy', 'Vz']

        ; remove NaNs from the solar wind velocity
        tdeflag, ['OMNI_HRO_1min_Vx', 'OMNI_HRO_1min_Vy', 'OMNI_HRO_1min_Vz'], 'remove_nan'

        ; get the IDL structures containing the velocity components
        get_data, 'OMNI_HRO_1min_Vx_deflag', data=Vx_data
        get_data, 'OMNI_HRO_1min_Vy_deflag', data=Vy_data
        get_data, 'OMNI_HRO_1min_Vz_deflag', data=Vz_data

        option 1:
            ; do the transformation to aberrated GSM (aGSM) using a rotation angle
            gse2agsm, position_gse, agsm_pos_from_angle, rotation_angle=4.0

        option 2:
            ; do the transformation to aberrated GSM (aGSM) using solar wind velocity loaded from OMNI
            gse2agsm, position_gse, agsm_pos_from_vel, sw_velocity = [[Vx_data.Y], [Vy_data.Y], [Vz_data.Y]]

     $LastChangedBy: egrimes $
     $LastChangedDate: 2018-02-05 14:11:03 -0800 (Mon, 05 Feb 2018) $
     $LastChangedRevision: 24646 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/gse2agsm.pro $

(See general/cotrans/gse2agsm.pro)

## HDZ2GEO

[Previous Routine] [Next Routine] [List of Routines]

    procedure: hdz2geo

    Purpose: Coordinate transformation between HDZ coordinates & GEO coordinates

         HDZ is defined as:

           H = horizontal field strength, in the plane formed by Z and GEO graphic north
           D = field strength in the Z x X direction in nT
           Z = downward field strength

         H should be a projection onto a basis vector pointing north from station in nT
         D should be a projection onto a basis vector perpendicular to H in the horizontal plane.

         Total field strength should be sqrt(H^2+D^2+Z^2) not sqrt(H^2+Z^2)
         D must be in nT not degrees

         GEO is defined as:
             X = Vector parallel to vector pointing outward at the intersection of the equatorial plane and the 0 degree longitudinal meridean(Greenwich Meridean)
             Y = Z x X
             Z = Vector parallel to orbital Axis of Earth Pointing northward.

    inputs:

      data_in:
        Name of input tplot variable to be transformed, or Nx3 array of data for transformation. If no tplot variable is specific latitude and longitude must be set.
      data_out:
        Name of tplot variable in which to store output.  If this is a named variable and not a string, output data will instead be returned in variable.
      latitude: latitude of the HDZ station, must be set if data_in is not tplot variable, or latitude and longitude not stored in dlimit.data_att or dlimit.cdf.vatt
      longitude: longitude of the HDZ station, must be set if data_in is not tplot variable, or latitude and longitude not stored in dlimit.data_att or dlimit.cdf.vatt
      geo2hdz: If set, performs inverse transformation from GEO to HDZ
      error: Set to named variable that will return 1 if an error occurs and 0 otherwise
      rotation_matrix:  Returns the rotation matrix that will be used to transform

    keywords:

       /SSE2GSE inverse transformation

       /IGNORE_DLIMITS: Dlimits normally used to determine if coordinate
       system is correct, to decide if position needs offset, or to
       stop incorrect transforms.  This option will stop this behavior.

    Examples:
      hdz2geo,hdz_arr_in,geo_arr_out,latitude=60.4,longitude=173.6
      hdz2geo,'in_tvar_name_hdz','out_tvar_name_geo'
      hdz2geo,'in_tvar_name_geo','out_tvar_name_hdz',/geo2hdz  ;inverse transformation

    Notes:
       #1 HDZ coordinates only make sense relative to a location, assumedly a ground station(gmag)

       #2 Specific latitude and longitude keywords must be set if:
        (1) data_in is not a tplot variable name
        -OR-
        (2) tplot variable named by data_in does not specific site_latitude & site_longitude in dlimits

       #3 If latitude or longitude keywords are set, these values will be used, not dlimit values.

       #4 This transformation is a first order approximation.  It treats the earth as if it is a true sphere, ignoring
       distortions due to the fact that the earth is actually an oblate spheroid.

       Written by Patrick Cruce(pcruce@igpp.ucla.edu)

     $LastChangedBy: pcruce $
     $LastChangedDate: 2010-03-29 15:27:35 -0700 (Mon, 29 Mar 2010) $
     $LastChangedRevision: 7445 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/hdz2geo.pro $

(See general/cotrans/hdz2geo.pro)

## MAG2GEO.PRO

[Previous Routine] [Next Routine] [List of Routines]

     NAME:
          mag2geo.pro

     PURPOSE:
         Convert from geomagnetic to geographic coordinates

     CALLING SEQUENCE:
           mag2geo, data_in, data_out, time

     INPUT:
           data_in = an [n,3] element array of position data in km and in
                    MAG coordinates or a tplot variable

           time = an n-element array containing double precision time values
                  corresponding to the points in data_in

     KEYWORD INPUTS:
                   None

     OUTPUT:
           data_out = an [n,3] element array of position data in km in
                     newly transformed GEO coordinates

     EXAMPLE:
        if data_in is a tplot variable:
           IDL> mag2geo, data_in, data_out
        otherwise:
           IDL> mag2geo, data_in, data_out, time

     NOTES:

           The algorithm and rotational matrices were developed by Pascal Saint-Hilaire
           (Saint-Hilaire@astro.phys.ethz.ch), May 2002

     MODIFICATION HISTORY:

(See general/cotrans/mag2geo.pro)

## SM2MLT

[Previous Routine] [Next Routine] [List of Routines]

     FUNCTION:
        sm2mlt

     PURPOSE:
         Converts a Cartesian vector in SM coordinates to Magnetic Local Time (MLT)

     $LastChangedBy: egrimes $
     $LastChangedDate: 2016-01-21 13:42:42 -0800 (Thu, 21 Jan 2016) $
     $LastChangedRevision: 19770 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/sm2mlt.pro $

(See general/cotrans/sm2mlt.pro)

## SPD_COTRANS_UPDATE_DLIMITS

[Previous Routine] [Next Routine] [List of Routines]

    Procedure:
      spd_cotrans_update_dlimits

    Purpose:
      This routine will replace coordinate plot labels only in the dlimits.
      If the coordinate name is clearly delineated, so that it will not
      accidentally modify substrings that look like coordinate names

    Notes:

    $LastChangedBy: egrimes $
    $LastChangedDate: 2016-10-27 12:25:53 -0700 (Thu, 27 Oct 2016) $
    $LastChangedRevision: 22221 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/spd_cotrans_update_dlimits.pro $

(See general/cotrans/spd_cotrans_update_dlimits.pro)

## SPD_COTRANS_VALIDATE_TRANSFORM

[Previous Routine] [Next Routine] [List of Routines]

    Procedure:
      spd_cotrans_validate_transform

    Purpose:
      Helper function to call when moving to/from non-inertial frames.
      A warning is printed if the variables metadata denotes it as a velocity.

    Notes:

    $LastChangedBy: aaflores $
    $LastChangedDate: 2015-12-08 21:21:58 -0800 (Tue, 08 Dec 2015) $
    $LastChangedRevision: 19549 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/spd_cotrans_validate_transform.pro $

(See general/cotrans/spd_cotrans_validate_transform.pro)

## SPD_GET_NUT_ANGLES_VEC

[Previous Routine] [Next Routine] [List of Routines]

     SPD_GET_NUT_ANGLES_VEC

     Vectorized version of spd_get_nut_angles from spd_gei2j2000.pro

     History:
       2016-02-10 - Optimized to reduce memory spike for large data sets
                    (combined a few lines and added temporary() calls)

     $LastChangedBy: aaflores $
     $LastChangedDate: 2016-02-10 12:59:53 -0800 (Wed, 10 Feb 2016) $
     $LastChangedRevision: 19928 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/spd_get_nut_angles_vec.pro $

(See general/cotrans/spd_get_nut_angles_vec.pro)

## SPD_MAKE_J2000_MATRIX_VEC

[Previous Routine] [Next Routine] [List of Routines]

     SPD_MAKE_J2000_MATRIX_VEC

     Vectorized version0 of spd_make_j2000_matrix_vec from spd_gei2j2000.pro

     $LastChangedBy: nikos $
     $LastChangedDate: 2018-06-11 13:13:02 -0700 (Mon, 11 Jun 2018) $
     $LastChangedRevision: 25346 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/spd_make_j2000_matrix_vec.pro $

(See general/cotrans/spd_make_j2000_matrix_vec.pro)

## SPD_SET_COORD

[Previous Routine] [Next Routine] [List of Routines]

    Procedure:
      spd_set_coord

    Purpose:
      Set coordinates of tplot variable

    Calling Sequence:
      spd_set_coord, tplotnames, coord

    Input:
      tplotnames:  List of tplot variables
      coord:  New coordinate system, e.g. 'gse', 'gsm'
              If not defined "unknown" will be used

    Output:
      none, alters dlimits.data_att.coord_sys

    Notes:

    $LastChangedBy: aaflores $
    $LastChangedDate: 2016-05-25 18:14:39 -0700 (Wed, 25 May 2016) $
    $LastChangedRevision: 21213 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/spd_set_coord.pro $

(See general/cotrans/spd_set_coord.pro)

## SPG2SSL

[Previous Routine] [Next Routine] [List of Routines]

    procedure: spg2ssl

    Purpose: coordinate transformation

             SPG<-->SSL;

    inputs

    	name_thx_xxx_in 	... data in the input coordinate system (t-plot variable name)
       name_thx_xxx_out    ... name for output  (t-plot variable name)

    keywords:

       probe :  explicitly specify a probe, rather than inferring from tplot name

       TRANSFORMATIONS

       /SSL2SPG inverse transformation

       /IGNORE_DLIMITS if the specified from coord is different from the
    coord system labeled in the dlimits structure of the tplot variable
    setting this keyword prevents an error

    Example:
          spg2ssl,'tha_fgl_spg','tha_fgl_ssl'
          spg2ssl,'tha_fgl_ssl','tha_fgl_spg',/SSL2SPG
    Notes: under construction!!

    Written by Hannes Schwarzl
     $LastChangedBy: kenb-mac $
     $LastChangedDate: 2007-05-05 10:29:05Z $
     $LastChangedRevision: 645 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/trunk/cotrans/ssl2dsl.pro $

(See general/cotrans/spg2ssl.pro)

## TGSM2MLT

[Previous Routine] [List of Routines]

     PROCEDURE:
        tgsm2mlt

     PURPOSE:
         Allows a user to convert position data in a tplot variable
         into a tplot variable containing MLT data

     INPUT:
         in_varname: tplot name of position variable in GSM coordinates
         out_varname: name of the tplot variable to store the MLT data in

     KEYWORDS:
         mlat: name of the tplot variable to store the magnetic latitude data in

     NOTES:
         Works on MMS position variables loaded from FGM files (which
            include the magnitude of the vector as the 4-th component)

     $LastChangedBy: egrimes $
     $LastChangedDate: 2016-01-21 14:59:30 -0800 (Thu, 21 Jan 2016) $
     $LastChangedRevision: 19772 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/cotrans/tgsm2mlt.pro $

(See general/cotrans/tgsm2mlt.pro)