pro block_hand,zdb=zdb ; This routine prompts the user for information needed to construct ; an entry in the "blocks" database. It assumes that blocks begin and ; end on reference field observations, hence searches the images database ; for those falling near to known reference field coords, on a specified night. ; If the blocks database does not exist, it is created. ; constants timez=7 ; timezone -- local time = UT -timez tstrt=15 ; earliest plausible start time, local hours tend=34 ; latest plausible end time, local hours (>24 ok) rad2deg=57.295 ; degrees per radian raref=[7.533,12.762,14.467,15.867,17.321,19.52,23.161,19.637,19.686] ;ra of ref fields, hours decref=[29.0,0.311,0.05,0.05,27.0,36.11,.732,46.567,40.222] ; dec of ref fields, decimal deg namref=['R07','R12','R14','R16','R17','R19','R23','NGC6811','NGC6819'] ; names of ref fields nref=n_elements(raref) filtnam=['u ','g ','r ','i ','z ',$ 'Gred ','D51 '] dthrsh=3. ; max ref posn error, arcmin zdbase=getenv('ZDBASE') if(keyword_set(zdb)) then zdbase=zdb astrolib imdbase=zdbase+'/survey/images/images' blkdbase=zdbase+'/survey/blocks/blocks' jdrnd=.00002 ; JD roundoff slop allowed ; identify night in question date: print,'Enter Mt. Hopkins LOCAL date for beginning-of-night yyyy mm dd' read,yy,mm,dd if(yy lt 2002 or yy gt 2010 or mm lt 1 or mm gt 12 or dd lt 1 or dd gt 31) $ then begin print,'Illegal date: Need 2002 <= yyyy <= 2010, etc. Try again.' goto,date endif jd0=julday(mm,dd,yy,0,0,0) ; corresp to noon UT = 5AM before obs jdmn=jd0+(timez+tstrt)/24. ; min plausible start date jdmx=jd0+(timez+tend)/24. ; max ditto f1='(f13.5)' sjdmn=string(jdmn-jdrnd,format=f1) sjdmx=string(jdmx+jdrnd,format=f1) ; get data on images within this jd, sorted by time dbopen,imdbase s=dbfind(sjdmn+' < jd < '+sjdmx) nim=n_elements(s) if(s(0) eq 0) then begin print,'No images for this date, jd = ',jd0 print,'Quit? (y/n)' ss='' & read,ss if(ss eq 'y') then goto,fini else goto,date endif so=dbsort(s,'jd') dbext,so,'entry,jd,ra,dec,exptime,filter',iseq,jd,ra,dec,exptime,filter ; identify each image as particular ref field, else targ imid=strarr(nim)+' targ' for j=0,nref-1 do begin dra=(ra-raref(j))*cos(dec/rad2deg)*900. ; ra err in arcmin ddec=(dec-decref(j))*60. ; dec err in arcmin perr=sqrt(dra^2+ddec^2) sp=where(perr le dthrsh,nsp) if(nsp gt 0) then imid(sp)=namref(j)+' ' endfor ; build list of contiguous images with same imid cim=[imid(0)] cct=[1] ncb=1 ctime=[(jd(0)-long(jd(0)))*24.-timez+12.] ; hours local time (>24 ok) cfirst=[0] ; index of 1st & last image in each group clast=[0] for i=1,nim-1 do begin if(imid(i) eq cim(ncb-1)) then begin cct(ncb-1)=cct(ncb-1)+1 clast(ncb-1)=clast(ncb-1)+1 endif else begin cim=[cim,imid(i)] cct=[cct,1] ncb=ncb+1 cfirst=[cfirst,i] clast=[clast,i] ctime=[ctime,(jd(i)-long(jd(i)))*24.-timez+12.] endelse endfor ; print this list print f2='(i4,2x,a9,i4,2x,f6.2)' for i=0,ncb-1 do begin print,i,cim(i),cct(i),ctime(i),format=f2 endfor ; get from user the first and last groups in block print print,'Enter index of first group in block' read,ibeg print,cct(ibeg),' images in group. Begin with which? (def 1st = 0)' ss='' & read,ss if(ss eq '') then begin firstim=cfirst(ibeg) endif else begin firstim=cfirst(ibeg)+fix(strtrim(ss,2)) endelse print print,'Enter index of last group in block' read,iend print,cct(iend),' images in group. End with which? (def last =',$ cct(iend)-1,')' ss='' & read,ss if(ss eq '') then begin lastim=clast(iend) endif else begin lastim=cfirst(iend)+fix(strtrim(ss,2)) endelse ; get comments print print,'Enter 3 lines of comments about this block (may be blank)' s1='' s2='' s3='' read,s1 & b1=byte(s1) & l1=n_elements(b1) read,s2 & b2=byte(s2) & l2=n_elements(b2) read,s3 & b3=byte(s3) & l3=n_elements(b3) bcom=bytarr(80,3)+32 ; pre-fill with blanks bcom(0:l1-1,0)=b1 bcom(0:l2-1,1)=b2 bcom(0:l3-1,2)=b3 bcom=reform(bcom,240) bcom=string(byte(bcom)) ; make data that are to be added to database jdmin=jd(firstim) jdmax=jd(lastim) sjdmin=string(jdmin-jdrnd,format=f1) sjdmax=string(jdmax+jdrnd,format=f1) sf=dbfind(sjdmin+' < jd < '+sjdmax, /silent) dbext,sf,'entry,filter',iseq,filter iseqmin=min(iseq) iseqmax=max(iseq) a=fltarr(7) b=fltarr(7) c=fltarr(7) k=fltarr(7) chip2=fltarr(7) chip3=fltarr(7) chip4=fltarr(7) qual=fltarr(7) valid=intarr(7) for i=0,6 do begin st=where(filter eq filtnam(i),nst) if(nst gt 0) then valid(i)=1 endfor dbclose ; make blocks database if it doesn't exist !priv=2 ierr=findfile(blkdbase+'.dbd') berr=byte(ierr) if(berr(0) eq 0) then begin comm='cp '+zdbase+'/blocks.dbd '+blkdbase+'.dbd' spawn,comm dbcreate,blkdbase,1,1 endif dbopen,blkdbase,1 ; put the data in dbbuild,jdmin,jdmax,iseqmin,iseqmax,valid,a,b,c,k,chip2,chip3,chip4,qual,bcom dbclose fini: end