;------------------------------------------------------------- ;+ ; NAME: ; GTE_DELVAR ; ; PURPOSE: ; Delete one or more variables from a data array and the ; associated variable descriptor. ; ; CATEGORY: ; GTE tools ; ; CALLING SEQUENCE: ; GTE_DELVAR,data,vardesc,selection ; ; INPUTS: ; DATA -> The data array (lines, vars) ; ; VARDESC -> The variable descriptor array (see GTE_VARDESC) ; ; SELECTION -> An index array that defines the variables to ; be deleted from the data array and variable descriptors. ; If no selection array is passed, or the first element is ; a negative number (typical result of WHERE(nothing)), ; then nothing is changed. ; ; KEYWORD PARAMETERS: ; ; OUTPUTS: ; ; SUBROUTINES: ; ; REQUIREMENTS: ; Uses INV_INDEX ; ; NOTES: ; ; EXAMPLE: ; gte_delvar,data,vardesc,[1,3] ; ; ; delete second and fourth column of data ; ; MODIFICATION HISTORY: ; mgs, 24 Aug 1998: VERSION 1.00 ; ;- ; Copyright (C) 1998, Martin Schultz, Harvard University ; This software is provided as is without any warranty ; whatsoever. It may be freely used, copied or distributed ; for non-commercial purposes. This copyright notice must be ; kept with any copy of this software. If this software shall ; be used commercially or sold as part of a larger package, ; please contact the author to arrange payment. ; Bugs and comments should be directed to mgs@io.harvard.edu ; with subject "IDL routine gte_delvar" ;------------------------------------------------------------- pro gte_delvar,data,vardesc,selection ; reasons not to proceed further if (n_elements(data) le 1) then return if (not chkstru(vardesc,'name')) then return if (n_elements(selection) eq 0) then return if (selection[0] lt 0) then return ; Invert selection array keep = inv_index(selection,n_elements(vardesc)) if (keep[0] lt 0) then begin ; delete everything data = -1L vardesc = 0 endif else begin data = data[*,keep] vardesc = vardesc[keep] endelse return end