function oc_search_pos_slow, ra, dec, radius, nstars, VERBOSE=verbose, CATALOG_in=catalog_in ; Searches for stars in the HD or TY2 catalog. ; This code could be generalized to other catalogs ; This code uses no speed-up methods such as pre-computed catalogs, searching ; subcatalogs, etc. For the WCS catalogs such as HD, faster methods are ; in theory preferred. ; ; Inputs: ; ra: J2000 RA of search center (radians, double) ; dec: J2000 Dec of search center (radians, double) ; radius: Search radius (radians, double) ; CATALOG=catalog: Which catalog to use ('HD', 'TY2', etc.) ; ; Outputs: ; nstars: optional returned value which indicates number of stars found. ; ; Returned value: ; star: List of matching stars (array[nstars] of structures) ; ; Author: ; HBT 25-Jan-2005 ; 26-Jan-2005: Minor changes ; 22-Feb-2005: Generalized so it works for catalogs beyond HD ; 10-Oct-2005: Minor changes to bring into CVS ; We want to execute a call to scat something like this: ; scat -tc hd -a -h -r 5000 -b 7:30:17.000 -16:29:00.000 b1950 ; ; NB: In order to get 'scat' to find the catalogs, the appropriate ; shell variable must be set; for instance: ; setenv WCS_CATDIR $HOME/occult/catalogs ; [HD catalog uses scat's WCS format, so it looks in WCS_CATDIR] ; setenv TY2_PATH $HOME/occult/catalogs/TYCHO2 ; [TY2 catalog uses scat's internal binary format, and looks in TY2_PATH] d2r = 2*!dpi / 360d r2d = 1/d2r d2as = 60d*60d nstars_max = 1000000 ; Maximum number of stars catalog_default= 'hd' if not(keyword_set(CATALOG_IN)) then begin catalog = catalog_default end $ else begin catalog = strlowcase(CATALOG_IN) end star = oc_struct_star(catalog) ; Process the coordinates ra_rad = ra dec_rad = dec radius_rad = radius ra_deg = ra*r2d dec_deg = dec*r2d radius_arcsec = radius_rad * r2d * d2as ; Make sure the environment variables are set properly case (catalog) of 'hd' : if strlen(getenv('WCS_CATDIR')) eq 0 then print, 'Warning: WCS_CATDIR not set.' 'ty2' : if strlen(getenv('TY2_PATH')) eq 0 then print, 'Warning: TY2_PATH not set.' end ; Construct the command command = 'scat ' + $ ' -c ' + catalog + $ ; catalog ' -r ' + string(radius_arcsec,format='(F20.5)') + $ ; search radius, arcsec ' -d' + $ ; degrees (not hms) ' -t' + $ ; tab-delimited columns (also adds 11 lines of header info) ' -j' + $ ; J2000 ' -n ' + st(nstars_max) + $ ; Max number returned ' ' + string(ra_deg,format='(F19.12)') + ' ' + string(dec_deg,format='(F19.12)') + ' j2000' ; Execute the command and return output to array 'scat' if keyword_set(VERBOSE) then print, 'Executing command: ' + command spawn, command, scat ; Figure out how many stars, and how many header lines we have here lines_header = 0 for i = 0, sizex(scat)-1 do if grep(scat[i], '---') then lines_header = i+1 ; if '---' in 3rd line, then we have a 3-line header if lines_header eq sizex(scat)-1 then lines_header = 0 ; if no '---' found then no header nstars = n_elements(scat)-lines_header if keyword_set(VERBOSE) then print, 'Found ' + st(nstars) + ' matching stars' ; If none found, then return if (nstars eq 0) then return, -1 ; If stars found, then prepare to read them in stars = replicate(star, nstars) scat_chop = scat[lines_header:*] ; 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_tab = string(9B) for i = 0, nstars-1 do begin arr = ht_str_split(scat_chop[i], char=char_tab) case (catalog) of 'hd' : begin stars[i].id = arr[0] stars[i].ra = arr[1]*d2r stars[i].dec = arr[2]*d2r stars[i].radius = arr[6] stars[i].catalog = catalog stars[i].starinfo.scatstr= scat_chop[i] stars[i].starinfo.spt = arr[5] stars[i].starinfo.vmag = arr[3] end 'ty2' : begin stars[i].id = arr[0] stars[i].ra = arr[1]*d2r stars[i].dec = arr[2]*d2r stars[i].radius = arr[7] ; Distance in arcsec stars[i].catalog = catalog ; Catalog name ('ty2') stars[i].starinfo.scatstr= scat_chop[i] ; The entire string ; stars[i].starinfo.spt = '--' ; Tycho: no spectral types stars[i].starinfo.bmag = arr[3] ; B mag stars[i].starinfo.vmag = arr[4] ; V mag end end end return, stars end