; STARID.PRO ; ;This program is designed to identify stars in an auroral or airglow ;image; specifically those taken at Rabbit Lake. The purpose of this is so that ;the exact position of the star will be known in row and column terms of the ;image, and by comparing these coordinates with known positions of the stars at ;the time of the exposure, a correlation between image position and sky position ;can be established. ;The process compares the image with those taken directly before and ;after the specified image, so the program will read in the specified image and ;the images preceeding and proceeding the specified image. The images chosen are ;based on the camera and filter numbers, the exposure time and consecutive image ;numbers. Since the program is to be used to identify stars, the ideal images ;are those with clearly visible stars and almost no cloud or aurora. ; ; MODES : 0 - Aurora; 1 - Bias; 2 - Calibration; 3 - Dark Frame; 4 - Flat Field; ; 5 - Airglow ;Modified on May 8, 1994 by T A Oliynyk: can now be used on unix or dos machines. PRO starid,day,cam,filt,binfac,texp,mode,imnum,sdev,amp,readdk=readdk IF N_PARAMS() LT 7 THEN BEGIN MESSAGE,'Usage: starid,day,cam,filt,binfac,texp,mode,imnum[,sdev,amp,/readdk]' $ ,/INFORMATIONAL MESSAGE,'Mode: 0=aurora 1=bias 2=cal 3=dark 4=flat 5=airglow' $ ,/INFORMATIONAL RETURN ENDIF ; Define OS-dependent parameters @isitdos IF N_PARAMS() EQ 7 THEN BEGIN sdev=3 amp=3 ENDIF cols=512/binfac rows=cols ;initializing variables rimg = INTARR(cols,rows,3) ; array of the 3 images to be compared pimg = rimg & dimg = rimg IF N_Elements(readdk) GT 0 THEN readdk=1 ELSE readdk=0 IF readdk THEN BEGIN STOP dkpath=iroot+dd+imagetype(3)+dd+cc+StrTrim(Fix(cam),2) dkfilt=String(day,Format='("d",I2.2,"*.*")') dkname=PickFile(path=dkpath,filter=dkfilt,/read) rdkimg,dkname,dkhd,dk ENDIF ELSE rdmeandk,FIX(cam),FIX(texp),dk dksize=SIZE(dk) IF dksize(1) NE cols THEN dk=binf(dk,dksize(1)/cols) WHILE imnum-1 LT 0 DO BEGIN ;cannot have an extension number less than zero PRINT,'Choose a new image number; no image previous to this one' READ,imnum ENDWHILE path = STRING(mpaths(mode),dd,cc,cam,dd,ff,filt,dd,firstchars(mode),day $ ,cam,filt,texp,imnum $ ,FORMAT='(A,A1,A,I1,A1,A,I1,A1,A,I2.2,2I1,I3.3,".",I3.3)') path=STRLOWCASE(path) ;filename of image ;find all images with the same filename, excluding the extension ;this is used to find the images previous to and following the image path2=STRING(mpaths(mode),dd,cc,cam,dd,ff,filt,dd,firstchars(mode),day $ ,cam,filt,texp $ ,FORMAT='(A,A1,A,I1,A1,A,I1,A1,A,I2.2,2I1,I3.3,".*")') fl=rfindfile(path2) w=where(fl eq path) w=w(0) file=strarr(3) ;read in the image, the one with the same cam, filt, exposure, one image before ;the specified image, and the image after. FOR j=w-1,w+1 DO file(j-(w-1))=fl(j) FOR i=0,2 DO BEGIN print,file(i),FORM='("READING : ",A)' rdkimg,file(i),hb,ximg kh = gethd(hb) help,/st,kh.misc.tm rimg(*,*,i) = ximg(*,*) IF i EQ 1 THEN head = hb ENDFOR medsize=cols/64+1 dilsize=medsize+cols/128 FOR i=0,2 DO BEGIN tmp0=rimg(*,*,i)-dk IF i EQ 1 THEN umed=tmp0 pimg(*,*,i)=tmp0-MEDIAN(tmp0,medsize) sig=stdev(pimg(*,*,i),mean) IF i EQ 1 THEN u=mean pimg(*,*,i)=(pimg(*,*,i)-mean)/sig cell=REPLICATE(1B,dilsize,dilsize) dimg(*,*,i)=DILATE((pimg(*,*,i) GT sdev),cell) ENDFOR simg=TOTAL(dimg,3) nimg=(simg GT 2) stimg=nimg*(pimg(*,*,1) GT sdev) wkimg=(rimg(*,*,1)-dk)+amp*umed*stimg stars=WHERE(stimg) !ORDER=1 WINDOW,0,XSIZE=512,YSIZE=512 tvscl,rimg(*,*,1)