;+ ; NAME: ; FINDLGSPSF ; ; PURPOSE: ; Search the 2MASS and USNO-B1.0 catalogue for PSF-TTref pairs ; matching the Targ-TTref pairs in a Keck LGSAO target list. ; ; EXPLANATION: ; Uses the IDL Astronomy User's Library routine QUERYVIZIER to query the ; 2MASS-PSC and USNO-B1.0 catalogues for IR-bright stars with a tip-tilt ; reference star with the same distance, PA, and magnitude parameters ; as each target-TTref pair. Output is a new target list, with PSFs ; listed after each LGSAO target. ; ; CALLING SEQUENCE: ; FINDLGSPSF, starlist, output_filename, raoff=raoff, kmag=kmag ; ; INPUTS: ; starlist - the full path to a Keck-format starlist. If not given, ; will prompt user to choose one using DIALOG_PICKFILE. ; ; OPTIONAL INPUTS: ; output_filename - a filename to which to output the LGSAO starlist. ; If not defined, output will be to command line. ; ; OPTIONAL INPUT KEYWORDS: ; RAOFF - An RA offset (in degrees, positive east) around which to ; search for the PSF stars. For example, if you intend to ; observe your target for 1 hr, then a PSF star near raoff=15.0 ; might be ideal. Default = 0. ; ; NPSF - Number of PSFs to return for each target. Default = 1 ; ; KMAG - A 2-element vector giving a the range of K magnitudes allowed ; for the PSF stars. Default = [8.0, 13.0]. ; ; RMAG - Maximum allowed R magnitude mis-match between Targ-TTref and ; PSF-TTref. Default = 0.5 ; ; TTOFF - Maximum allowed offset of PSF TTref (arcsec). Default = 2.5 ; ; EXAMPLE: ; First use FINDTTREF to identify tip-tilt reference stars for all ; objects in a Keck starlist 'stars.lst' ; ; FINDTTREF, 'stars.lst', 'lgsstars.lst' ; ; Then indentify 2 PSFs, 1 hr east of each of these target-TTref pairs. ; Note: this may take a long time to run (1-5 minutes per target.) ; ; FINDLGSPSF, 'lgsstars.lst', 'lgsstars_with_psfs.lst', npsf=2, raoff=15. ; ; Sample output for one target, 2 PSF stars, each with TTrefs: ; ; OH231 07 42 16.844 -14 42 51.00 2000.0 lgs=1 ; 0752-0160130 07 42 17.156 -14 42 36.87 2000.0 rmag=15.6 sep=14.8 S=0.27 ; 2MASS 0741-1439 07 41 55.729 -14 39 49.97 2000.0 PSF1 lgs=1 K=12.8 H=12.9 ; 0753-0160157 07 41 56.180 -14 39 34.80 2000.0 rmag=15.5 sep=16.5 dsep=2.3 ; 2MASS 0742-1456 07 42 29.186 -14 56 30.34 2000.0 PSF2 lgs=1 K=12.1 H=12.1 ; 0750-0158558 07 42 29.419 -14 56 15.19 2000.0 rmag=15.6 sep=15.5 dsep=1.5 ; ; PROCEDURES USED: ; Functions: QUERYVIZIER(), READSTARLIST(), STARSTRING() ; Procedures: GCIRC, COPY_STRUCT ; ; NOTES: ; QUERYVIZIER uses the SOCKET procedure, which requires IDL 5.4 or later. ; ; MODIFICATION HISTORY: ; Written 01/05 by A.H. Bouchez, WM Keck Observatory. ; 28aug2006 ARC Removed reference to '/canada' from queryviz calls. ; See 28aug2006 email thread with Stockton. ;- PRO FINDLGSPSF, starlist, output_filename, raoff=raoff, npsf=npsf, $ kmag=kmag, rmag=rmag, ttoff=ttoff ;;; 1. Set defaults npar = N_PARAMS() if npar eq 0 then begin default_path = '/net/ulua/local/kroot/starlists/' starlist = DIALOG_PICKFILE(path=default_path, tit='Select a starlist') endif if not KEYWORD_SET(output_filename) then $ output_filename='std_out' if not KEYWORD_SET(raoff) then raoff = 0. ; PSF RA offset if not KEYWORD_SET(npsf) then npsf = 1 ; number of PSFs per target if not KEYWORD_SET(kmag) then kmag = [8., 13] ; Kmag range of PSFs if not KEYWORD_SET(rmag) then rmag = 0.5 ; max allowed TTRmag mismatch if not KEYWORD_SET(ttoff) then ttoff = 2.5 ; max allowed TTref offset (") silent = 1 ; =1 disables status reports avoid_targ = 10.0 ; PSF min dist from target (") lgs_str = { targ: '', $ ; Target name raj2000: 0D, $ ; Target RA J2000, degrees dej2000: 0D, $ ; Target Dec J2000, degrees rah: 0, $ ; Target RA hours ram: 0, $ ; Target RA minutes ras: 0., $ ; Target RA seconds design: '', $ ; Target Dec sign (+1 or -1) ded: 0, $ ; Target Dec degrees dem: 0, $ ; Target Dec minutes des: 0., $ ; Target Dec seconds equ: 0., $ ; Target Equinox vmag: 0., $ ; Target V magnitude comment: '', $ ; All Target data after equinox ttref: '', $ ; TTref name ttraj2000:0D, $ ; TTref RA J2000, degrees ttdej2000:0D, $ ; TTref Dec J2000, degrees ttrmag: 0., $ ; TTref R magnitude ttcomment:''} ; All TTref data after equinox stmp = { targ:'', rah:0, ram:0, ras:0., design:'', $ ; (all ngs fields except ded:0, dem:0, des:0., equ:0., comment:''} ; raj2000 & dej2000) fmt = '(A15,X,I2.2,X,I2.2,X,F6.3,X,A1,I2.2,X,I2.2,X,F5.2,X,F6.1,X,A)' ;;; 2. Read starlist, set up output structure array, open output file tlist = READSTARLIST(starlist, /lgs) nt = N_ELEMENTS(tlist) if output_filename ne 'std_out' then begin PRINT,'Output starlist: ' + output_filename OPENW, unit, output_filename, /get_lun FREE_LUN, unit endif ;;; 3. Loop over targets, print target data nn = 0 for n=0,nt-1 do begin plist = REPLICATE(lgs_str, npsf+1) ; structure array for PSFs plist[0] = tlist[n] ; Target goes in index 0 str = STARSTRING(plist[0],ttstr) if output_filename ne 'std_out' then begin PRINT,' ' PRINT,'Targ: ' + str OPENU, unit, output_filename, /append, /get_lun PRINTF, unit, str PRINTF, unit, ttstr FREE_LUN, unit endif else begin PRINT, str PRINT, ttstr endelse nn = nn + 1 if (tlist[n].ttraj2000 ne 0) and $ ; Only search if TTref RA, Dec (tlist[n].ttdej2000 ne 0) and $ ; and Rmag are defined. (tlist[n].ttrmag ne 0) then begin rade0 = [tlist[n].raj2000 + raoff, $ ; PSF seach center tlist[n].dej2000] drade0 = 15. ; r_search (arcmin) offset = [tlist[n].ttraj2000-tlist[n].raj2000, $ ; TTref-Targ offset tlist[n].ttdej2000-tlist[n].dej2000] np = 0 ; number of PSFs found ;;; 4. Download 2MASS and USNO-B1 stars for search region while np lt npsf do begin if (output_filename ne 'std_out') and (not silent) then $ PRINT,' Search radius = ' + $ STRTRIM(STRING(drade0/60,f='(F6.2)'),2) + ' deg.' tmas = QUERYVIZIER('2MASS-PSC', rade0, drade0) usno = QUERYVIZIER('USNO-B1', rade0, drade0) ;;; 5. Retain only 2MASS stars out of Kmag range, exclude targ. and prev. PSFs if (SIZE(tmas))[0] gt 0 then begin crit0 = (tmas.kmag ge kmag[0]) and $ ; PSF K mag. range (tmas.kmag lt kmag[1]) crit1 = REPLICATE(1B, N_ELEMENTS(tmas)) for m=0,npsf-1 do begin GCIRC, 1, plist[m].raj2000/15, plist[m].dej2000, $ tmas.raj2000/15, tmas.dej2000, dist if m eq 0 then dist_targ = dist w0 = WHERE(dist lt avoid_targ) if w0[0] ne -1 then crit1[w0[0]] = 0 endfor w1 = WHERE(crit0 and crit1, ntmas) if ntmas gt 0 then tmas = (tmas[w1])[SORT(dist_targ[w1])] $ else tmas=-1 endif ;;; 6. Retain only USNO-B1 stars in Rmag range. if (SIZE(usno))[0] gt 0 then begin usno_rmag = (usno.r1mag + usno.r2mag)/2. ; R1 or R2 mag. w2 = WHERE(FINITE(usno.r2mag) ne 1) if w2[0] ne -1 then usno_rmag[w2] = usno[w2].r1mag w3 = WHERE(FINITE(usno.r1mag) ne 1) if w3[0] ne -1 then usno_rmag[w3] = usno[w3].r2mag w4 = WHERE(ABS(usno_rmag-tlist[n].ttrmag) lt rmag, nusno) if nusno gt 0 then begin usno = usno[w4] usno_rmag = usno_rmag[w4] endif else usno=-1 endif ;;; 7. Loop through 2MASS stars, checking for appropriate TTrefs. if ((SIZE(tmas))[0] gt 0) and ((SIZE(usno))[0] gt 0) then begin if (output_filename ne 'std_out') and (not silent) then $ PRINT,' 2MASS stars = ' + STRING(ntmas,f='(I0.0)') + $ '; USNO-B1 stars = ' + STRING(nusno,f='(I0.0)') for m=0,ntmas-1 do begin if np lt npsf then begin ; If N