;+ ; NAME: ; oc_search_pos_single_usnob10 ; ; PURPOSE: (one line) ; Return array of star structures around a single position ; ; DESCRIPTION: ; Searches the online USNO-B1.0 catalog and returns array of star structures ; ; CATEGORY: ; Star catalogs ; ; CALLING SEQUENCE: ; stars = oc_search_usnob10_single(ra, dec, radius, nstars, _extra=extra, ; verbose=verbose, method = method) ; ; INPUTS: ; ra - right ascension (radian) ; dec - declination (radian) ; radius - search radius (radian) ; ; OPTIONAL INPUT PARAMETERS: ; None ; ; KEYWORD INPUT PARAMETERS: ; verbose : set (1) to print out information ; method : 'scat' or 'vizier' ; ; KEYWORD OUTPUT PARAMETERS: ; None ; ; OUTPUTS: ; nstars : number of stars found (0 if none) ; returns array of star array (-1 is none found) ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; This version fills in only the minimum star ; ; EXAMPLE: ; a=oc_search_pos_single_usnob10(0.1, 0.1, 0.01, nstars, /verb) ; [Finds 6016 stars] ; ; MODIFICATION HISTORY: ; Written 2005 November, by Leslie Young, SwRI ; Renamed 2005 December, HBT, from oc_search_usnob10_single ; Modified 14-Apr-2006 by Leslie Young. Made loop index long. ;- function oc_search_pos_single_usnob10, ra, dec, radius, nstars, $ verbose=verbose, method = method, $ _extra=extra cat = 'USNO B1.0' ; set up an empty USNO B10 star idcat = cat id = 'none' poscat = cat et = 0.d ; J2000 = 0 seconds (TDB) after J2000 epoch ra_ = -999.d dec_ = -999.d raerr = -999.d decerr = -999.d radot = -999.d decdot = -999.d radoterr = -999.d decdoterr = -999.d magcat = [ cat, cat, cat, cat, cat] magname = [ 'B1', 'R1', 'B2', 'R2', 'I'] mag = [-999.d, -999.d, -999.d, -999.d, -999.d] magerr = [-999.d, -999.d, -999.d, -999.d, -999.d] SpTcat = 'none' SpT = '' notecat = [cat] note = [''] star = {idcat:idcat, id:id, $ poscat:poscat, et:et, ra:ra_, dec:dec_, $ raerr:raerr, decerr:decerr,$ radot:radot, decdot:decdot, $ radoterr:radoterr, decdoterr:decdoterr, $ magcat:magcat, magname:magname, mag:mag, magerr:magerr, $ sptcat:sptcat, spt:spt, notecat:notecat, note:note} ; switch on method defaultmethod = 'scat' if keyword_set(method) then begin usemethod = strlowcase(method) endif else begin usemethod = defaultmethod endelse definedmethods = ['scat', 'vizier'] imatch = where(usemethod eq definedmethods, nmatch) if nmatch eq 0 then begin if keyword_set(verbose) then begin print, 'oc_search_pos_single_usnob10: method (', method, $ ') should be one of ', definedmethods, $ '. Defaulting to ', defaultmethod end usemethod = defaultmethod end if keyword_set(verbose) then begin print, 'oc_search_pos_single_usnob10: using method ', usemethod end case usemethod of 'scat': begin ;------------------------------------------ ; Construct the command line call to scat ;------------------------------------------ command = 'scat ' + $ ' -c ub1' + $ ; catalog ' -r ' + string(radius*3600.d*180.d/!dpi,format='(F20.5)') + $ ; search radius, arcsec ' -d' + $ ; degrees (not hms) ' -t' + $ ; tab-delimited columns (also adds 11 lines of header info) ' -j' + $ ; J2000 ' -n 1000000' + $ ; Max number returned ' ' + string(ra*180.d/!dpi,format='(F19.12)') + $ ' ' + string(dec*180.d/!dpi,format='(F19.12)') + ' j2000' ; Execute the command and return output to array 'scat' if keyword_set(VERBOSE) then begin print, 'oc_search_pos_single_usnob10: Executing command: ' + $ command endif spawn, command, scat ;------------------------------------------ ; Count the stars ; Figure out how many stars, and how many header lines we have here ;------------------------------------------ lines_header = 0 for i = 0L, sizex(scat)-1 do begin ; if '---' in 3rd line, then we have a 3-line header if grep(scat[i], '---') then lines_header = i + 1 endfor ; if no '---' found then no header if lines_header eq sizex(scat)-1 then lines_header = 0 nstars = n_elements(scat)-lines_header if keyword_set(VERBOSE) then begin print, 'oc_search_pos_single_usnob10: '+$ 'Found ' + st(nstars) + ' matching stars' print, scat[0:lines_header-1] end ; If none found, then return if (nstars le 0) then return, -1 scat_chop = scat[lines_header:*] if keyword_set(VERBOSE) then begin print, scat_chop[0] end ;------------------------------------------ ; Parse and store the scat output ; Scan will not return output with fixed column locations; ; therefore, IDL's FORMAT= routines do not work. ; We therefore use tab-delimited output, and split on tabs, which ; prevents problems with ID's containing spaces. ;------------------------------------------ char_sep = string(9B) stars = replicate(star, nstars) for istar = 0L, nstars-1 do begin fields = (ht_str_split(scat_chop[istar], char=char_sep)) stars[istar].id = fields[0] stars[istar].ra = fields[1] * !dpi/180.d stars[istar].dec = fields[2] * !dpi/180.d b1 = fields[3] r1 = fields[4] b2 = fields[5] r2 = fields[6] i = fields[7] if b1 gt 99. then b1 = -999.d if r1 gt 99. then r1 = -999.d if b2 gt 99. then b2 = -999.d if r2 gt 99. then r2 = -999.d if i gt 99. then i = -999.d stars[istar].mag = [b1,r1,b2,r2,i] stars[istar].note[0] = 'SCAT, filling in minimum fields' end end 'vizier': begin stars = -1 & nstars = 0 ;------------------------------------------ ; Construct the command line call to Vizier ;------------------------------------------ s='-order=I' rastr, ra, 4, rastr, carry, sepchar=':' decstr, dec, 3, decstr, sepchar=':' s=s+'&' + '-c=' + rastr + '%20' + decstr ; search position s=s+'&' + '-c.eq=J2000' ; epoch s=s+'&' + '-oc.form=sexa' ; sexadecimal s=s+'&' + '-out.max=9999' ; 9999 lines s=s+'&' + '-out.form=Tab-Separated-Values' ; output type rstr = strtrim(string(radius*180.d*3600.d/!dpi,for='(F11.3)'),2) s=s+'&' + '-c.r='+rstr ; search radius s=s+'&' + '-c.u=arcsec' ; units (arcsec) s=s+'&' + '-c.geom=r' ; radius, not box s=s+'&' + '-out.add=_RAJ2000,_DECJ2000' ; compute ra, dec s=s+'&' + '-sort=_RA*-c.eq' ; sort by position s=s+'&' + '-source=I/284/out' ; catalog (USNO_B1.0) s=s+'&' + '-out.all=1' ; output all columns url = 'http://vizier.u-strasbg.fr/viz-bin/asu-tsv' command = 'curl ' + $ '--silent ' + $ '-d "'+s+'" ' + $ url ;------------------------------------------ ; Call Vizier ;------------------------------------------ if keyword_set(VERBOSE) then begin print, 'oc_search_pos_single_usnob10: Executing command: ' + $ command endif spawn, command, vizout ;------------------------------------------ ; Count the stars ;------------------------------------------ nline = n_elements(vizout) char0 = strmid(vizout,0,1) idash = where(char0 eq '-', ndash) if ndash eq 0 then begin lines_header = nline endif else begin lines_header = idash[0]+1 endelse if lines_header lt nline then begin viz_chop = vizout[lines_header:nline-1] ok = where(strlen(viz_chop) gt 0, nstars) if nstars gt 0 then viz_chop = viz_chop[ok] endif else begin nstars = 0 endelse if keyword_set(VERBOSE) then begin print, 'oc_search_pos_single_usnob10: '+$ 'Found ' + st(nstars) + ' matching stars' print, vizout[0:lines_header-1] end ; If none found, then return if (nstars le 0) then return, -1 if keyword_set(VERBOSE) then begin print, viz_chop[0] end ;------------------------------------------ ; Parse the output ;------------------------------------------ char_sep = string(9B) stars = replicate(star, nstars) for istar = 0L, nstars-1 do begin fields = (ht_str_split(viz_chop[istar], char=char_sep)) stars[istar].id = fields[3] stars[istar].ra = raparse(fields[1]) stars[istar].dec = decparse(fields[2]) b1 = flt(fields[19], -999.d) r1 = flt(fields[26], -999.d) b2 = flt(fields[33], -999.d) r2 = flt(fields[40], -999.d) i = flt(fields[47], -999.d) stars[istar].mag = [b1,r1,b2,r2,i] stars[istar].note[0] = 'VIZIER, filling in minimum fields' end end endcase ; ids = reform(stars.id) ids = stars.id stars = stars[uniq(ids)] stars = stars[sort(stars.id)] return, stars end