;+ ; PROJECT: SDAC ; ; NAME: fcount_rate ; ; ; PURPOSE: Compute the counting rate, counts/cm2/keV, from the response ; matrix and a photon flux model parameters ; ; CATEGORY: SPEX, Spectral analysis, fitting. ; ; ; CALLING SEQUENCE: c_rate = fcount_rate( e_in, par) ; ; ; INPUTS: ; Eout - dummy parameter, the meaning of these values are represented ; by the detector response matrix drm which is loaded on the initial call. ; ; Par - parameters to be used in call to F_MODEL. Par may be a two-dimensional ; array where the first index references a single argument list, and ; the second references each set. For example, a thermal model with two ; parameters in the function call and thirty sets of models would be ; dimensioned 2x30 and would return 30 vectors of count rates, where the ; first index would be on the energy axis. ; ; Ein - photon flux in units of 1/(cm2 s keV), must be 2XN array ; and must be in a form acceptable by the function in the string F_MODEL ; found in the common block function_com. ; drm - response matrix which returns the count rate in counts/cm2/sec/keV ; per unit photon/cm2, saves drm if drm isn't input. ; ; KEYWORD INPUTS: ; WUSE - return count rates for these indices. If WUSE isn't passed, the ; value is take from SPEX_COMMONS if it exists, otherwise the full output ; vector of drm(i.e. the first index) is used, i.e. wuse=indgen(n_elements(drm(*,0))). ; MODEL - string with name of photon spectral form. ; common blocks: ; function_com - contains name of fitting function, f_model ; fcount_rate_com - holds the drm ; Procedure: ; Count rates are generated by obtaining numbers of photons in ; each input band, these are multiplied by the DRM to get the rate. ; Restrictions- to be used inside of SPEX if DRM, EIN, and WUSE aren't supplied. ; These values are taken using spex_current.pro ; ; MODIFICATION HISTORY: ras, 24 Sept. 1993 ; Version 2, Totally revised, richard.schwartz@gsfc.nasa.gov, 18-aug-1997 ; Version 3, richard.schwartz@gsfc.nasa.gov, 28-jan-1998, allow PAR to ; be multiple parameter sets. ; Version 4, richard.schwartz@gsfc.nasa.gov, 10-dec-1998, let model override f_model in common. ;- function fcount_rate, eout, par, ein, drm, wuse=wuse, model=model ;Model name is specified by F_MODEL in function_com unless the keyword MODEL is set. @function_com checkvar, model, f_model f_model = model checkvar, drm, fcheck( spex_current('drm'), 0.0) checkvar, ein, fcheck( spex_current('e_in'), 0.0) checkvar, wuse, fcheck( fcheck(wuse, spex_current('wuse')), indgen(n_elements(drm(*,0)))) ;help, drm, ein, wuse, f_model if keyword_set(drm) and keyword_set(ein) then begin euse = ein edge_products, ein, width=w_in, mean=emin test = model_components(f_model,/exist) ;if it returns a 1, then the function can take 2xN argument. if not test then begin test = call_function( f_model, ein, par(*,0) ) ; ; If the vector test has the same number of elements as ein(2xn), then use emin(1-d), otherwise ein. if n_elements(test) eq n_elements(ein) then euse = emin endif number_of_param_sets = n_elements(par(0,*)) case (size(drm))(0) of 1: result = drm(wuse,*) * (call_function( f_model, euse, par(*,0)) * w_in) else: result = drm(wuse,*) # (call_function( f_model, euse, par(*,0)) * w_in) endcase if number_of_param_sets gt 1 then begin result = result(*) # (fltarr(1,number_of_param_sets)+1.0) for i=1,number_of_param_sets-1 do begin case (size(drm))(0) of 1: temp = drm(wuse,*) * (call_function( f_model, euse, par(*,i)) * w_in) else: temp = drm(wuse,*) # (call_function( f_model, euse, par(*,i)) * w_in) endcase result(*,i) = temp endfor endif endif else result = 0 return, result end