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

Last modified: Tue Aug 5 18:17:40 2025.

# Directory Listing of Routines

# projects/themis/state/cotrans

- DSL2GSE
- GSE2SSE
- SSE2SEL
- SSL2DSL
- THM_COTRANS
- THM_COTRANS_MATRIX
  brute force method of creating rotation matrix for a
- THM_COTRANS_TENSOR
  wrapper for coordinate transforms to prssure and momentum
- THM_FAC_MATRIX_MAKE
- THM_GSM2LMN_WRAP
  Wrapper transforms THEMIS-generated vector field from GSM to LMN (boundary-normal)

# Routine Descriptions

## DSL2GSE

[Next Routine] [List of Routines]

    procedure: dsl2gse

    Purpose: THEMIS coordinate transformations

             DSL<-->GSE;

             interpolates, right ascension, declination
             updates coord_sys atribute of output tplot variable.

    inputs

    	name_thx_xxx_in 	... data in the input coordinate system (t-plot variable name)
       name_thx_spinras     ... right ascension (t-plot variable name)
       name_thx_spindec     ... declination (t-plot variable name)
       name_thx_xxx_out     ... name for output (t-plot variable name)

    keywords:
       TRANSFORMATIONS

       /GSE2DSL 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:
          dsl2gse('tha_fgl_dsl','tha_spinras','tha_spindec','tha_fglc_gse')

            expects attitude in GEI (tha_spinras,tha_spindec)

          dsl2gse('tha_fglc_gse','tha_spinras','tha_spindec','tha_fgl_dsl',/GSE2DSL)

            expects attitude in GEI (tha_spinras,tha_spindec)

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

    Written by Hannes Schwarzl
     $LastChangedBy: pcruce $
     $LastChangedDate: 2013-07-29 10:24:04 -0700 (Mon, 29 Jul 2013) $
     $LastChangedRevision: 12735 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/dsl2gse.pro $

(See projects/themis/state/cotrans/dsl2gse.pro)

## GSE2SSE

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

    procedure: gse2sse

    Purpose: Coordinate transformation between GSE & SSE coordinates(and the inverse)

         SSE is defined as:
            X: Moon->Sun Line
            Y: Ecliptic North cross X
            Z: X cross Y

         GSE is defined as:
            X: Earth Sun Line(naturally in the ecliptic plane)
            Y: Z x X
            Z: Ecliptic North
    inputs:

      name_in:
        Name of input tplot variable to be transformed or an array of data [t,x,y,z]
      name_sun_pos:
        Name of the solar position tplot variable in GEI coordinates
        or as an array of data [t,x,y,z]
      name_lun_pos:
        Name of the lunar position tplot variable in GEI coordinates
        or as an array of data [t,x,y,z]
      name_out:
        Name that the rotated variable should take.

    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.
       This keyword is only used with tplot variables and ignored if
       array data is input

       /ROTATION_ONLY: Set this flag when to only do the rotation, and not
       the translation from geocentric to selenocentric coordinates.
       That is used for sse2sel transform when creating the sel rotation
       matrix

    Examples:

          gse2sse,'tha_state_pos','slp_sun_pos_gse','slp_lun_pos_gse','tha_state_pos_sse'
          gse2sse,'tha_state_pos_sse','slp_sun_pos_gse','slp_lun_pos_gse','tha_state_pos_gse',/sse2gse,/ignore_dlimits

          OR (with vector data [t,x,y,z]

          gse2sse, pos_gse,sun_gse,lun_pos,pos_sse
          gse2sse,pos_sse,sun_gse,lun_pos,pos_gse,/sse2gse

    Notes:
       #1 SSE coordinate Z-axis is generally not exactly parallel to ecliptic north,
          as the moon will not always be in the ecliptic plane, and thus the moon->sun line
          will not always lie in the ecliptic plane.
       #2 If dlimit-labeled position passed in without /ignore_dlimits,
          input will be offset to account for relative position of frames of reference.
       #3 If dlimit-labeled velocity passed in without /ignore_dlimits,
          input will be offset to account for relative motion of frames of reference
       #4 If dlimit-labeled acceleration passed in without /ignore_dlimits,
          warning will be raise, but offset will not be applied automatically
       #5 Uses tvector_rotate, and sse_matrix_make to perform the rotation.
          tvector_rotate will also interpolate the rotation matrix onto the time-grid of the input.
          Interpolation done using quaterions and the spherical linear interpolation algorithm (SLERP)
       #6 dlimits are automatically ignored if vector data is input

    Written by Jenni Kissinger and Patrick Cruce

     $LastChangedBy: jwl $
     $LastChangedDate: 2023-04-12 11:20:40 -0700 (Wed, 12 Apr 2023) $
     $LastChangedRevision: 31739 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/gse2sse.pro $

(See projects/themis/state/cotrans/gse2sse.pro)

## SSE2SEL

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

    procedure: sse2sel

    Purpose: Coordinate transformation between SSE & SEL coordinates(and the inverse)

         SSE is defined as:
            X: Moon->Sun Line
            Y: Ecliptic North cross X
            Z: X cross Y

         SEL is defined as:
            X: TBD
            Y: TBD
            Z: TBD
    inputs:

      name_in:
        Name of input tplot variable to be transformed
        or as an array of data [t,x,y,z]
      name_sun_pos:
        Name of the sun position tplot variable in GEI coordinates
        or as an array of data [t,x,y,z]
      name_moon_pos:
        Name of the moon position tplot variable in GEI coordinates
        or as an array of data [t,x,y,z]
      name_lun_att_x:
        Name of the SEL X-axis tplot variable in GEI coordinates
        or as an array of data [t,x,y,z]
      name_lun_att_z:
        Name of the SEL Z-axis tplot variable in GEI coordinates
        or as an array of data [t,x,y,z]
      name_out:
        Name that the rotated variable should take.

    keywords:

       /SEL2SSE 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.
       This keyword is only used with tplot variables and ignored if
       array data is input

    Examples:

          sse2sel,'tha_state_pos_sse','slp_sun_pos','slp_lun_pos','slp_lun_att_x','slp_lun_att_z','tha_state_pos_sel'
          sse2sel,'tha_state_pos_sel','slp_sun_pos','slp_moon_pos','slp_lun_att_x','slp_lun_att_z','tha_state_pos_sse',/sel2sse,/ignore_dlimits

          Or for vector data

          sse2sel,pos_sse,sun_pos,lun_pos,lun_att_x,lun_att_z,pos_sel
          sse2sel,pos_sel,sun_pos,lun_pos,lun_att_x,lun_att_z,pos_sse, /sel2sse

    Notes:
       #1 Uses tvector_rotate, and sse_matrix_make to perform the rotation.
          tvector_rotate will also interpolate the rotation matrix onto the time-grid of the input.
          Interpolation done using quaterions and the spherical linear interpolation algorithm (SLERP)
       #2 If vector data is input the IGNORE_LIMITS keyword is not used.

    Adapted from gse2sse, written by Jenni Kissinger and Patrick Cruce

     $LastChangedBy: jwl $
     $LastChangedDate: 2012-06-04 10:25:21 -0700 (Mon, 04 Jun 2012) $
     $LastChangedRevision: 10492 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/sse2sel.pro $

(See projects/themis/state/cotrans/sse2sel.pro)

## SSL2DSL

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

    procedure: ssl2dsl

    Purpose: despins (spins) THEMIS  data

             SSL<-->DSL;

             interpolates the spinphase, spin period
             updates coord_sys atribute of output tplot variable.

    inputs

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

    keywords:
       /NAME_INPUT : Always required; this argument is the name of a tplot
         variable to use as the input data.

       /NAME_OUTPUT: Always required; this argument is the name of a tplot
         variable to receive the output.

       TRANSFORMATIONS

       /DSL2SSL 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

      /INTERPOLATE_STATE : if specified, interpolate the spin phase
        from the 1-minute samples in the state CDF.  Otherwise,
        use the spinmodel routines by default.

      /NAME_THX_SPINPER : required if /INTERPOLATE_STATE is specified;
        this is the name of a tplot variable containing the 1-minute
        spinper samples from the state CDF.

      /NAME_THX_SPINPHASE : required if /INTERPOLATE_STATE is specified;
        this is the name of a tplot variable containing the 1-minute
        spinphase samples from the state CDF.

      /SPINMODEL_PTR : required if /INTERPOLATE_STATE is NOT specified;
        this argument is a pointer to the appropriate spin model data structure.

    Example:
          ssl2dsl,name_input='tha_fgl_ssl',$
              name_output='tha_fgl_dsl',$
              /INTERPOLATE_STATE,$
              name_thx_spinper='tha_state_spinper',$
              name_thx_spinphase='tha_state_spinphase'

          ssl2dsl,name_input='tha_fgl_dsl',$
            /INTERPOLATE_STATE,$
            name_thx_spinper='tha_state_spinper',$
            name_thx_spinphase='tha_state_spinphase',$
            name_output='tha_fgl_ssl',$
            /DSL2SSL

          ssl2dsl,name_input='tha_fgl_dsl',$
             spinmodel_ptr=spinmodel_get_ptr('a'),$
             name_output='tha_fgl_ssl'

    Notes: under construction!!

    Written by Hannes Schwarzl
     $LastChangedBy: jwl $
     $LastChangedDate: 2012-06-04 10:26:03 -0700 (Mon, 04 Jun 2012) $
     $LastChangedRevision: 10493 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/ssl2dsl.pro $

(See projects/themis/state/cotrans/ssl2dsl.pro)

## THM_COTRANS

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

    Procedure: thm_cotrans
    Purpose:   Transform between various THEMIS  and geophysical coordinate systems
    keywords:
      probe = Probe name. The default is 'all', i.e., transform data for all
              available probes.
              This can be an array of strings, e.g., ['a', 'b'] or a
              single string delimited by spaces, e.g., 'a b'
      datatype = The type of data to be transformed, can take any of the values
              allowed for datatype for the various thm_load routines. You
              can use wildcards like ? and [lh].
              'all' is not accepted. You can use '*', but you may get unexpected
              results if you are using suffixes.
      in_coord = 'spg', 'ssl', 'dsl', 'gse', 'gsm','sm', 'gei','geo', 'sse', 'sel' or
              'mag' coordinate system of input.
              This keyword is optional if the dlimits.data_att.coord_sys attribute
              is present for the tplot variable, and if present, it must match
              the value of that attribute.  See cotrans_set_coord,
              cotrans_get_coord
      out_coord = 'spg', 'ssl', 'dsl', 'gse', 'gsm', 'sm', 'gei','geo', 'sse','sel', or 'mag'
               coordinate system of output.  This keyword is optional if
               out_suffix is specified and last 3 characters of suffix specify
               the output coordinate system.
      in_suffix = optional suffix needed to generate the input data quantity name:
               'th'+probe+'_'datatype+in_suffix
      out_suffix = optional suffix to add to output data quantity name.  If
               in_suffix is present, then in_suffix will be replaced by out_suffix
               in the output data quantity name.
     valid_names:return valid coordinate system names in named varibles supplied to
               in_coord and/or out_coord keywords.
     support_suffix: if support_data is loaded with a suffix you can
                     specify it here
     slp_suffix: if slp_sun_pos, slp_lun_pos, slp_lunn_att variables have
                 this suffix, you can specify it here
     out_vars: return a list of the names of any transformed variables

     ignore_dlimits: set this keyword to true so that an error will not
         be produced if the internal label of the coordinate system clashed
         with the user provided coordinate system.
     interpolate_state: use interpolation on 1-minute state CDF spinper/spinphase
         samples for despinning instead of spin model

     no_update_labels: Set this keyword if you want the routine to not update the labels automatically

    Optional Positional Parameters:
     in_name  Name(s) of input tplot variable(s) (or glob patern)
              (space-separated list or array of strings.).  If the in_name
              parameter is provided, the probe and datatype
              keywords will be ignored.  However, if the input name
              is not of format 'th[a-e]_*', use the probe keyword to indicate
              which probe's state data should be used for each input variable.
     out_name Name(s) of output tplot variable(s).  glob patterns not accepted.
              Number of output names must match number of input names (after glob
              expansion of input names).  (single string, or array of strings.)

    Examples:
      thm_load_state, /get_support

      thm_cotrans, probe='a', datatype='fgl', out_suffix='_gsm'

      ; or equivalently

      thm_cotrans, 'tha_fgl', 'tha_fgl_gsm', out_coord='gsm'

      ; to transform all th?_fg?_dsl to th?_fg?_gsm

      thm_cotrans, 'th?_fg?', in_suffix='_dsl', out_suffix='_gsm'

      ; for arbitrary input variables, specify in_coord and probe:

      thm_cotrans,'mydslvar1 mydslvar2 mydslvar3', $
                  in_coord='dsl', probe='b c d', out_suff='_gse'

     $LastChangedBy: jimm $
     $LastChangedDate: 2019-02-13 16:05:02 -0800 (Wed, 13 Feb 2019) $
     $LastChangedRevision: 26625 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/thm_cotrans.pro $

(See projects/themis/state/cotrans/thm_cotrans.pro)

## THM_COTRANS_MATRIX

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

    NAME:
     thm_cotrans_matrix
    PURPOSE:
     brute force method of creating rotation matrix for a
     THEMIS coordinate transform.
    CALLING SEQUENCE:
     rotmat = thm_cotrans_matrix(in_name, $
                                 in_coord=in_coord, $
                                 out_coord=out_coord, $
                                 interpolate_state=interpolate_state, $
                                 use_spinaxis_correction=use_spinaxis_correction, $
                                 use_spinphase_correction=use_spinphase_correction, $
                                 use_eclipse_corrections=use_eclipse_corrections)
    INPUT:
     in_name = a THEMIS tplot variable,
    OUTPUT:
     rotmat = a 3x3 transformation matrix for each time given by the
              input variable
    KEYWORDS:
     Standard thm_cotrans keywords:
      probe = 'a', 'b', 'c', 'd', 'e', If not set, then we will try to
               get it from the variable name
      in_coord = 'spg', 'ssl', 'dsl', 'gse', 'gsm','sm', 'gei','geo', 'sse', 'sel' or
              'mag' coordinate system of input.
              This keyword is optional if the dlimits.data_att.coord_sys attribute
              is present for the tplot variable, and if present, it must match
              the value of that attribute.  See cotrans_set_coord,
              cotrans_get_coord
      out_coord = 'spg', 'ssl', 'dsl', 'gse', 'gsm', 'sm', 'gei','geo', 'sse','sel', or 'mag'
               coordinate system of output.  This keyword is optional if
               out_suffix is specified and last 3 characters of suffix specify
               the output coordinate system.
     interpolate_state: use interpolation on 1-minute state CDF spinper/spinphase
         samples for despinning instead of spin model
     use_spinaxis_correction: uses spinaxis correction as in THM_COTRANS
     use_spinphase_correction: uses spinphase correction as in THM_COTRANS
     use_eclipse_correction: uses eclipse correction as in THM_COTRANS
     support_suffix: if support_data is loaded with a suffix you can
     specify it here
     slp_suffix: if slp_sun_pos, slp_lun_pos, slp_lunn_att variables have
     this suffix, you can specify it here
    EXAMPLE:
     For converting DSL to GSE coordinates, using ptens variable
      rotmat = thm_cotrans_matrix('tha_peif_ptens', out_coord = 'GSE')
    Any input can be used, only the time variable is important, but if
    the variable has no coordinate system defined (e.g., density) then
    the in_coord keyword should be set.
    HISTORY:
     2019-01-16, jmm, jimm@ssl.berkeley.edu
     $LastChangedBy: jimm $
     $LastChangedDate: 2019-02-13 11:37:26 -0800 (Wed, 13 Feb 2019) $
     $LastChangedRevision: 26620 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/thm_cotrans_matrix.pro $

(See projects/themis/state/cotrans/thm_cotrans_matrix.pro)

## THM_COTRANS_TENSOR

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

    NAME:
    thm_cotrans_tensor
    PURPOSE:
    wrapper for coordinate transforms to prssure and momentum
    flux tensors
    CALLING SEQUENCE:
     in_coord is optional if dlimits includes a data_att.coord_sys element.
    pro thm_cotrans_tensor, in_name, out_name, $
                     in_coord=in_coord, out_coord=out_coord, verbose=verbose, $
                     in_suffix=in_suf, out_suffix=out_suf, $
                     support_suffix=support_suffix,ignore_dlimits=ignore_dlimits,$
                     interpolate_state=interpolate_state,out_vars=out_vars,$
                     use_spinaxis_correction=use_spinaxis_correction, $
                     use_spinphase_correction=use_spinphase_correction, $
                     use_eclipse_corrections=use_eclipse_corrections,$
                     slp_suffix=slp_suffix,no_update_labels=no_update_labels
    INPUT:
     in_name  Name(s) of input tplot variable(s) (or glob patern)
              (space-separated list or array of strings.). Non-tensor
              variables can be mixed in, these will be passed to
              thm_cotrans directly.
     out_name Name(s) of output tplot variable(s).  glob patterns not accepted.
              Number of output names must match number of input names (after glob
              expansion of input names).  (single string, or array of strings.)
    KEYWORDS:
      in_coord = 'spg', 'ssl', 'dsl', 'gse', 'gsm','sm', 'gei','geo', 'sse', 'sel' or
              'mag' coordinate system of input.
              This keyword is optional if the dlimits.data_att.coord_sys attribute
              is present for the tplot variable, and if present, it must match
              the value of that attribute.  See cotrans_set_coord,
              cotrans_get_coord
      out_coord = 'spg', 'ssl', 'dsl', 'gse', 'gsm', 'sm', 'gei','geo', 'sse','sel', or 'mag'
               coordinate system of output.  This keyword is optional if
               out_suffix is specified and last 3 characters of suffix specify
               the output coordinate system.
      in_suffix = optional suffix needed to generate the input data quantity name:
               'th'+probe+'_'datatype+in_suffix
      out_suffix = optional suffix to add to output data quantity name.  If
               in_suffix is present, then in_suffix will be replaced by out_suffix
               in the output data quantity name.
     valid_names:return valid coordinate system names in named varibles supplied to
               in_coord and/or out_coord keywords.
     support_suffix: if support_data is loaded with a suffix you can
     specify it here

     out_vars: return a list of the names of any transformed variables

     ignore_dlimits: set this keyword to true so that an error will not
         be produced if the internal label of the coordinate system clashed
         with the user provided coordinate system.
     interpolate_state: use interpolation on 1-minute state CDF spinper/spinphase
         samples for despinning instead of spin model
     use_spinaxis_correction: use spinaxis correction
     use_spinphase_correction: use spinphase correction
     use_eclipse_corrections: use eclipse corrections
     no_update_labels: Set this keyword if you want the routine to not
                       update the labels automatically
     reuse_rotation_matrix: If set, use the same rotation atrix for all
                            inputs, if the time arrays are the same
     delete_rotation_matrix: If set, delete the rotation matirx variable

     $LastChangedBy: jimm $
     $LastChangedDate: 2019-02-19 11:14:39 -0800 (Tue, 19 Feb 2019) $
     $LastChangedRevision: 26642 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/projects/themis/state/cotrans/thm_cotrans_tensor.pro $

(See projects/themis/state/cotrans/thm_cotrans_tensor.pro)

## THM_FAC_MATRIX_MAKE

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

    Procedure: thm_fac_matrix_make

    Purpose:  generates a field aligned coordinate transformation matrix
    from an input B vector array(and sometimes a position vector array)
    then stores it in a tplot variable.

    This code has been modified from fac_matrix_make to handle input data that are
    in DSL coordinates.

    Arguments:
       mag_var_name=the name of the tplot variable storing the magnetic field
       vectors to be used in transformation matrix generation
       pos_var_name(optional)=the name of the tplot variable storing the position
       vectors to be used in transformation matrix generation
       newname(optional)=the name of the tplot variable in which to store
       the output
       error(optional) = named variable that holds the error state of the
       computation 1 = success 0 = failure
       other_dim(optional) = the second axis for the field aligned
       coordinate system.
       probe=probe(optional) = string indicating the THEMIS probe for systems that use the DSL system.
         If this keyword is not specified and probe name is required, thm_fac_matrix_make will infer the probe
         from the 3rd letter of the magnetic field variable. (eg. 'tha_fgs_gsm')  If the tplot variable doesn't have
         a probe label in the name, this can lead to very irregular behavior, so it is recommended that you
         always specify probe.

       /DEGAP: Set to call TDEGAP to remove any gaps from the data. See TDEGAP for
               for other options that can be invoked using the _extra keyword.
               E.g. thm_fac_matrix_make, 'tha_fgs', other_dim='xgse', /degap, dt=3

       ************For all transformations Z = B************

       Warning about coordinate systems:
       B field tplot variable must be in gse,gsm, or dsl coordinates,
       depending on what transformation has been selected.
       Position tplot variable must be in gei coordinates. Gei is the default coordinate
       system of thm_load_state.

       Warning:  The resulting transformation matrices will only correctly
       transform data from the coordinate system of the input variable to
       the field aligned coordinate system.  So if mag_var_name is in dsl
       coordinates then you should only use the output matrices to transform
       other data in dsl coordinates.

       valid second coord(other_dim) options:

             'Xgse', (DEFAULT) translates from gse or gsm into FAC
                        Definition(works on GSE, or GSM):
                        X Axis = on plane defined by Xgse - Z
                        Second coordinate definition: Y = Z x X_gse
                        Third coordinate, X completes orthogonal RHS
                        (right hand system) triad: XYZ
                        Note: X_gse is a unit vector pointing in direction from
                              earth to the sun
             'Rgeo',translate from geo into FAC using radial position vector
                        Rgeo is radial position vector, positive radialy outwards.
                        Second coordinate definition: Y = Z x Rgeo (eastward)
                        Third coordinate, X completes orthogonal RHS XYZ.
             'mRgeo',translate into FAC using radial position vector
                        mRgeo is radial position vector, positive radially inwards.
                        Second coordinate definition: Y = Z x mRgeo (westward)
                        Third coordinate, X completes orthogonal RHS XYZ.
             'Phigeo', translate into FAC using azimuthal position vector
                        Phigeo is the azimuthal geo position vector, positive Eastward
                        First coordinate definition: X = Phigeo x Z (positive outwards)
                        Second coordinate, Y ~ Phigeo (eastward) completes orthogonal RHS XYZ
             'mPhigeo', translate into FAC using azimuthal position vector
                        mPhigeo is minus the azimuthal geo position vector; positive Westward
                        First coordinate definition: X = mPhigeo x Z (positive inwards)
                        Second coordinate, Y ~ mPhigeo (Westward) completes orthogonal RHS XYZ
             'Phism', translate into FAC using azimuthal Solar Magnetospheric vector.
                     Phism is "phi" vector of satellite position in SM coordinates.
                     Y Axis = on plane defined by Phism-Z, normal to Z
                     Second coordinate definition: X = Phism x Z
                     Third completes orthogonal RHS XYZ
             'mPhism', translate into FAC using azimuthal Solar Magnetospheric vector.
                     mPhism is minus "phi" vector of satellite position in SM coordinates.
                     Y Axis = on plane defined by Phism-Z, normal to Z
                     Second coordinate definition: X = mPhism x Z
                     Third completes orthogonal RHS XYZ
             'Ygsm', translate into FAC using cartesian Ygsm position as other dimension.
                     Y Axis on plane defined by Ygsm and Z
                     First coordinate definition: X = Ygsm x Z
                     Third completes orthogonal RHS XYZ
             'Zdsl', translates from dsl into FAC
                        Definition:
                        X Axis = on plane defined by Zdsl - Z
                        Second coordinate definition: X = Z x Zdsl
                        Third coordinate, Y completes orthogonal RHS
                        (right hand system) triad: XYZ
     Example:
      fac_matrix_make,'tha_fgs',other_dim='Xgse',pos_var_name='tha_pos',out_var_name='tha_fgs_fac_mat',probe='a'

(See projects/themis/state/cotrans/thm_fac_matrix_make.pro)

## THM_GSM2LMN_WRAP

[Previous Routine] [List of Routines]

     NAME:
         THM_GSM2LMN_WRAP

     PURPOSE:
    	Wrapper transforms THEMIS-generated vector field from GSM to LMN (boundary-normal)
    	coordinate system for magnetopause with help of routine gsm2lmn.pro.
    	It gets the necessary solar wind data with help of routine
    	get_sw_data.pro and passes all necessary keywords to it.
    	In distinction of GSM2LMN_WRAP, it finds space-time coordinates using
    	reference to a THEMIS probe.

     CATEGORY:
    	Coordinate Transformation

     CALLING SEQUENCE:
    	thm_gsm2lmn_wrap,data_in,data_out,probe,SWkeywords

     INPUTS:
    	data_in: structure {x:time, y:data}
    	probe: string specify which spacecraft caught data_in.

     KEYWORDS: Solarwind_load.pro keywords (Any combination of keywords defining
               output of solarwind_load.pro)

     PARAMETERS: none

     OUTPUTS:
    	data_out: structure {x:time, y:transformed_data}

     DEPENDENCIES: gsm2lmn.pro, solarwind_load.pro. Intermediate-level part of LMN
    		transform package.

     MODIFICATION HISTORY:
         Written by: Liu Jiang 09/21/2007
    	Modified for new background routines by: Vladimir Kondratovich 2007/12/28
    	Modified for error handling and changed () to [] for arrays
    	                                     by: Lynn B. Wilson III    2012/10/26

(See projects/themis/state/cotrans/thm_gsm2lmn_wrap.pro)