FUNCTION CHAP_orig2,Z,THETA,H ; ; Routine to calculate the Chapman function ; Author: Dave Rusch ; Modified by Lou Clark, June 1982 ; Converted to IDL by Michael T. Callan, September 2005 ; ; Input: ; Z - Altitude (km) ; THETA - Solar zenith angle (degrees) ; H - Scale height (km) ; ; Output: ; Chapman's grazing incidence integral returned as function value ; COMMON CHAP_COM,RE,CHAP_MIN,A1,A2,A3,A4,B1,B2 ; ; Initialize COMMON CHAP_COM if this is the first call ASIZE = SIZE(RE) IF ASIZE(1) EQ 0 THEN BEGIN RE = 6371. CHAP_MIN = 1.E-20 A1 = 1.0606963 A2 = .55643831 A3 = 1.0619896 A4 = 1.7245609 B1 = .56498823 B2 = .06651874 ENDIF ; ; Check the calling arguments for reasonableness IF (Z LT 0.) OR (H LT 0.) OR (THETA lt 0) or (theta GT 180.) THEN BEGIN PRINT,'Error in arguments to Chapman function' PRINT,Z,THETA,H,FORMAT= $ "('Z = ',F5.1,5X,'Theta = ',F5.1,5X,'Scale height = ',F9.1)" RETURN,0. ENDIF ; ; Calculate the value big=0 IF THETA EQ 0. THEN begin RETURN,1. end ELSE IF THETA GT (90.) THEN begin big=1 theta=180-theta end F = 1. ANGLE = THETA*!const.dtor TEMP = 0. C = SQRT(!PI*(RE+Z)/(2.*H)) Y = C*COS(ANGLE)/SQRT(!PI) IF Y LT 8. THEN begin result = TEMP + F*C*(A1 + A2*Y)/(A3 + (A4 + Y)*Y) end else begin result = TEMP + F*C*B1/(B2 + Y) ENDELSE if big then result=2*chap2(z,90,h)-result RETURN,result ; END