; ---------------------------------------------------------------------- ; Correct the image (un-slant and un-curve). -tab 19jan2018 ; Also, clean the image first. ; pro nsx_correct_image, IMG, SOP1, SOP2, AVP, SPX, NoClean, NoHotClean, nsxdir, NoFlat common nsx nc = IMG[0].nc ; /* nominal 2048 */ nr = IMG[0].nr ; /* nominal 1024 */ ;float *clnimgNFD; /* clean image with No Flat Division */ ;float *fltimg; ; Allocate. */ clnimgNFD = PTR_NEW( fltarr(nc, nr) ) fltimg = PTR_NEW( fltarr(nc, nr) ) ; Clean the original image (remove CRs and hot spots). */ print, format='("Cleaning CRs and hot spots from image (",A,").")',IMG.root for ii=0, (nc*nr)-1 do (*IMG.clnimg)[ii] = (*IMG.image)[ii] rr0 = SYSTIME(/SECONDS) ; timegetsec8(); nsx_clean_image, IMG, SPX, NoClean, NoHotClean, nsxdir rr1 = SYSTIME(/SECONDS) ; timegetsec8(); print, format='("... ",F," seconds")',rr1-rr0 for ii=0,(nc*nr)-1 do (*clnimgNFD)[ii] = (*IMG.clnimg)[ii] ; Flat division. ;> NoFlat eq 1 ;if (NoFlat == 0) { ; sprintf(wrd,"%scal/flatnorm-180304.fits",nsxdir); ; nsx_read_general_image( wrd, fltimg, nc, nr ); ; for (ii=0; ii<(nc*nr); ++ii) { IMG[0].clnimg[ii] = IMG[0].clnimg[ii] / fltimg[ii]; } ; fprintf(logfu,"Completed flat field correction using '%s'.\n",wrd); ; printf( "Completed flat field correction using '%s'.\n",wrd); ;} else { ; fprintf(logfu,"No flat field correction has been done.\n"); ; printf( "No flat field correction has been done.\n"); ;} ; Zero for ii=0,nc-1 do begin for jj=0,nr-1 do begin pixno = ii + (jj * long(nc)) (*IMG.corimg)[pixno] = 0. endfor endfor ; For 2017 calibration, I used 0.2 arcsec per pixel and use nso=3 width. asinc = ARCSEC_PER_PIXEL asnum = SPX[3].numpro - 1 asmax = asinc * double(asnum) print,format='("Correct image using asinc=",F," asmax=",F," asnum=",I,"")',asinc,asmax,asnum ; Each order. for nso=3,7 do begin if (nso eq 7) then ecol=nc/2 else ecol=nc jjoff = ((7-nso) * 200) ; Each column (where a 'column' starts at lower edge and then slants up). for icol=0L,ecol-1 do begin edge = nsx_find_real_image_row( 1, icol, nso ) for as=0.,asmax,asinc do begin ; Select row (offset from edge) boundaries on arcsec scale. rba = edge + nsx_AVPinv( AVP, nso, icol, as, IMG ) rbb = edge + nsx_AVPinv( AVP, nso, icol, as+asinc, IMG ) rbave = (rba + rbb) / 2. rowoff = rbave - edge ; Column range using actual 'rowoff' value. nsx_slant_boundaries_SOP2, nso, icol, rowoff, SOP1, SOP2, ecol, cb1, cb2 ; Fractional pixel. nsx_fractional_pixel_2D, nc, IMG.clnimg, cb1, cb2, rba, rbb, imgsum nsx_fractional_pixel_2D, nc, clnimgNFD , cb1, cb2, rba, rbb, imgsumNFD ii = icol jj = jjoff + cnint(( as / asinc )) pixno = ii + (jj * nc) (*IMG.corimg)[pixno] = imgsum (*IMG.corimgNFD)[pixno] = imgsumNFD endfor ; as endfor ; icol endfor ; nso ; Trim out first 12 columns and last 4 columns of corimg[]. for jj=0,nr-1 do begin for ii=0,12-1 do begin pixno=ii+(jj*long(nc)) (*IMG.corimg)[pixno]=0. (*IMG.corimgNFD)[pixno]=0. endfor for ii=nc-4,nc-1 do begin pixno=ii+(jj*long(nc)) (*IMG.corimg)[pixno]=0. (*IMG.corimgNFD)[pixno]=0. endfor endfor nsx_write_general_image,"clnimg.fits", IMG[0].clnimg, nc, nr nsx_write_general_image, "clnimgNFD.fits", clnimgNFD, nc, nr nsx_write_general_image, "corimg.fits", IMG[0].corimg, nc, nr nsx_write_general_image, "corimgNFD.fits", IMG[0].corimgNFD, nc, nr ptr_free, clnimgNFD ptr_free, fltimg end