PRO cafe_integrate, env, range, subgroup, group, $ help=help, shorthelp=shorthelp ;+ ; NAME: ; integrate ; ; PURPOSE: ; integrates data set(s) in given range and prints result. ; ; CATEGORY: ; cafe ; ; SYNTAX: ; integrate[,range] [,subgroup][,group] ; ; INPUTS: ; ; range - (optional) Defines data points to sum up. This can ; be either: ; - Data point range, denoted by the data ; point number: ; [-], while , are positive ; numbers. Data point numbers start from zero. ; Open intervals can be represented with a ; "*" instead of the number. ; If only one number is given, a single ; data point will be referenced. ; If is less than all but the ; interval .. are referenced. ; - X value range, denoted by float point numbers: ; -, while , ; represents X values defining the interval to ; reference. Open intervals can be represented ; with a * instead of the value. If is ; less than all but the interval ; .. is referenced. ; - Vector of data point indices. The vector is ; denoted with [val,val,...,val] (indgen may ; be used also). ; - Boolean expressions with X/Y values. All ; values for which this expression is true are ; referenced. The expression may contain ; algebraic formulas combined with comparison ; operators "lt", "le", "eq", "gt", "ge" as used in IDL ; comparisons. For each data point a keyword ; is defined which has meaning and can be used ; for the boolean expression: ; x - The x-column value. ; y - The y-column value. ; error - The error column value. ; selected - True when the data point is selected. ; def - True when the data point is defined. ; x1 - Multi column first column value. ; x2 - Multi column second column ; value. ; x3 - Multi column third column value. ; To avoid interference with functions which ; also can be used a lower/upper case ; distinction is made. IDL funktions should ; be upper case. ; ; Default is to fold the entire data set. ; ; subgroup - (optional) The data set (subgroup) for which the model ; should be applied. This can be either the ; subgroup number or the file name representing ; the data set. It is possible to set more than ; one subgroup, either with numbers in brackets ; ([]) separated with ","; or denoting filenames ; with wildcards ("*"). ; Default are all subgroups in currently used ; group. ; ; ; group - (optional) The data group for which folding ; should applied. ; Default is the current group. Must be in ; range [0..29]. ; ; OUTPUT: ; The y value of all data points given is summed and printed ; out. ; ; SIDE EFFECTS: ; none ; ; EXAMPLE: ; > data,test.dat ; > integrate,50.-100. ; -> print sum of all data points in the x-range 50-100 (not ; the data point number!) ; ; HISTORY: ; $Id: cafe_integrate.pro,v 1.4 2004/06/17 16:36:59 goehler Exp $ ;- ; ; $Log: cafe_integrate.pro,v $ ; Revision 1.4 2004/06/17 16:36:59 goehler ; actual integration ; ; Revision 1.3 2003/11/05 15:10:44 goehler ; for debugging/manual handling: ; create environment if not existing ; ; Revision 1.2 2003/11/04 14:27:36 goehler ; added help with shorthelp for all subtopics ; added qdp x binsize info (for plot also) ; ; Revision 1.1 2003/10/04 18:46:45 goehler ; initial version of sum-up tool ; ; ; ; ;; command name of this source (needed for automatic help) name="integrate" ;; create environment if not existing: IF n_elements(env) EQ 0 OR NOT PTR_VALID(env) THEN env = cafeenv__define() ;; ------------------------------------------------------------ ;; HELP ;; ------------------------------------------------------------ ;; if help given -> print the specification above (from this file) IF keyword_set(help) THEN BEGIN cafe_help,env, name return ENDIF ;; ------------------------------------------------------------ ;; SHORT HELP ;; ------------------------------------------------------------ IF keyword_set(shorthelp) THEN BEGIN cafereport,env, "integrate- sum up data points" return ENDIF ;; ------------------------------------------------------------ ;; DATA EXTRACTION ;; ------------------------------------------------------------ ;; extract x/y/error: cafeextract,env, x,y,err,range, subgroup, group cafereport,env,"Integration from "+strtrim(string(min(x)),2) $ + " to "+ strtrim(string(max(x)),2) + ": " $ + strtrim(string(int_tabulated(x,y,/sort,/double)),2) END