PRO Tresholds

;+
; NAME
; 	 Tresholds
; PURPOSE
;	Redefines the highest and lowest value of the plot.
;	If a point of the plot is higher (lower) it will be redefined
;	to the value entered.
;	The user introduces on the keyboard
; 	the new maximum and minimum values. This procedure
;	is a part of the mdisp analyser.
;	The operation is performed only on selected plots
; CATEGORY:
;	1D
; CALLING SEQUENCE:
;	Tresholds
; COMMON BLOCK:
;	TreshRetr: for intern use only
; SIDE EFFECTS:
;	The Selectioner of mdisp is used, and a new plot is
;	created.
;	The terminal window is used.
; RESTRICTION:
;	To use ONLY together with the mdisp selectioner
;	procedures.
; -
; MODIFICATION HISTORY
;	Created: June 91, A.Csillaghy


COMMON TreshRetr, treshNr

IF N_Elements(treshNr) EQ 0 THEN treshNr= 0

nbSelected = N_Selected()

Clear_Screen
PTo, 5, 5,'Thresholds definition'

ltr = '' & htr = ''
Read,'Please enter the  lowest treshold (<ret> when not defined): ', ltr
Read, 'Please enter the highest treshold (<ret> when not defined): ', htr

FOR i = 1, nbSelected DO BEGIN
  name = Selection(i)
  Load_Plot, name, x,y
  IF ltr NE '' THEN newY = y > FLOAT(ltr) $
  ELSE IF htr NE '' THEN newY = y < FLOAT(htr) $
  ELSE newY = y > FLOAT(ltr) < FLOAT(htr)
  newName = name + '_tr'+StrTrim(treshNr,2)
  treshNr = treshNr +1 

  Store_Plot, newName, x,newY
  Remove_Sel, name
  Insert_Sel, newName

ENDFOR

END