pro dogrism, inname,x,y,ext=ext,angle=angle,outext=outext,$ srcwid = srcwid, bkgoff1=bkgoff1, bkgwid1=bkgwid1, $ bkgoff2 = bkgoff2, bkgwid2 = bkgwid2,chatter=chatter, $ nodisplay = nodisplay,caldb=caldb,outfile=outfile ;+ ; NAME: ; DOGRISM ; PURPOSE: ; Wrapper for UVOTIMGRISM. Includes an image display of the results ; ; CALLING SEQUENCE: ; DOGRISM, file, x, y, [ EXT= , ANGLE=, OUTFILE= ; SRCWID=,BKGOFF1=,BKGWID1=,BKGOFF1=,BKGOFF2=, BKGWID2=] ; REQUIRED INPUTS: ; filename - scalar string giving name of the detector image ; X - numeric scalar giving X centroid of the zero order ; Y - numeric scalar giving Y centroid of the zero order ; ; OPTIONAL KEYWORD INPUTS: ; EXT - Integer GT 1 specifying then FITS extension to process. ; Default is EXT=1, i.e. process the first extension. ; Note that each extension must be processed separately, ; chatter - integer (1-5) controlling amount of informational display, ; default=4 ; outext - extension appended to the output .pha file output by UVOTIMGRISM ; Default is to append "_i.pha" to the root of the input file name ; where i is the Extension number. If outext is supplied then ; this name is appended after the extension number. ; Angle - the angle in degrees of the spectrum with respect to the rows of ; the detector image. This is passed directly to UVOTIMGRISM if supplied: ; otherwise defaults are used for the U grism (144.5 clocked, ; 151.4 unclocked) and V grism (140.5 clocked, 148.1 unclocked). ; /NoDisplay - if set, then the final output image is not displayed using ; imgrism.pro ; ; The optional keywords SRCWID, BKGOFF1, BKGWID1, BKGOFF1, BKGOFF2, ; and BKGWID2 are passed directly to UVOTIMGRISM ; EXAMPLE: ; IDL> dogrism,'sw00055201009ugu_dt2.img',1945.14,668.778,ext=2,ang=151.8 ; ; In this example, the user processes the second extension explicitly ; setting the grism angle to 151.8 degrees rather than use the default ; value of 151.4. Output files sw00055201009ugu_2.pha (and ; sw00055201009ugu_2_back.pha are created. ; ; MODIFICATION HISTORY: ; Written, W. Landsman SSAI Aug 2005 ;- teldir = '$CALDB/data/swift/uvota/bcf/teldef/' ;Location of teldef file if N_params() LT 3 then begin print,'Syntax - dogrism, inname, x, y, Ext = ' print,' Angle=, outfile=, srcwid=,bkgoff1=,bkgwid1=' return endif if N_elements(chatter) EQ 0 then chatter = '4' else $ chatter = strtrim(chatter,2) file = file_search(inname + ['','_dt.img','_dt.img.gz'],count=n) if N_elements(ext) EQ 0 then ext = 1 i_ext = strtrim(ext,2) h = headfits(file,ext=ext) filter = strtrim(sxpar(h,'FILTER'),2) wheelpos = sxpar(h,'WHEELPOS') if filter EQ 'UGRISM' then begin if wheelpos EQ 160 then begin if N_elements(angle) EQ 0 then angle = 144.5 endif else begin if N_elements(angle) EQ 0 then angle = 151.4 endelse wavemin = '1700' & wavemax = '4900' endif else if filter EQ 'VGRISM' then begin if wheelpos EQ 955 then begin if N_elements(angle) EQ 0 then angle = 140.5 endif else begin if N_elements(angle) EQ 0 then angle = 148.1 endelse wavemin = '2700' & wavemax = '6100' endif else message,'ERROR - Not a grism image ' + filter if (abs(x) GT 10) and (abs(y) GT 10) then begin xd = strtrim(string(x+1,f='(f9.3)'),2) yd = strtrim(string(y+1,f='(f9.3)'),2) endif else begin adxy,h,x,y,xd,yd xd = strtrim(string(xd,f='(f7.4)'),2) yd = strtrim(string(yd,f='(f7.4)'),2) endelse fdecomp,file,disk,dir,fname fname = gettok(fname,'_') app = '_' + i_ext if N_elements(outext) NE 0 then app = app + '_' + outext if N_elements(outfile) EQ 0 then outfile = fname + app + '.pha' if N_elements(backfile) EQ 0 then backfile = fname + app + '_back.pha' if N_elements(badpixfile) EQ 0 then badpix = '~/teldef/ugrism_bp.img+1' if N_elements(srcwid) EQ 0 then srcwid = '21' else srcwid = strtrim(srcwid,2) if N_elements(bkgwid1) EQ 0 then bkgwid1 = '20' else bkgwid1 = strtrim(bkgwid1,2) if N_elements(bkgwid2) EQ 0 then bkgwid2 = bkgwid1 else $ bkgwid2 = strtrim(bkgwid2,2) if N_elements(bkgoff1) EQ 0 then bkgoff1 = '7' else bkgoff1 = strtrim(bkgoff1,2) if N_elements(bkgoff2) EQ 0 then bkgoff2 = bkgoff1 else $ bkgoff2 = strtrim(bkgoff2,2) infile = file + '+' + i_ext script ='uvotimgrism infile=' + infile + ' outfile=' + outfile + $ ' ang=' + strtrim(angle,2) + $ ' backfile=' + backfile + ' badpixfile=' + badpix + $ ' wavefile=CALDB areafile=CALDB teldeffile=CALDB' + ' ra=-1 dec=-1' + $ ' sourcex=' + xd + ' sourcey=' + yd + ' chatter=' + chatter + ' clobber=y history=y ' +$ ' wavemin='+ wavemin + ' wavemax=' + wavemax + ' inreg=DEFAULT' + $ ' srcwid=' + srcwid + ' bkgwid1=' + bkgwid1 + ' bkgwid2=' + bkgwid2 + $ ' bkgoff1=' + bkgoff1 + ' bkgoff2=' + bkgoff2 print,script spawn,script,/sh if not keyword_set(nodisplay) then imgrism,outfile[0] return end