; $Id: remove.pro,v 1.2 2002/01/14 20:59:26 amunter Exp $
function remove,a,xind,xmin,xmax,yind,ymin,ymax
;+
; NAME:         REMOVE
; PURPOSE:
;               remove data fom a TASCOM data structure
; CATEGORY:
; CALLING SEQUENCE:
;               remove,data_structure,'xindex',xmin,xmax
; INPUTS:
;               data_structure - TASCOM data structure to be modified
;               'x-index'- the print parameter to used as an index
;               xmin,xmax - upper and lower limits for removal
;                  e.g. remove,a,'h',0.9,1.1
; OPTIONAL INPUT PARAMETERS:
; KEYWORD PARAMETERS:
; OUPUTS:
;               a new data structure consisting of:
;                 d.points - integer - # of points in scan
;                 d.heads - integer - # of header parameters
;                 d.pars - integer - # of scan parameters
;                 d.text - string array - 2 lines of descriptive text
;                 d.hdef - string array - definition of header parameters
;                 d.hnum - float array - header parameters
;                 d.prp - string array - defintion of scan parameters
;                 d.data - 2D float array - scan data (parameter,point#)
; OPTIONAL OUTPUT PARAMETERS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; PROCEDURE:
; MODIFICATION HISTORY:
;               Thom Mason, Riso National Laboratory, 1993
;-  
if (xmax lt xmin) then begin
  temp=xmin
  xmin=xmax
  xmax=temp
  end
if (ymax lt ymin) then begin
  temp=ymin
  ymin=ymax
  ymax=temp
  end
i=0
while (i le a.points-1) do begin
  if ((a.data(tasid(xind,a),i) ge xmin) and (a.data(tasid(xind,a),i) le xmax) $
    and (a.data(tasid(yind,a),i) ge ymin) and (a.data(tasid(yind,a),i) le ymax)) then begin
    if (i eq 0) then a.data(*,0:a.points-2)=a.data(*,1:a.points-1) else $
      if (i eq a.points-1) then a.data=a.data(*,0:a.points-2) else $
      a.data(*,i:a.points-2)=a.data(*,i+1:a.points-1)
    a.points=a.points-1
    i=i-1
    endif
  i=i+1
  endwhile
bdat=[a.data(*,0:a.points-1)]
b={points: a.points,heads: a.heads,pars: a.pars,text: a.text,$
 hdef: a.hdef,hnum: a.hnum,prp: a.prp,data: bdat}
return,b
end
