PRO go2, inputfile ; Program to do the non-linearity correction for NSFCam device, decomposed=0 TVLCT, 255, 0, 0, 1 ; red TVLCT, 255, 150, 0, 2 ; orange TVLCT, 255, 255, 0, 3 ; yellow TVLCT, 0, 255, 0, 4 ; green TVLCT, 0, 255, 150, 5 ; green-blue TVLCT, 0, 255, 255, 6 ; blue-green TVLCT, 50, 50, 255, 7 ; blue TVLCT, 150, 0, 255, 8 ; indigo TVLCT, 255, 0, 255, 9 ; violet TVLCT, 0, 0, 230, 10 ; aqua TVLCT, 230, 230, 230, 11 ; light gray TVLCT, 150, 150, 255, 12 ; light blue ;********************************************************************** ; Read in fit coefficients, and data to be corrected ;********************************************************************** print, 'input file is:', inputfile help, inputfile coeff0 = READFITS('/Users/msc/irtf/nsfcam2/coeff0.fits') coeff1 = READFITS('/Users/msc/irtf/nsfcam2/coeff1.fits') coeff2 = READFITS('/Users/msc/irtf/nsfcam2/coeff2.fits') coeff3 = READFITS('/Users/msc/irtf/nsfcam2/coeff3.fits') coeff4 = READFITS('/Users/msc/irtf/nsfcam2/coeff4.fits') uc = READFITS(inputfile) ; this is the data to be corrected ; uc = uncorrected substring = '_corrected.fits' ; string to be inserted into filename expression = '.fits' ; part of string to be replaced in filename output = strjoin(strsplit(inputfile, expression, /regex, /extract, /preserve_null), substring) ; print, 'output string = ', output ; help, output ; strreplace, inputfile, '.fits', 'corrected.fits' ; print, inputfile lc = dblarr(2048,2048); this is the array for the corrected image ; lc = linearity corrected FOR i=0, 2047 DO BEGIN ; nested loops to address each pixel FOR j=0, 2047 DO BEGIN lc[i,j] = uc[i,j]*(1.0 + coeff0[i,j] + coeff1[i,j]*uc[i,j] + coeff2[i,j]*uc[i,j]^2 + coeff3[i,j]*uc[i,j]^3 + coeff4[i,j]*uc[i,j]^4) ENDFOR ENDFOR ;strreplace, inputfile, '.fits', 'corrected.fits' ;print, inputfile ; wait, 60 writefits, output, lc end