; NAME: ; darkjumbo2.pro ; ; PURPOSE: ; This program analyzes dark current images and produces a plot of ; dark current per image as a function of time. ; ; CALLING SEQUENCE: ; darkjumbo2,filename,detector ; ; INPUTS: ; filename containing filenames of images ; detector name ; ; KEYWORD PARAMETERS: ; none ; ; ; EXAMPLE ; darkjumbo2,'/mydirectory/myfile.txt','H1RG-002-5.0mu' ; ; ; REFERENCE: ; ; MODIFICATION HISTORY: ; Written by: Sungsoo Kim & Don Figer, IDTL, August 16, 2002 ; Ernie Morse, IDTL, Nov. 26, 2002 ; Changed name of main function to darkjumbo2 to match file name ; ; Don Figer, IDTL, April 23, 2003 ; Cleaned up code, modified plot characteristics ; ; Ernie Morse, IDTL, April 23, 2003 ; Changed determination of y-axis range and changed to printing detector temperatures ; as integers ; ;- FUNCTION getdatestring, hours ; leap month calculation valid until 2099 days = ceil(hours / 24) leapdays = days / 1461 year = (days - leapdays) / 365 dayofyear = (days - (leapdays * 1461)) mod 365 leap = 0 if((year mod 4) eq 0) then leap = 1 CASE 1 OF (dayofyear ge 0) AND (dayofyear le 31): month = '1' (dayofyear ge 32) AND (dayofyear le (59+leap)): month = '2' (dayofyear ge (60+leap)) AND (dayofyear le (90+leap)): month = '3' (dayofyear ge (91+leap)) AND (dayofyear le (120+leap)): month = '4' (dayofyear ge (121+leap)) AND (dayofyear le (151+leap)): month = '5' (dayofyear ge (152+leap)) AND (dayofyear le (181+leap)): month = '6' (dayofyear ge (182+leap)) AND (dayofyear le (212+leap)): month = '7' (dayofyear ge (213+leap)) AND (dayofyear le (243+leap)): month = '8' (dayofyear ge (244+leap)) AND (dayofyear le (273+leap)): month = '9' (dayofyear ge (278+leap)) AND (dayofyear le (304+leap)): month = '10' (dayofyear ge (305+leap)) AND (dayofyear le (334+leap)): month = '11' (dayofyear ge (335+leap)) AND (dayofyear le (365+leap)): month = '12' ELSE: begin print,'Problem with month2days: ',month stop end ENDCASE CASE 1 OF (month eq '1'): day = strtrim(string(dayofyear),2) (month eq '2'): day = strtrim(string(dayofyear mod 31),2) (month eq '3'): day = strtrim(string(dayofyear mod (59+leap)),2) (month eq '4'): day = strtrim(string(dayofyear mod (90+leap)),2) (month eq '5'): day = strtrim(string(dayofyear mod (120+leap)),2) (month eq '6'): day = strtrim(string(dayofyear mod (151+leap)),2) (month eq '7'): day = strtrim(string(dayofyear mod (181+leap)),2) (month eq '8'): day = strtrim(string(dayofyear mod (212+leap)),2) (month eq '9'): day = strtrim(string(dayofyear mod (243+leap)),2) (month eq '10'): day = strtrim(string(dayofyear mod (273+leap)),2) (month eq '11'): day = strtrim(string(dayofyear mod (304+leap)),2) (month eq '12'): day = strtrim(string(dayofyear mod (334+leap)),2) ELSE: begin print,'Problem with month2days: ',month stop end ENDCASE return, month+'/'+day+'/'+strtrim(string(year+2001),2) END PRO darkjumbo2,testdir, outdir=outdir, infile=infile ; set plot margins !y.margin=[6,2] !x.margin=[14,4] ; set directory according to whether using a PC or workstation if (!version.os_family eq 'unix') then begin delim = '/' endif else begin delim = '\' endelse ; set outdir equal to testdir if outdir is not set if (not keyword_set(outdir)) then outdir = testdir ; set plotting devices devicesave=!d.name set_plot,'ps' ; define the default file that contains the list of filenames of images if (not keyword_set(infile)) then begin infile = testdir+delim+'darkjumbo.txt' endif else begin infile = testdir+delim+infile endelse rdmode = (region = (scaname = (refcor_version = (refcor_type = '')))) ; read image parameters from input file openr, lun1, infile, /get_lun readf, lun1, scaname, format='(A)' readf, lun1, rdmode, format='(A)' readf, lun1, refcor_version, format='(A)' readf, lun1, refcor_type, format='(A)' readf, lun1, region, format='(A)' free_lun, lun1 ; read list of files from input file readcol, infile, files, dsub, hour, slope, format='A,F,F,F', skipline=5 startdate = getdatestring(hour[0]) ; round temperatures to nearest integer and make an array of the unique temperature values sortdsub = dsub[sort(dsub)] udsub = sortdsub[uniq(sortdsub)] ; define plot limits hour = hour - min(hour) xmax = max(hour) ymax = max(slope) xmin = min(hour) ymin = min(slope(where(slope gt 0))) xrng = (xmax - xmin) / 0.8 yrng = (ymax - ymin) / 0.7 ylo = (0.0 - yrng*0.15) < (ymin - yrng*0.15) yhi = ymax + yrng*0.15 xlo = xmin - xrng*0.1 xhi = xmax + xrng*0.1 ; define plot symbols symbols = [2, 4, 5, 6, 7, 1, 8, 8] nplots = ceil(n_elements(udsub)/float(n_elements(symbols))) ; draw curves for np=0,nplots-1 do begin ; define forground and background colors white = 255 black = 0 ; define plot file names psfile = outdir+delim+'darkjumbo_'+scaname + '_' + strtrim(string(np),2) + '.ps' jpgfile = outdir+delim+'darkjumbo_'+scaname + '_' + strtrim(string(np),2) + '.jpg' for plotcount=0,1 do begin if (plotcount eq 0) then begin ;set up for landscape Postscript plotting set_plot, 'ps' !p.font=-1 device, filename= psfile, /landscape fsub = psfile ;filename to be written at bottom of plot !x.minor = 10 !y.minor = 10 !y.margin=[6,2] !x.margin=[14,4] ; set line and text characteristics for publication quality !P.CHARSIZE=1.2 !P.CHARTHICK=4. !X.THICK=8. !Y.THICK=8. !P.THICK=8. !P.MULTI=0 !P.TICKLEN=0.03 symsize=1.5 filenamecharsize=1.1 endif else begin ;set up to plot to memory buffer. This plot will later be written from memory to a JPEG file. set_plot, 'z' device, set_resolution=[8000,6000] device, set_font='Courier' fsub = jpgfile ;filename to be written at bottom of plot ;set plot margin & tick marks !Y.MINOR=10 !x.minor=10 !y.margin=[6,4] !x.margin=[14,4] ; set line and text characteristics for publication quality !P.CHARSIZE=10 !P.CHARTHICK=15. !X.THICK=20. !Y.THICK=20. !P.THICK=20. symsize=10. filenamecharsize=8. endelse ; The series will be represented by big filled circles _radius = 1.0 ; Offset radius is about size of a character _X = fltarr(10) ; Place for x verticies, offset from point _Y = fltarr(10) ; Place for y verticies, offset from point _theta = 0 ; Position angle _delta_theta = 2 * !PI / 10 ; Angle step size for i=0, 9 do begin _X[i] = _radius * cos(_theta) ; Project radius onto x axis _Y[i] = _radius * sin(_theta) ; Project radius onto y axis _theta = _theta + _delta_theta ; Increment angle endfor ; make plot axes plot,[0],[0],/nodata,xrange=[xlo,xhi],xstyle=1,ystyle=1, $ xtitle='Time (hours)',ytitle='Dark Current (ADU/s)', title='Dark Current for '+scaname, $ color=black, background=white,charsize=!P.CHARSIZE*1.4,/ylog,yrange=[1e-4,(1 > (ymax*2))] ; ,yrange=[ylo,yhi] ; add line through zero oplot,[!X.CRANGE(0),!X.CRANGE(1)],[0,0],linestyle=0,color=black startdsub = n_elements(symbols)*np enddsub = startdsub + n_elements(symbols) - 1 if (enddsub ge n_elements(udsub)) then enddsub = n_elements(udsub)-1 dsubslice = udsub[startdsub:enddsub] xloc = xlo + xrng*0.05 yloc = yhi ; add data points for each temperature to plot for i=0, n_elements(dsubslice)-1 do begin idsub = where(dsub eq dsubslice[i]) xdata = hour[idsub] ydata = slope[idsub] ;sort data for plotting ptorder = sort(xdata) xdata = xdata[ptorder] ydata = ydata[ptorder] case i mod n_elements(symbols) OF 6: usersym, _X, _Y, /FILL ; Define the symbol 7: usersym, [-1, -0.5, 0.5, 1, 0.5, -0.5, -1], [0, 0.5, 0.5, 0, -0.5, -0.5, 0], /fill else: endcase ; draw curves oplot,xdata,ydata,psym=symbols[i mod n_elements(symbols)], color=black,symsize=symsize ; make legend offset=0.15 oplot,[!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.86],[1.5*10^(!Y.CRANGE(0)+offset*i)], psym=symbols[i mod n_elements(symbols)], color=black,symsize=symsize xyouts,[!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.88],[1.4*10^(!Y.CRANGE(0)+offset*i)],strtrim(string(dsubslice[i], format='(F4.2)'),2) + ' V', color=black ;string(float(tempslice[i]),format='(f4.1)')+' K', color=black endfor ; add legend offset=0.16 xyouts, [!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.05], [1.5*10^(!Y.CRANGE(0)+0*offset)], 'Start date: ' + startdate, color=black xyouts, [!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.05], [1.5*10^(!Y.CRANGE(0)+1*offset)], 'Refsub Type: ' + refcor_type, color=black xyouts, [!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.05], [1.5*10^(!Y.CRANGE(0)+2*offset)], 'Refsub Version: ' + refcor_version, color=black ;xyouts, [!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.05], [1.5*10^(!Y.CRANGE(0)+3*offset)], 'Read Mode: ' + rdmode, color=black xyouts, [!X.CRANGE(0)+(!x.CRANGE(1)-!x.CRANGE(0))*0.05], [1.5*10^(!Y.CRANGE(0)+3*offset)], 'Analysis Region: ' + region, color=black ; add file name to bottom of plot xyouts, 1.0, 40.0, fsub, color=black, charsize=filenamecharsize, /device ; write JPG image file if (plotcount eq 1) then begin xyouts, 1.0, 0.0, '_', /device jpgimg = tvrd() write_jpeg, jpgfile, congrid(jpgimg, 1280, 960, /interp, /center), quality=100 endif device, /close endfor endfor ; restore plotting device to original set_plot,devicesave END