;+ ; NAME: ; oc_create_subcat ; ; PURPOSE: (one line) ; Extract and create a subcatalog on disk of a full catalog. ; ; DESCRIPTION: ; Takes a bounding RA/DEC box and a catalog name, and uses WSCTools' ; SCAT to extract the stars within that box into their own text-format ; catalog on disk. The output format is one which is compatible with ; WCSTools. When searching through catalogs distributed in text format ; (e.g., HD), it can be more efficient to search through many small ; subcatalogs, vs. searching once through the full catalog. ; ; The files are placed in temporary directory $HDOCCUL_TMP . ; The idea is that they will be recreated if they are needed, but should not ; be regularly deleted. ; ; Currently this routine works only for the HD catalog. ; ; This routine is called by oc_subcat_create, which ; ; CATEGORY: ; Star catalogs ; ; CALLING SEQUENCE: ; oc_create_subcat, subcat_str, catalog [, /VERBOSE] ; ; INPUTS: ; subcat_str -- String specifying the catalog to create. The string ; encodes the catalog name and the bounding box. ; Format is CAT_RA0_RA1_DE0_DE1, where CAT is the catalog ; name (e.g., 'hd'), and each of the four RA/DEC values is ; an angle, in degrees. Fractional angles are OK; RA must ; be in the range [0 .. 360), and DE must be in the range ; [-180 .. 180]. ; ; Catalog name is converted to lower case if it is not already. ; ; This string name is also used verbatim for the output filename. ; ; OPTIONAL INPUT PARAMETERS: ; /VERBOSE -- Print diagnostic messages to screen. ; ; KEYWORD INPUT PARAMETERS: ; None ; ; KEYWORD OUTPUT PARAMETERS: ; None ; ; OUTPUTS: ; None ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; Creates file $HDOCCUL_TMP/subcat_str , or overwrites it if it already ; exists. ; ; RESTRICTIONS: ; Directory $HDOCCUL_TMP must exist. ; The specified catalog must exist and be accessible to WCSTools. ; ; EXAMPLE: ; ; oc_subcat_create, 'hd_262.4_262.5_-15.2_-15.1', /VERBOSE ; ; MODIFICATION HISTORY: ; Written 28-Jan-2005 by Henry Throop, SwRI ; Modified 9-Dec-2005 by HBT. Renamed from create_subcat.pro, and minor ; revisions. ; Modified 15-Dec-2006 by HBT. Renamed again: oc_create_subcat -> ; oc_subcat_create. ; Modified 23-Feb-2006 by HBT. Improved documentation and formatting. ; Removed vestigial 'catalog' input param and ; other minor changes. ;- ;;;;;;;;;; pro oc_subcat_create, subcat_str, VERBOSE=verbose ;;;;;;;;;; r2d = 360d/(2*!dpi) d2r = 1/r2d d2as = 60d*60d nstar_max = 100000 path_wcs = getenv('HDOCCUL_TMP') path_subcat = path_wcs + '/' ; if not(file_exists(path_subcat)) then begin ; command = 'mkdir ' + path_subcat ; print, command ; spawn, command ; if not(file_exists(path_subcat)) then begin ; print, 'Failed!' ; end ; end a = ht_str_split(subcat_str, char='_') catalog = strlowcase(a[0]) if (catalog eq 'hd') then file_catalog = 'hd/catalog.wcs.dat' ; Parse RA, dec in degrees ra_min = double(a[1]) ra_max = double(a[2]) dec_min = double(a[3]) dec_max = double(a[4]) dec = (dec_min+dec_max)/2d ra = (ra_min+ra_max)/2d dra_deg = ra_max-ra_min ddec_deg = dec_max-dec_min dra_as = dra_deg * d2as ddec_as = ddec_deg * d2as command = 'scat ' + $ ; catalog ' -c ' + file_catalog + $ ; search radius ' -r ' + st(dra_as/2d) + ',' + st(ddec_as/2d) + $ ; degrees (not hms) ' -d' + $ ; tab-delimited columns (also adds 11 lines of header info) ; ' -t' + $ ; J2000 ' -j' + $ ; max # of stars to return ' -n ' + st(nstar_max) + $ ' ' + string(ra,format='(F19.12)') + ' ' + $ string(dec,format='(F19.12)') + ' j2000' + $ ' > ' + path_subcat + subcat_str if keyword_set(VERBOSE) then print, command spawn, command end