;+ ; NAME: ; oc_getrec_tyc2_hd ; ; PURPOSE: (one line) ; Return structure that correlates TYC2 and HD catalogs, given stellar ID(s). ; ; DESCRIPTION: ; Return a fully-populated tyc2_hd record, based on a supplied Tycho-2 or HD ; ID. The structure is similar to a star structure, but with ; different fields. The record can be used to match star with its ; counterpart(s) in the HD or Tycho-2 catalog. ; ; The structure type implements the fields in the Vizier ReadMe file ; for the catalog. The catalog is Vizier IV/25, Fabricius et al 2002. ; ; Statistics: 272152 stars in HD catalog ; 385 stars in tyc2_hd where 2 HD stars match 1 TYC2 star ; 16 stars in tyc2_hd where 1 HD star matches 2 TYC2 stars ; ~400 HD stars which match no TYC2 star ; ; CATEGORY: ; Star catalogs ; ; CALLING SEQUENCE: ; lines = oc_getrec_tyc2_hd( {HD=hd | TYC2=tyc2} [, NTH=nth], $ ; [, NSTARS=nstars] [, /VERBOSE] ; ; ; INPUTS: ; HD = hd -- Either HD= *or* TYC2= must be passed. Each is an ID ; TYC2 = tyc2 or array of ID's, in the standard format for that catalog. ; ; OPTIONAL INPUT PARAMETERS: ; NTH -- Return the nth possible match for each star, if possible; if not, ; return a lower match. E.g., there may be 2 TYC2 stars for 1 HD ID. ; Setting NTH=0 will return the first match for this star and ; NTH=1 with return the second match to the star. For stars ; on which there is only one match, it will return the single ; match. ; ; /VERBOSE -- If set, print diagnostics to screen. ; ; OPTIONAL INPUT PARAMETERS: ; None ; ; KEYWORD INPUT PARAMETERS: ; None ; ; KEYWORD OUTPUT PARAMETERS: ; NSTARS -- Returns the number of successfully-retrieved records. ; ; OUTPUTS: ; Structure or array of structures. Same dimensions as input ID, regardless ; of multiple matches or non-matches. ; ; If HD= is passed for input, returned values are for Tycho-2 stars. ; If TYC2= is passed for input, returned values are for HD stars. ; ; If a star has no match, an empty structure is returned for that element. ; ; None ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; Tycho2-HD catalog must exist at $WCS_CATDIR/tyc2_hd/tyc2_hd.dat . ; ; EXAMPLE: ; recs = oc_getrec_tyc2_hd(HD=[0,1,10,100,1000,10000d], nstars=nstars) ; [Returns 5 matches and one non-match, setting nstars=5] ; ; MODIFICATION HISTORY: ; Written 3-Nov-2005 by Henry Throop, SwRI ; Modified 30-Nov-2005 by HBT. Fixed to read in n_hd, n_tyc properly. ; Changed output format of .tyc2 field. ; Improved handling of multiple- and ; non-matches. ; Modified 7-Dec-2005 by HBT. Improved error handling. ; Modified 28-Feb-2006 by HBT. Improved documentation and formatting. ; Modified 7-Mar-2006 by LAY. Changed documentation to reflect nth=0..lines-1 ; Modified 14-Apr-2006 by Leslie Young. Made loop index long. ;- function oc_getrec_tyc2_hd, HD=hd, TYC2=tyc2, NSTARS=nstars, $ VERBOSE=verbose, NTH=nth ; Byte-by-byte Description of file: tyc2_hd.dat ; --------------------------------------------------------------------------- ; Bytes Format Units Label Explanations ; --------------------------------------------------------------------------- ; 1- 4 I4 --- TYC1 [1,9537]+= TYC1 from Tycho-2 ; 6- 10 I5 --- TYC2 [1,12121] TYC2 from Tycho-2 ; 12 I1 --- TYC3 [1,4] TYC3 from Tycho-2 ; 13 A1 --- f_TYC [S] Set for stars in Tycho-2 Supplement#1 ; 15- 20 I6 --- HD HD (Cat. ) identifier ; 22- 24 A3 --- SpType Spectral type from HD catalogue ; 26 I1 --- n_HD [1,2] number of HD stars for Tyc2 star ; 28 I1 --- n_TYC [1,2] number of Tyc2 stars for HD star ; 30 A1 --- TDSC [D] star in Tycho Double Star Catalogue ; 32 A1 --- Rem *[DEGMR*] Remarks flag from HD file ; 34 A1 --- Note [N] note exists in the notes.dat file ; Bug: print, (oc_getrec_tyc2_hd(tyc2=['1763-3028-1', '1762-2809-1']) ).hd ; Make sure only one set of input id's was passed if keyword_set(HD) and keyword_set(TYC2) then begin nstars = 0 if (keyword_set(VERBOSE)) then print, $ 'Error: oc_getrec_tyc2_hd: Either TYC2 or HD must be passed but not both.' return, -1 end ; Test whether we were passed HD numbers, or TYC2 ID's if keyword_set(HD) then ids = hd $ else ids = tyc2 num_ids = sizex(ids) ; Initialize all of the proper *TYC2_HD* variables. All values are kept as ; their original name and format. ; Note that in this catalog, there is no 'star' structure. Instead, there is ; *only* an array of 'tyc2_hd' structures. TYC1_ = 0L ; Renamed from TYC2 to avoid conflicts with keyword variable TYC2_ = 0L TYC3_ = 0L f_TYC = '' ; Renamed from HD to avoid conflicts with keyword variable HD_ = 0L SpType = '' n_HD = 0 n_TYC = 0 TDSC = '' Rem = '' Note = '' ; Not tyc2_hd field. This field stores entire tyc2_hd catalog line entry. record = '' TYC = '' ; Not tyc2_hd field, but for ease of use, stores fully concatenated TYC2 ID. tyc2_hd = {TYC1:TYC1_, TYC2:TYC2_, TYC3:TYC3_, f_TYC:f_TYC, HD:HD_, $ SpType:SpType, n_HD:n_HD, n_TYC:n_TYC, TDSC:TDSC, $ Rem:Rem, Note:Note, $ TYC:TYC, record:record} records = make_array(num_ids, value=tyc2_hd) tyc2_hd_init = tyc2_hd ; Look up the raw catalog lines ; tyc2_hd = oc_getrec_tyc2_hd(hd=[1,45900d,50000d], /VERB, NTH=1) lines = oc_getline_tyc2_hd(HD=hd, TYC2=tyc2, NSTARS=nstars, $ VERBOSE=verbose, NTH=nth) ; Now process each line for i = 0L, num_ids-1 do begin id = ids[i] line = lines[i] id = ids[i] ; Clear the record tyc2_hd = tyc2_hd_init ; Check to make sure it's valid. ; If it's not, fill in fields to denote it is invalid. if (line eq '') then begin tyc2_hd.tyc1 = -999 tyc2_hd.tyc2 = -999 tyc2_hd.tyc3 = -999 tyc2_hd.hd = -999 tyc2_hd.n_hd = -999 tyc2_hd.n_tyc = -999 tyc2_hd.record = 'none' goto, parse_end end ; Set the string from the Vizier ReadMe catalog description file string_tyc2_hd = '(I4, X, I5, X, I1, A1, X, I6, X, ' + $ 'A3, X, I1, X, I1, X, A1, X, A1, X, A1)' ; Parse the raw catalog line into a bunch of variables reads, line, format=string_tyc2_hd, TYC1_, TYC2_, TYC3_, f_TYC, $ HD_, SpType, n_HD, n_TYC, TDSC, Rem, Note ; Stick each variable into its proper *TYC2_HD* structure location tyc2_hd = tyc2_hd_init tyc2_hd.record = line tyc2_hd.tyc = st(tyc1_) + '-' + st(tyc2_) + '-' + st(tyc3_) ; Concatenate the ID's onto each other tyc2_hd.tyc = str_replace(string(tyc1_, tyc2_, tyc3_, $ format = '(I4, "-", I5, "-", I1)'), ' ', '0', /ALL) tyc2_hd.tyc1 = tyc1_ tyc2_hd.tyc2 = tyc2_ tyc2_hd.tyc3 = tyc3_ tyc2_hd.f_tyc = f_tyc tyc2_hd.hd = hd_ tyc2_hd.sptype = sptype tyc2_hd.n_hd = n_hd tyc2_hd.n_tyc = n_tyc tyc2_hd.tdsc = tdsc tyc2_hd.rem = rem tyc2_hd.note = note parse_end: ; Store the structure in an array records[i] = tyc2_hd end ; Based on whether a scalar or an array was passed in, return the same. if is_scalar(ids) then return, records[0] if is_array(ids) then return, records end