; docformat = 'rst' ; ; NAME: ; evalMoffat ; PURPOSE: ; Evaluate the ordinate (Y) coordinates of a 1-D Moffat function ; ;+ ; :Description: ; Evaluate the ordinate (Y) coordinates of a 1-D Moffat function ; ; :Categories: ; Maths, Evaluation ; ; :Params: ; X: in, required, type=float ; Array (any dimension) of x values. ; P: in, required, type=float ; The parameters of the Moffat:: ; P[0] = Amplitude ; P[1] = Center ; P[2] = FWHM ; P[3] = Power Law Index ; P[4] = Background Level (Optional) ; P[5] = Background Slope (Optional) ; ; :Returns: The evaluated ordinates at positions X ; ; :Keywords: ; _EXTRA: in, optional, type=struct ; Can suppleant P in inversion code s(see MPFITFUN) ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Original Version written in June 2013, B. Carry (IMCCE) ; 2013 Sep. - B.Carry (IMCCE) - Header for idldoc ; 2017 Aug. - B.Carry (OCA) - Added idl2 option ;- function evalMoffat, X, P, _EXTRA=_EXTRA COMPILE_OPT hidden, idl2 ;-------------------------------------------------------------------------------- ;--I-- Initialization And Input Verification ----------------------------------- ;--I.1-- Check Presence of Arguments ; if N_params() LT 2 then begin ; message, /ioError, 'syntax: Y = evalMoffat( X, P )' ; return, -1 ; endif ;--I.2-- Handle Extra Keyword (e.g., for use in MPFIT): replace P by _EXTRA.P if keyword_set( _extra ) then p = _extra.p ;--I.3-- Convert Inputs to Float X=float(X) P=float(P) ;--II-- Evaluate the Moffat ---------------------------------------------------- u = (x - p[1])/p[2] moffat = p[0]/(u^2 + 1)^p[3] ;--III-- Evaluate a Potential Background --------------------------------------- nterms = n_elements( p ) case nterms of 4: plane=x*0. 5: plane=p[4] 6: plane=p[4] + x*p[5] endcase ;--IV-- Return the Moffat on top of the Background ----------------------------- return, (moffat+plane) end