pro editsmei, infile, outfile, first=first, last=last @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; editsmei ; PURPOSE: ; Edits SMEI time series from ascii files ; CATEGORY: ; CALLING SEQUENCE: ; INPUTS: ; infile scalar; type: string; default: $TUB/03_148_02000_003.sm ; name of input file ; outfile scalar; type: string; default: .new ; name of output file ; OPTIONAL INPUT PARAMETERS: ; first scalar; type: integer ; index of first sky bin to be displayed ; last scalar; type: integer ; index of last sky bin to be displayed ; OUTPUTS: ; (written to output file) ; CALLS: ; InitVar, flt_read, BadValue, PlotCurve, pcursor ; PROCEDURE: ; All displayed time series can be edited ; Left-click selects a points; its data value is flagged as bad ; Right-click terminates the selection of points, and writes the modified ; data to the output file. ; MODIFICATION HISTORY: ; NOV-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, infile , filepath(root=getenv('TUB'),'03_148_02000_003.sm') InitVar, outfile, infile+'.new' ; Read input file, stop on error status = flt_read(infile, gg, fmt=fmt, error=error) if not status then message, error n_times = gg[2,0] ; # times is assumed to be the same for all sky bins n_bins = (size(gg,/dim))[1] ; # sky bins InitVar, first, 0 InitVar, last , 3 last = last < (n_bins-1) nplots = last-first+1 ra = reform(gg[0,*]) ; Right ascensions dec = reform(gg[1,*]) ; Declinations ;t_one = reform(gg[3,*]) ; First time for each sky bin i = 2*indgen(n_times) tt = gg[3+i,*] ; Times ff = gg[4+i,*] ; Intensities ascii_bad = min(ff) ; Bad data value in ascii file real_bad = BadValue(ff) ; Bad data value used for plotting i = where(ff eq ascii_bad) ; Replace ascii bad by real bad if i[0] ne -1 then ff[i] = real_bad !p.multi = [0,1,nplots] ; Stack nplots plots xmin = min(tt[*,first:last],max=xmax) xrange = [xmin,xmax] ; Use same x-axis for all plots for i=first, last do $ ; Display plots PlotCurve, tt[*,i], ff[*,i], xrange=xrange, xstyle=1, chars=1.5, $ psym=1, /silent repeat begin pcursor, xp, yp, /data ; Get cursor location err = !err ; Save !err for 'until' test if err eq 1 then begin ; Left-click selects points ; Determine data point nearest to cursor location. ; iplot is the plot used to select a point ; Only the horizontal coordinate is used to select a point iplot = last-fix( (convert_coord(xp,yp, /data, /to_normal))[1]*nplots ) tmp = min( abs(xp-tt[*,iplot]), itime) ff[itime,iplot] = real_bad ; Set selected point to bad for i=first, last do $ ; Display update data PlotCurve, tt[*,i], ff[*,i], xrange=xrange, xstyle=1, chars=1.5, $ psym=1, /silent endif endrep until err eq 4 ; Right-click terminates loop i = where( 1-finite(ff) ) ; Replace real bad by ascii bad if i[0] ne -1 then ff[i] = ascii_bad i = 2*indgen(n_times) gg[4+i,*] = ff ; Write updated data into original array message, /info, 'writing '+outfile ; Write into output file using same format as input file openw, iu, /get_lun, outfile for i=0,n_bins-1 do printf, iu, format=fmt, gg[*,i] free_lun, iu return & end