;+
;Procedure: fac_crib
;
;Purpose:  A crib on showing how to transform into field aligned coordinates

;Notes:
;
; $LastChangedBy: pcruce $
; $LastChangedDate: 2007-09-07 16:53:14 -0700 (Fri, 07 Sep 2007) $
; $LastChangedRevision: 1560 $
; $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/ssl_general/tags/tdas_3_01/cotrans/special/fac/fac_crib.pro $
;-



; Example of FAC-Xgse matrix generation and rotation
del_data, '*'
timespan, '2007-03-23'

thm_load_fgm,probe = 'c', coord = 'gse'

;smooth the Bfield data appropriately
tsmooth2, 'thc_fgs_gse', 601, newname = 'thc_fgs_gse_sm601'

;make transformation matrix
fac_matrix_make, 'thc_fgs_gse_sm601', other_dim='xgse', newname = 'thc_fgs_gse_sm601_fac_mat'

;transform Bfield vector (or any other) vector into field aligned coordinates
tvector_rotate, 'thc_fgs_gse_sm601_fac_mat', 'thc_fgs_gse', newname = 'thc_fgs_facx'

tplot, ['thc_fgs_gse', 'thc_fgs_gse_sm601', 'thc_fgs_facx']
tlimit,'2007-03-23/10:00:00','2007-03-23/13:00:00'

print, 'Just ran an example of FAC-Xgse matrix generation and rotation'

stop

; Example of FAC-Rpos matrix generation and rotation

del_data, '*'
timespan, '2007-03-23'
thm_load_state,probe='c'
thm_load_fgm,probe = 'c', coord = 'gse'

;smooth the Bfield data appropriately
tsmooth2, 'thc_fgs_gse', 601, newname = 'thc_fgs_gse_sm601'

;make transformation matrix
fac_matrix_make, 'thc_fgs_gse_sm601',other_dim='rgeo', pos_var_name='thc_state_pos', newname = 'thc_fgs_gse_sm601_fac_mat'

;transform Bfield vector (or any other) vector into field aligned coordinates
tvector_rotate, 'thc_fgs_gse_sm601_fac_mat', 'thc_fgs_gse', newname = 'thc_fgs_facr'

tplot, ['thc_fgs_gse', 'thc_fgs_gse_sm601', 'thc_fgs_facr']
tlimit,'2007-03-23/10:00:00','2007-03-23/13:00:00'

print, 'Just ran an example of FAC-Rpos matrix generation and rotation'

stop

; Example of FAC-Ypos matrix generation and rotation
del_data, '*'
timespan, '2007-03-23'
thm_load_state,probe='c'
thm_load_fgm,probe = 'c', coord = 'gse'

;smooth the Bfield data appropriately
tsmooth2, 'thc_fgs_gse', 601, newname = 'thc_fgs_gse_sm601'

;make transformation matrix
fac_matrix_make, 'thc_fgs_gse_sm601',other_dim='ygeo', pos_var_name='thc_state_pos', newname = 'thc_fgs_gse_sm601_fac_mat'

;transform Bfield vector (or any other) vector into field aligned coordinates
tvector_rotate, 'thc_fgs_gse_sm601_fac_mat', 'thc_fgs_gse', newname = 'thc_fgs_facy'

tplot, ['thc_fgs_gse', 'thc_fgs_gse_sm601', 'thc_fgs_facy']
tlimit,'2007-03-23/10:00:00','2007-03-23/13:00:00'

print, 'Just ran an example of FAC-Ypos matrix generation and rotation'

stop

; Example of FAC-Ysm matrix generation and rotation
del_data, '*'
timespan, '2007-03-23'
thm_load_state,probe='c'
thm_load_fgm,probe = 'c', coord = 'gse'

;smooth the Bfield data appropriately
tsmooth2, 'thc_fgs_gse', 601, newname = 'thc_fgs_gse_sm601'

;make transformation matrix
fac_matrix_make, 'thc_fgs_gse_sm601',other_dim='ysm', pos_var_name='thc_state_pos', newname = 'thc_fgs_gse_sm601_fac_mat'

;transform Bfield vector (or any other) vector into field aligned coordinates
tvector_rotate, 'thc_fgs_gse_sm601_fac_mat', 'thc_fgs_gse', newname = 'thc_fgs_facy'

tplot, ['thc_fgs_gse', 'thc_fgs_gse_sm601', 'thc_fgs_facy']
tlimit,'2007-03-23/10:00:00','2007-03-23/13:00:00'

print, 'Just ran an example of FAC-Ysm matrix generation and rotation'

stop

end