; docformat = 'rst' ; ; NAME: ; frameCoord_Eq2Gal ; PURPOSE: ; Convert Equatorial coordinates into Galactic coordinates or reverse ; ;+ ; :Description: ; Convert Equatorial coordinates into Galactic coordinates or reverse ; ; :Categories: ; Coordinates, Convertion ; ; :Params: ; EQ1: in, required, type=float ; A two-elements vector with equatorial coordinates (deg). If ; EQ2 is set, then EQ1 must contain a single element only ; (right ascencion). ; EQ2: in, optional, type=float ; The declination can be alternatively provided here (deg). ; ; :Returns: A two-elements vector with coordinates converted in Galactic (deg). ; ; :Keywords: ; EQ_TO_GAL: in, optional, type=boolean, default=1 ; If set, transforms EQuatorial coordinates into ECliptic ; ; GAL_TO_EQ: in, optional, type=boolean, default=0 ; If set, transforms ECliptic coordinates into EQuatorial ; ; VERBOSE: in, optional, type=boolean, default=0 ; If set, prints coordinate in standard output ; ; :Examples: ; Prints several convertions:: ; IDL> print, frameCoord_Eq2Gal( 0., 0. ) ; IDL> print, frameCoord_Eq2Gal( [0., 0.] ) ; IDL> print, frameCoord_Eq2Gal( [210., +20.] ) ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Written in March 2015, B. Carry (IMCCE) ;- function frameCoord_Eq2Gal, EQ1, EQ2, EQ_TO_GAL=EQ_TO_GAL, GAL_TO_EQ=GAL_TO_EQ, VERBOSE=VERBOSE ;-------------------------------------------------------------------------------- ;--I-- Input verification and Initialization ----------------------------------- COMPILE_OPT hidden, idl2 ;--I.1-- Coordinates Provided in one or two Variables if keyword_set(EQ2) then coord=[EQ1,EQ2] else coord=EQ1 coord *= !DTOR ;--I.2-- GAL->EQ or EQ->GAL? if not keyword_set(GAL_TO_EQ) and not keyword_set(EQ_TO_GAL) then EQ_TO_GAL=1 ;-------------------------------------------------------------------------------- ;--II-- EQ to Gal Conversion --------------------------------------------------- if keyword_set(EQ_TO_GAL) then begin ;--II.1-- Constant Angles for Conversion a1 = 192.25 * !DTOR a2 = 27.40 * !DTOR a3 = 303.00 * !DTOR ;--II.2-- Galactic Longitude tanx = sin( a1-coord[0] ) tanx /= cos(a1-coord[0])*sin(a2) - tan(coord[1])*cos(a2) out1 = (a3 - atan(tanx))/!DTOR ;--II.3-- Galactic Latitude sinb = sin(coord[1])*sin(a2) + cos(coord[1])*cos(a2)*cos(a1-coord[0]) out2 = asin( sinb ) /!DTOR endif else begin endelse ;-------------------------------------------------------------------------------- ;--II-- Gal to EQ Conversion --------------------------------------------------- if keyword_set(GAL_TO_EQ) then begin ;--II.1-- Constant Angles for Conversion a1 = 123.00 * !DTOR a2 = 27.40 * !DTOR a3 = 12.25 * !DTOR ;--II.2-- Right Ascension tany = sin( coord[0]-a1 ) tany /= cos(coord[0]-a1)*sin(a2) - tan(coord[1])*cos(a2) out1 = (a3 + atan(tany))/!DTOR ;--II.3-- Declination sind = sin(coord[1])*sin(a2) + cos(coord[1])*cos(a2)*cos(coord[0]-a1) out2 = asin( sind ) /!DTOR endif else begin endelse ;-------------------------------------------------------------------------------- ;--IV-- UI - If VERBOSE Specified --------------------------------------------- if keyword_set(verbose) then begin if keyword_Set(EQ_TO_GAL) then begin print, 'EQuatorial: alpha, delta :'+strtrim(string(coord[0], format='(F6.1)'),2)+' '+$ strtrim(string(coord[1], format='(F6.1)'),2) print, 'GALactic : lambda, beta :'+strtrim(string(out1, format='(F6.1)'),2)+' '+$ strtrim(string(out2, format='(F6.1)'),2) endif else begin print, 'GALactic : lambda, beta :'+strtrim(string(coord[0], format='(F6.1)'),2)+' '+$ strtrim(string(coord[1], format='(F6.1)'),2) print, 'EQuatorial: alpha, delta :'+strtrim(string(out1, format='(F6.1)'),2)+' '+$ strtrim(string(out2, format='(F6.1)'),2) endelse endif ;-------------------------------------------------------------------------------- ;--V-- Return the Result of Conversion return, [out1, out2] end