pro redat1 xsize = 1280 ; pixelu. ysize = 512 ; pixelu. badpixel=intarr(xsize,ysize);matice poskozenych pixelu pom=intarr(xsize,ysize);pomocna matice aw=intarr(2);pozice horniho vlasce aw1=intarr(2);pozice spodniho vlasce awx=intarr(2);pozice sp cary sl=fltarr(2);pozice sterbiny faktor=10;presnost vypoctu offset=1;promenna urcujici posunuti u narovnavani car sloupec=intarr(ysize);pomocny sloupec pri posouvani sloupec1=intarr(ysize);pomocny sloupec pri posouvani approx=lon64arr(5,xsize);pomocne pole s pixely pro vypocet linearni regrese frame=lon64arr(xsize,ysize);pomocna matice vektor=fltarr(ysize*faktor);pomocny vektor pri posouvani vektorspec=fltarr(ysize*faktor);pomocny vektor pri posouvani vektorx=fltarr(xsize*faktor);pomocny vektor pri posouvani vektorspecx=fltarr(xsize*faktor);pomocny vektor pri posouvani x1=fltarr(xsize,ysize);pomocna matice ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;Vyber a zpracovani temnych snimku pom[*,*]=0 seznam_snimku=dialog_pickfile(/MULTIPLE_FILES,filter='*.fts',title='Vyberte prosim zdrojove snimky pro hlavni temny snimek') snimky=size(seznam_snimku) pocet_snimku=snimky[1] for l=0,pocet_snimku-1 DO BEGIN rawf=readfits(seznam_snimku[l],header) pom=pom+rawf END rawf=0.0+pom/pocet_snimku pozadi=median(rawf) rozsah=2*round(sqrt(pozadi)) odchylka = LON64ARR(pozadi) odchylka[*]=0 for k=0,1 do begin for i=0,xsize-1 do begin for j=0,ysize-1 do begin if k EQ 0 then if (rawf[i,j]-pozadi) GT -1 AND (rawf[i,j]-pozadi) LT rozsah then odchylka[rawf[i,j]-pozadi]=odchylka[rawf[i,j]-pozadi]+1 $ else if (rawf[i,j]-pozadi) LT -1 AND (rawf[i,j]-pozadi) GT rozsah then odchylka[abs(rawf[i,j]-pozadi)]=odchylka[abs(rawf[i,j]-pozadi)]+1 end end i=0 rozsah=0 ;sirka pasma funkcnich pixelu while odchylka[i] NE 0 do i=i+1 rozsah=rozsah+i-1 ;;print, odchylka, rozsah end badpixel=abs(rawf-pozadi-rozsah/2)+abs(rawf-pozadi+rozsah/2)-rozsah ;vysledkem je badpixel,rozsah a pozadi ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;Vyber a zpracovani snimku pro ff seznam_snimku=dialog_pickfile(/MULTIPLE_FILES,filter='*.fts',title='Vyberte prosim zdrojove snimky pro hlavni flat-field ') snimky=size(seznam_snimku) pocet_snimku=snimky[1] for l=0,pocet_snimku-1 DO BEGIN rawf=readfits(seznam_snimku[l],header) ;oprava pixelu se zmenenou citlivosti rawf=abs(rawf-pozadi) for i=0,xsize-1 do if badpixel[i,0] NE 0 then rawf[i,0]=rawf[i,1] for i=0,xsize-1 do begin for j=1,ysize-2 do begin if badpixel[i,j] NE 0 then rawf[i,j]=(rawf[i,j+1]+rawf[i,j-1])/2 ;print, rawf[i,j], i, j end end for i=0,xsize-1 do if badpixel[i,ysize-1] NE 0 then rawf[i,ysize-1]=rawf[i,ysize-2] aw[0]=4095 typ_snimku=0.0 for i=ysize/2,ysize-50 do begin if rawf[xsize/2,i-10] GT rawf[xsize/2,i] and rawf[xsize/2,i+10] GT rawf[xsize/2,i] then if rawf[xsize/2,i] LT aw[0] then begin;nalezeni 1. dratku aw[0]=rawf[xsize/2,i] aw[1]=i end end aw1[0]=4095 i=ysize/2 while rawf[xsize/2,i] GT rozsah and i GT 50 and rawf[xsize/2,i-10] GT rozsah do if rawf[xsize/2,i] LT aw1[0] then $;nalezeni 2. dratku begin aw1[0]=rawf[xsize/2,i] aw1[1]=i i=i-1 end else i=i-1 if l EQ 0 then begin frame=rawf+0.0 baseaw=aw[1] endif else frame=frame+rawf end frame=0.0+frame/pocet_snimku ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;Vyber a uprava datoveho snimku s2=readfits(pickfile(title='Vyberte prosim snimek ke zpracovani '),header) s2=abs(s2-pozadi) for i=0,xsize-1 do if badpixel[i,0] NE 0 then s2[i,0]=s2[i,1] for i=0,xsize-1 do begin for j=1,ysize-2 do begin if badpixel[i,j] NE 0 then s2[i,j]=(s2[i,j+1]+s2[i,j-1])/2 end end for i=0,xsize-1 do if badpixel[i,ysize-1] NE 0 then s2[i,ysize-1]=s2[i,ysize-2] ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;;detekce pozice dratku+detekce zmen pozice dratku (vytvareni seznamu bodu pro interpolaci) j=0 left=baseaw for i=xsize/2,0,-1 do begin if frame[i,left+1] lt frame[i,left] then left=left+1 $ else if frame[i,left-1] lt frame[i,left] then left=left-1 approx[0,j]=i approx[1,j]=left j=j+1 end approx[4,*]=frame[*,ysize/2] typ_snimku=moment(approx[4,*]) ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;Spektrum nebo sterbina? if typ_snimku[1]/typ_snimku[0] GT 30 then begin ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;spektrum ;;vodorovne vyrovnani ;;dopocet x^2 a xy pro linearni regresi i=0 while approx[1,i] NE 0 do begin approx[2,i]=approx[0,i]^2 approx[3,i]=approx[0,i]*approx[1,i] i=i+1 end ;; ;;vypocet koeficientu pro linearni regresi (y=ax+b i=n) e=(i*total(approx[3,*],2)-(total(approx[0,*],2))*(total(approx[1,*],2)))/(i*total(approx[2,*],2)-(total(approx[0,*],2))^2) print,e f=((total(approx[2,*],2))*(total(approx[1,*],2))-(total(approx[0,*],2))*(total(approx[3,*],2)))/(i*total(approx[2,*],2)-(total(approx[0,*],2))^2) print,f ;; ;;zvetseni s interpolaci,posun,zmenseni for i=0,xsize-1 do begin for j=0,ysize-2 do begin ;a,b b=frame[i,j] a=(frame[i,j+1]-b+0.0)/faktor ;smernice primky pri linearni interpolaci d=s2[i,j] c=(s2[i,j+1]-d+0.0)/faktor ;smernice primky pri linearni interpolaci for k=0,faktor-1 do begin vektor[j*faktor+k]=k*a+b vektorspec[j*faktor+k]=k*c+d end end offset=round(faktor*(e*i+f))-(baseaw*faktor) vektor=shift(vektor,-offset[0]) vektorspec=shift(vektorspec,-offset[0]) for j=0,ysize-1 do begin frame[i,j]=vektor[j*faktor] s2[i,j]=round(vektorspec[j*faktor]) end end rawf=frame ;;;vyhledani temne spektralni cary awx[0]=4095 for i=100,300 do begin if rawf[i-10,ysize/2] GT rawf[i,ysize/2] and rawf[i+10,ysize/2] GT rawf[i,ysize/2] then if rawf[i,ysize/2] LT awx[0] then begin;nalezeni 1. dratku awx[0]=rawf[i,ysize/2] awx[1]=i end end ;;svisle vyrovnani ;;detekce pozice dratku+detekce zmen pozice dratku (vytvareni seznamu bodu pro interpolaci) j=0 approx[*,*]=0 left=awx[1] for i=ysize/2,0,-1 do begin if frame[left+1,i] lt frame[left,i] then left=left+1 $ else if frame[left-1,i] lt frame[left,i] then left=left-1 approx[0,j]=i approx[1,j]=left j=j+1 end ;;dopocet x^2 a xy pro linearni regresi i=0 while approx[1,i] NE 0 do begin approx[2,i]=approx[0,i]^2 approx[3,i]=approx[0,i]*approx[1,i] i=i+1 end ;; ;;vypocet koeficientu pro linearni regresi (y=ax+b i=n) e=(i*total(approx[3,*],2)-(total(approx[0,*],2))*(total(approx[1,*],2)))/(i*total(approx[2,*],2)-(total(approx[0,*],2))^2) print,e f=((total(approx[2,*],2))*(total(approx[1,*],2))-(total(approx[0,*],2))*(total(approx[3,*],2)))/(i*total(approx[2,*],2)-(total(approx[0,*],2))^2) print,f ;; ;;zvetseni s interpolaci,posun,zmenseni for i=0,ysize-1 do begin for j=0,xsize-2 do begin ;a,b b=frame[j,i] a=(frame[j+1,i]-b+0.0)/faktor ;smernice primky pri linearni interpolaci d=s2[j,i] c=(s2[j+1,i]-d+0.0)/faktor ;smernice primky pri linearni interpolaci for k=0,faktor-1 do begin vektorx[j*faktor+k]=k*a+b vektorspecx[j*faktor+k]=k*c+d end end offset=round(faktor*(e*i+f))-(awx[1]*faktor) vektorx=shift(vektorx,-offset[0]) vektorspecx=shift(vektorspecx,-offset[0]) for j=0,xsize-1 do begin frame[j,i]=vektorx[j*faktor] s2[j,i]=round(vektorspecx[j*faktor]) end end for i=0,xsize-1 do x1[i,*]=median(frame[i,*])+0.0 x1=(0.0+frame)/x1 end else begin ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;sterbina sj=intarr(2) sj[0]=4095 for i=xsize/3,xsize-xsize/3 do begin if frame[i,ysize/2] LT sj[0] then begin;nalezeni sterbiny sj[0]=frame[i,ysize/2] sj[1]=i end end ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;konecne upravy x1=(frame+0.0)/((TOTAL(frame)+0.0)/(N_ELEMENTS(frame)+0.0)) x1=s2/x1 frame=round(x1) frame[sj[1],*]=0 ;dokreslit sterbinu end frame[*,baseaw]=0;dokresleni 1.dratku frame[*,aw1[1]]=0;dokresleni 2.dratku ; ; jmeno fits-souboru ze zkalibrovanym snimkem flfitsout=' ' print,'Jmeno fits souboru kde ulozit zkalibrovany snimek' print,'napiste jmeno bez pripony .fits, .fts, atd.' read,flfitsout,prompt='> ' flfitsout=flfitsout+'.fts' writefits,flfitsout , frame;ulozeni zkalibrovaneho snimku end