;+
; Contains the polar_projection procedure
;
; :Author:
; Laurent Lamy
;
; :History:
; 2004/12/03: Created
;
; 2004/12/03: Last Edit
;-
;
;+
; polar_projection is a procedure that <behavior desc here>
;
; :Params:
; th_data_in: in, required, type=sometype
; A parameter named th_data_in
; ph_data_in: in, required, type=sometype
; A parameter named ph_data_in
; th_center_in: in, required, type=sometype
; A parameter named th_center_in
; ph_center_in: in, required, type=sometype
; A parameter named ph_center_in
; th_north_in: in, required, type=sometype
; A parameter named th_north_in
; ph_north_in: in, required, type=sometype
; A parameter named ph_north_in
; pol_r: in, required, type=sometype
; A parameter named pol_r
; pol_th: in, required, type=sometype
; A parameter named pol_th
;
; :Keywords:
; deg: in, optional, type=sometype
; A keyword named deg
;-
PRO polar_projection,th_data_in,ph_data_in,th_center_in,ph_center_in, $
th_north_in,ph_north_in,pol_r,pol_th, $
deg=deg
if keyword_set(deg) then begin
th_data = th_data_in/!radeg
ph_data = ph_data_in/!radeg
th_center = th_center_in/!radeg
ph_center = ph_center_in/!radeg
th_north = th_north_in/!radeg
ph_north = ph_north_in/!radeg
endif else begin
th_data = th_data_in
ph_data = ph_data_in
th_center = th_center_in
ph_center = ph_center_in
th_north = th_north_in
ph_north = ph_north_in
endelse
q1 = q_make(th_Center,[sin(ph_Center),-cos(ph_Center),0])
qd = q_vmake(make_vect_sph(1.,th_data,ph_data))
qn = q_vmake(make_vect_sph(1.,th_north,ph_north))
qd1 = q_rot(q1,qd)
qn1 = q_rot(q1,qn)
ph1_north = atan(qn1(1,*),qn1(2,*))
q2 = q_make(ph1_north-!pi/2.,[0,0,1])
qd2 = q_rot(q2,qd1)
th2_data = reform(acos(qd2(3,*)<1.))
ph2_data = reform(atan(qd2(1,*),qd2(2,*)))
pol_r = th2_data*!radeg
pol_th = ph2_data
return
end