;+ ; NAME: ; GETSIG ; PURPOSE: ; Determine significant pixels in both Polar Camera fields of view. ; CATEGORY: ; ; CALLING SEQUENCE: ; GETSIG, YEAR, MONTH, DAY, MASK0, MASK1 ; INPUTS: ; YEAR, MONTH, DAY: Numeric parameters specifying the date. ; Note: YEAR can have 2 or 4 digits. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /DEBUG: If set, shows the names of the files read. ; OUTPUTS: ; MASK0, ; MASK1: 256x256 byte arrays with 1's in the significant ; pixels and 0's elsewhere. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; None. ; RESTRICTIONS: ; File names are specific to the Unix network. It could be ; generalized to work on a PC. ; PROCEDURE: ; The appropriate file is determined for the specified date. ; The binary file containing the subscripts of the significant ; pixels is read, and the corresponding pixels of a 256x256 ; byte array are set to 1. The byte array is returned. ; EXAMPLE: ; GETSIG,1994,11,1,mask0,mask1 ; gets the significant pixels ; ; on November 1, 1994. ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Written by: D P Steele, March 1994. ; Modified and documented by D P Steele, March 27, 1995. ;- PRO getsig,year,month,day,mask0,mask1,debug=debug @isitdos ; First step toward making routine host-nonspecific ; Make sure year looks right. IF year LT 1900 THEN $ IF year LT 50 THEN year=year+2000 ELSE year=year+1900 ; Need to decide which significant-pixels file to use. ; Identify different sets by their camera 0 entries. sg0=rfindfile(root+dd+'sg0?????.dat',count=nsg0) ; Save Julian dates and date strings. jdate=LONARR(nsg0) ds=jdate ; Locate filename beginnings in filepath strings. p=STRPOS(sg0,'sg0') FOR i=0,nsg0-1 DO BEGIN ; Extract date string. ds(i)=LONG(STRMID(sg0(i),p(i)+3,5)) ; Get year and day number of year. fyear=1900+ds(i)/1000 dn=ds(i) MOD 1000 ydn2md,fyear,dn,fmonth,fday ; Compute Julian date corresponding to date string. jdate(i)=julday(fmonth,fday,fyear) ENDFOR ; Julian date of observations. odate=julday(month,day,year) ; Time from significant-pixel date to observation date. diff=odate-jdate IF MAX(diff) LT 0 THEN BEGIN ; No good if obs. predate significant-pixel images! MESSAGE,'Observations earlier than first significant-pixel images!' $ ,/INFORMATIONAL d256=SHIFT(dist(256),128,128) mask0=BYTE(d256 LT 151) mask1=mask0 RETURN ENDIF ELSE BEGIN ; Flag significant-pixel files pertaining after observations. IF MIN(diff) LT 0 THEN diff(WHERE(diff LT 0))=99999 ; Find last significant-pixel set taken before date of observations. mindiff=MIN(diff,n) ENDELSE ; Now we know the right significant-pixel files, go get 'em. npix=0L mask0=BYTARR(256,256) mask1=mask0 FOR j=0,1 DO BEGIN sgname=STRING(j,ds(n),FORMAT='("sg",I1,I5,".dat")') IF KEYWORD_SET(debug) THEN PRINT,'Reading '+root+dd+sgname OPENR,sgunit,root+dd+sgname,/GET_LUN READU,sgunit,npix IF dos THEN BYTEORDER,npix,/HTONL six=LONARR(npix) READU,sgunit,six FREE_LUN,sgunit IF dos THEN BYTEORDER,six,/HTONL CASE j OF 0: mask0(six)=1 1: mask1(six)=1 ENDCASE ENDFOR RETURN END