###################### list2dfdr.cl ##################################### # #.LANGAGES CL - IRAF #.IDENTIFICATION list2dfdr.cl #.AUTHORS Michael Drinkwater #.KEYWORDS fibres, spectroscopy #.ENVIRONMENT #.COMMENTS #.VERSION 1.0 2002 May 20 # #+++++++++++++++++++++ Explanation for the function +++++++++++++++++++++++ # #.PURPOSE Takes 2dfinfo fibre listing from 2dfdr # -puts object names and beams into image header for IRAF # -makes text listing of objects, optionally skipping sky #.INPUTS # 1. 2dfinfo fibres output as a text file # 2. reduced 2dF file # #.RETURNS 1. new copy of reduced data with IRAF details in header # 2. full RA, Dec, mag, etc. listing of observed objects # #.ALGORITHM Straightforward, uses IRAF cl language. Macro. # #.REMARKS To use this script in IRAF you should copy this # file to your directory and then within IRAF type: # task list2df = PATH/list2df.cl # where PATH/ is the full directory path to the file. # #-------------------------------------------------------------------------- procedure list2dfdr (infile,outfile,targets,fibres,field,set,plate,ccd) string infile {prompt="input image(blank for list only)"} string outfile {prompt="output image"} string targets {prompt="output target list"} string fibres {prompt="2dF fibre list file name"} int field = 1 {prompt="Target field ID (integer)"} int set = 1 {prompt="Target set ID (integer)"} int plate = 0 {prompt="2dF plate used (0 or 1)"} int ccd = 1 {prompt="2dF CCD used (1 or 2)"} bool no_sky = no {prompt="Skip skys etc. in target list?"} bool clobber = no {prompt="clobber output files?"} bool verbose = yes {prompt="verbose output?"} struct *s_fibres begin bool images real r1,r2,r3,d1,d2,d3,m1,mag[404] int nred,nsel,iccd,iplt,ipiv,ispc,i,i2,nfile int ntarg,nsky,nfid,nbroke,pfib,nbeam,pivot[404] int f_plate,flag[404],f_ccd,isav,f_field,f_set int nsava,nsavo,tmp4 string tmp1,tmp2,tmp3,flg,name[404],data[404],hname,hvalue string f_infile,f_outfile,f_targets,f_fibres struct line # get parameters f_infile = infile f_outfile = outfile f_targets = targets f_fibres = fibres f_field = field f_set = set f_plate = plate f_ccd = ccd # check output data file option images = yes if (f_infile=="") images=no # check outfile files if (access (f_outfile)) { if (clobber) { imdelete(f_outfile, ver-, >& "dev$null") } else { print("output file exists: ",f_outfile) bye }} if (access (f_targets)) { if (clobber) { delete(f_targets, ver-, >& "dev$null") } else { print("output file exists: ",f_targets) bye }} ################################################################### # "Read input files-----------------------------------------------" # Read allocations file (ap, ID, P, no, RA, Dec, mag) if (verbose) print("Reading ",f_fibres) if (! access (f_fibres)) { print(f_fibres," file not found.") bye } s_fibres = f_fibres if (fscan(s_fibres,line) != EOF) { if (fscan(s_fibres,line) != EOF) { if (verbose) print("Read 2 comment lines") } else { print("*** Error reading comment lines") bye } } else { print("*** Error reading comment lines") bye } nred = 0 ntarg = 0 nsky = 0 nfid = 0 nbroke= 0 while (fscan(s_fibres,line) != EOF){ if (fscan(line,pfib,tmp2,flg,tmp4,r1,r2,r3,d1,d2,d3,m1)==11){ nred += 1 if(nred!=pfib){ print(" error in aperture number",nred,pfib) bye } name[pfib]=substr(tmp2,1,4) data[pfib]=substr(line,42,68) flag[pfib] = -9 mag[pfib] = m1 pivot[pfib] = tmp4 if (flg=="F") { flag[pfib] = -1 nfid += 1 } if (flg=="U" || flg=="N") { flag[pfib] = -1 nbroke += 1 } if (flg=="S") { flag[pfib] = 0 nsky += 1 } if (flg=="P") { flag[pfib] = 1 ntarg += 1 } #if (verbose) print("n,a,f,ff",nred,pfib,flg,flag[pfib]) } else { #if (verbose) print(line) #print(" error reading line") #print(line) #print(nscan()) #bye } } print("Read assignments: n = ",nred) print("#fibres,skys,guides,broken= ",ntarg,nsky,nfid,nbroke) # "Write output files-----------------------------------------------" if (images) { imcopy(f_infile//"[0]",f_outfile) hedit(f_outfile,"WAT0_001","system=equispec",add+,ver-,update+) } # NB each spectrum has an aperture no. (i) on the chip [1-200] # as well as an order no. (nfile) in the final reduced spectrum. if (verbose) print("Writing output files") nfile = 0 nsava = 0 nsavo = 0 ntarg = 0 nsky = 0 nbroke= 0 for (i=1; i <= 200; i += 1) { nbeam = flag[i] #print("test 0: ",i,nbeam) i2 = i isav = 1 if (no_sky && nbeam<1) isav = 0 if(isav==1){ nfile =nfile+1 printf("%26s %3s %5.2f %7s %3d %3d %2d %2d %2d %4d %4d %4d\n", data[i],"P 9",mag[i],name[i],f_field,f_set,f_plate, f_ccd,nbeam,pivot[i],nfile,i2,>>f_targets) } if (images) { hname="APID"//str(i) hvalue=name[i]//" "//str(mag[i]) hedit(f_outfile,hname,hvalue,add+,ver-,update+,show-) hname="APNUM"//str(i) hvalue="1 "//str(nbeam)//" 1 1024" hedit(f_outfile,hname,hvalue,add+,ver-,update+,show-) } if (nbeam==-1) nbroke =nbroke+1 if (nbeam==0) nsky=nsky+1 if (nbeam==1) ntarg=ntarg+1 } print("# RA Dec Pri Mag Name", " fld set pl cd bm pivt file aper",>>f_targets) print(" #fibres,skys,broken = ",ntarg,nsky,nbroke) print(" saved ",nfile," identifications in ",f_targets) end # cd /data/thor/mdrinkwa/tmp/virgo/ccd2 # epar list2dfdr