; ---------------------------------------------------------------------- ; Correct the image (un-slant and un-curve). -tab 19jan2018 ; Also, clean the image first. ;> if not already cleaned ; pro nsxng_correct_image, IMG, SOP1, SOP2, AVP, SPX, NCP, NoClean, NoHotClean ; common nsx c = nsxng_constants() ARCSEC_PER_PIXEL = c.ARCSEC_PER_PIXEL NoFlat = 1 nc = IMG[0].nc ; /* nominal 2048 */ nr = IMG[0].nr ; /* nominal 1024 */ ;float *clnimgNFD; /* clean image with No Flat Division */ ;float *fltimg; if not ptr_valid(IMG.clnimg) then nsxng_clean_image, IMG, SPX, NoClean, NoHotClean, NCP ; 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