;+ ; NAME: ; CarringtonNear ; PURPOSE: ; Translate a heliographic longitude into a Carrington variable within half ; a rotation from a specified Carrington variable ; CATEGORY: ; CALLING SEQUENCE: FUNCTION CarringtonNear, XC, LNG, degrees=Degrees ; INPUTS: ; XC array; type: float ; reference Carrington variable ; LNG array; type: float ; heliographic longitude in [0,360] ; OPTIONAL INPUT PARAMETERS: ; /degrees indicates LNG is in degrees (default is radians) ; OUTPUTS: ; XCnear array; type: float ; Carrington variable near XC ( abs(XCnear-XC) le 0.5 ) ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; ToRadians ; SEE ALSO: ; Carrington ; RESTRICTIONS: ; The input longitudes MUST be inside [0,360] ; PROCEDURE: ; The difference in longitude between LNG and XC is calculated. If ; the difference is less than -180 deg then 360 deg is added; if greater than ; 180 deg then 360 deg is subtracted. ; MODIFICATION HISTORY: ; OCT-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- OnePi = !dpi TwoPi = 2*OnePi ;------- ; The decimal fraction of XC determines the heliographic longitude. ; ; Get the difference in heliographic longitude. ; The point of observation is located east or west relative to the spacecraft. ; If it lies in the eastern hemisphere 0 <= DLNG < -180; ; If it lies in the western hemisphere 0 <= DLNG < 180. DLNG = LNG*ToRadians(degrees=Degrees) - (1.0d0-(XC-floor(XC)))*TwoPi DLNG = DLNG+(abs(DLNG) GT OnePi)*(1-2*(DLNG GT 0))*TwoPi RETURN, XC-DLNG/TwoPi & END