;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; This code calculates the fractional transmission based on an ecam image of a standard star ; ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; Define Gaussian to be fit ;---------------------------------------------------------------------------------------------- function gfunct, x, y, P ;define Gaussian to be fit F=P[0]*exp(-((x-P[1])^2/(2*(P[3]^2))+(y-P[2])^2/(2*(P[3]^2)))) return, F end ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; ----------------------------------------IMAGE SET 1------------------------------------------ ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; Define an image where the star was NOT in the slit, so the max flux ; can be determined and compared to when it is in the slit (the loop ; further down). ;---------------------------------------------------------------------------------------------- Print, "Image set 1\n" image=readfits('proc-e0030.fits') image=image+32768.0 xr=findgen(511) yc=findgen(511) x = 116 y = 261 ;b=floor(where(image eq max(image))/511.0) ;c=(where(image eq max(image))/511.0-floor(where(image eq max(image))/511.0))*511.0 ;---------------------------------------------------------------------------------------------- ; Find max and min pixel values of image ; Fit guassian function ; b = the x position of the max value pixel. The data is read as a ; list of values, so to find the row you need to divide by 511 (the ; number of pixels in the row) ; c = same as b except for the y position ; aper, image, c, b, flux, errflux, sky, skyerr, 1, [30], [50, 100], [0.0,30000.0], /flux ; aper = aperture function defined in idl. It will draw an aperature ; of a defined size. Here it's defined as 30 pixels in diameter (it ; assumes a circular aperture by default) ; ; flux = an idl routine that calculate the integrated flux of an ; aperture that was define ; ; sky = idl routine that find the integrated flux of a sky area same ; aperatue size as the previous aperature ; ; 0.0, 30000 sets the min and max value it will consider. This is a ; problem for stars that are faint because the cosmic rays will be ; brighter and not necessarily 30,000. You can set this down based on ; the higherst point of your star. ; ; [50, 100] is the annulus of the sky. The ring will go around the ; star from 50 though 100 pixels out from the star's central location. ; ; In order to try and sort out the cosmic rays from the star, try ; making a list of the top 15 max values or so and their location. ; Then check where the pixel values are in relation to each other. If ; it's a cosmic ray, it will only be 1-4, but a star will have them ; all together. Or you can do an aperature and integrated flux for ; each of the top 15 max positions and choose the one with the highest ; integrated flux to be your star. Just make sure to print out the ; max position so you can double check in the image that the spot is accurate. ;---------------------------------------------------------------------------------------------- aper, image, x, y, flux, errflux, sky, skyerr, 1, [15], [50, 100], [0.0,3000.0], /flux plot, yc, image[*,y], xrange=[190,240] ;---------------------------------------------------------------------------------------------- ; Loop through images where star is on slit ;---------------------------------------------------------------------------------------------- READCOL,'position_A0V.0001.dat',image_numb,x,y,FORMAT='A,I,I' ;Read 3 column data file with integer ;columns, assigned to the image number ;and the x and y position fraction=fltarr(N_ELEMENTS(image_numb)) start_img = 0036 end_img = 0058 tot_img = end_img - start_img + 1 for i=0, N_ELEMENTS(image_numb)-1 do begin print, i print, image_numb[i] ; image_numb[i] = strn(image_numb[i],FORMAT='(I04)') ; makes the image number an integer (I) of 4 characters, ; with all leading characters set to 0. If i = 88, then ; stringnumber is 0088, and if i = 100, then stringnumber = 0100. image2 = readfits('proc-e'+image_numb[i]+'.fits') image2=image2+32768.0 aper, image2, x[i], y[i], slitflux, slitfluxerr, skyslit, skysliterr, 1, [15], [50, 100], [0.0,30000.0], /flux fraction[i]=slitflux/flux print, fraction[i] endfor fraction=fraction(where(finite(fraction) eq 1)) print, fraction med=median(fraction) med=1-med ;actually want 1-transmission to get light in slit average=total(fraction)/size(fraction, /N_elements) average=1-average averagevector=replicate(average, tot_img) sigma=stddev(fraction) sigmavector=replicate(sigma, tot_img) plot, 1-fraction, psym=1 oplot, averagevector-sigmavector, linestyle=5 oplot, averagevector+sigmavector, linestyle=5 print, 'median=', med print, 'average=', average print, 'stddev=', sigma print, 'percent error=', sigma/average openw, 1, 'fluxcal1.txt' for i=0, size(fraction, /N_elements)-1 do begin printf, 1, i, string(9b), 1-fraction[i], string(9b), averagevector[i], string(9b), sigmavector[i] endfor close,1 print, 'enter 1 to continue' read, continue if continue eq 1 then begin endif else begin stop endelse ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; ----------------------------------------IMAGE SET 2------------------------------------------ ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- Print, "Image set 2\n" image=readfits('proc-e0063.fits') image=image+32768.0 xr=findgen(511) yc=findgen(511) x = 165 y = 242 aper, image, x, y, flux, errflux, sky, skyerr, 1, [17], [50, 100], [0.0,3000.0], /flux plot, yc, image[*,y], xrange=[190,240] ;---------------------------------------------------------------------------------------------- ; Loop through images where star is on slit ;---------------------------------------------------------------------------------------------- READCOL,'position_A0V.0002.dat',image_numb,x,y,FORMAT='A,I,I' ;Read 3 column data file with integer ;columns, assigned to the image number ;and the x and y position fraction=fltarr(N_ELEMENTS(image_numb)) start_img = 0075 end_img = 0123 tot_img = end_img - start_img + 1 for i=0, N_ELEMENTS(image_numb)-1 do begin print, i print, image_numb[i] ; image_numb[i] = strn(image_numb[i],FORMAT='(I04)') ; makes the image number an integer (I) of 4 characters, ; with all leading characters set to 0. If i = 88, then ; stringnumber is 0088, and if i = 100, then stringnumber = 0100. image2 = readfits('proc-e'+image_numb[i]+'.fits') image2=image2+32768.0 aper, image2, x[i], y[i], slitflux, slitfluxerr, skyslit, skysliterr, 1, [17], [50, 100], [0.0,30000.0], /flux fraction[i]=slitflux/flux print, fraction[i] endfor fraction=fraction(where(finite(fraction) eq 1)) print, fraction med=median(fraction) med=1-med ;actually want 1-transmission to get light in slit average=total(fraction)/size(fraction, /N_elements) average=1-average averagevector=replicate(average, tot_img) sigma=stddev(fraction) sigmavector=replicate(sigma, tot_img) plot, 1-fraction, psym=1 oplot, averagevector-sigmavector, linestyle=5 oplot, averagevector+sigmavector, linestyle=5 print, 'median=', med print, 'average=', average print, 'stddev=', sigma print, 'percent error=', sigma/average openw, 1, 'fluxcal2.txt' for i=0, size(fraction, /N_elements)-1 do begin printf, 1, i, string(9b), 1-fraction[i], string(9b), averagevector[i], string(9b), sigmavector[i] endfor close,1 print, 'enter 1 to continue' read, continue if continue eq 1 then begin endif else begin stop endelse ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; ----------------------------------------IMAGE SET 3------------------------------------------ ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- Print, "Image set 3\n" image=readfits('proc-e1390.fits') image=image+32768.0 xr=findgen(511) yc=findgen(511) x = 92 y = 270 aper, image, x, y, flux, errflux, sky, skyerr, 1, [13], [50, 100], [0.0,3000.0], /flux plot, yc, image[*,y], xrange=[190,240] ;---------------------------------------------------------------------------------------------- ; Loop through images where star is on slit ;---------------------------------------------------------------------------------------------- READCOL,'position_A0V.0003.dat',image_numb,x,y,FORMAT='A,I,I' ;Read 3 column data file with integer ;columns, assigned to the image number ;and the x and y position fraction=fltarr(N_ELEMENTS(image_numb)) start_img = 1404 end_img = 1427 tot_img = end_img - start_img + 1 for i=0, N_ELEMENTS(image_numb)-1 do begin print, i print, image_numb[i] ; image_numb[i] = strn(image_numb[i],FORMAT='(I04)') ; makes the image number an integer (I) of 4 characters, ; with all leading characters set to 0. If i = 88, then ; stringnumber is 0088, and if i = 100, then stringnumber = 0100. image2 = readfits('proc-e'+image_numb[i]+'.fits') image2=image2+32768.0 aper, image2, x[i], y[i], slitflux, slitfluxerr, skyslit, skysliterr, 1, [13], [50, 100], [0.0,30000.0], /flux fraction[i]=slitflux/flux print, fraction[i] endfor fraction=fraction(where(finite(fraction) eq 1)) print, fraction med=median(fraction) med=1-med ;actually want 1-transmission to get light in slit average=total(fraction)/size(fraction, /N_elements) average=1-average averagevector=replicate(average, tot_img) sigma=stddev(fraction) sigmavector=replicate(sigma, tot_img) plot, 1-fraction, psym=1 oplot, averagevector-sigmavector, linestyle=5 oplot, averagevector+sigmavector, linestyle=5 print, 'median=', med print, 'average=', average print, 'stddev=', sigma print, 'percent error=', sigma/average openw, 1, 'fluxcal3.txt' for i=0, size(fraction, /N_elements)-1 do begin printf, 1, i, string(9b), 1-fraction[i], string(9b), averagevector[i], string(9b), sigmavector[i] endfor close,1 print, 'enter 1 to continue' read, continue if continue eq 1 then begin endif else begin stop endelse ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- ; ----------------------------------------IMAGE SET 4------------------------------------------ ;---------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------- Print, "Image set 4\n" image=readfits('proc-e2454.fits') image=image+32768.0 xr=findgen(511) yc=findgen(511) x = 45 y = 312 aper, image, x, y, flux, errflux, sky, skyerr, 1, [7], [60, 65], [0.0,3000.0], /flux plot, yc, image[*,y], xrange=[190,240] ;---------------------------------------------------------------------------------------------- ; Loop through images where star is on slit ;---------------------------------------------------------------------------------------------- READCOL,'position_A0V.0014.dat',image_numb,x,y,FORMAT='A,I,I' ;Read 3 column data file with integer ;columns, assigned to the image number ;and the x and y position fraction=fltarr(N_ELEMENTS(image_numb)) start_img = 2477 end_img = 2505 tot_img = end_img - start_img + 1 for i=0, N_ELEMENTS(image_numb)-1 do begin print, i print, image_numb[i] ; image_numb[i] = strn(image_numb[i],FORMAT='(I04)') ; makes the image number an integer (I) of 4 characters, ; with all leading characters set to 0. If i = 88, then ; stringnumber is 0088, and if i = 100, then stringnumber = 0100. image2 = readfits('proc-e'+image_numb[i]+'.fits') image2=image2+32768.0 aper, image2, x[i], y[i], slitflux, slitfluxerr, skyslit, skysliterr, 1, [7], [60, 65], [0.0,30000.0], /flux fraction[i]=slitflux/flux print, fraction[i] endfor fraction=fraction(where(finite(fraction) eq 1)) print, fraction med=median(fraction) med=1-med ;actually want 1-transmission to get light in slit average=total(fraction)/size(fraction, /N_elements) average=1-average averagevector=replicate(average, tot_img) sigma=stddev(fraction) sigmavector=replicate(sigma, tot_img) plot, 1-fraction, psym=1 oplot, averagevector-sigmavector, linestyle=5 oplot, averagevector+sigmavector, linestyle=5 print, 'median=', med print, 'average=', average print, 'stddev=', sigma print, 'percent error=', sigma/average openw, 1, 'fluxcal4.txt' for i=0, size(fraction, /N_elements)-1 do begin printf, 1, i, string(9b), 1-fraction[i], string(9b), averagevector[i], string(9b), sigmavector[i] endfor close,1 print, 'enter 1 to continue' read, continue if continue eq 1 then begin endif else begin stop endelse stop end