;;+ ; NAME: ; oc_convertid_tyc2_float ; ; PURPOSE: (one line) ; Convert TY2 ID's from standard format to an internal floating-point format. ; ; DESCRIPTION: ; Convert Tycho-2 ID's from standard format to an internal floating-point ; format. This floating-point format is used by the IDL occultation routines ; to refer uniquely to Tycho-2 stars more easily than handling strings. ; ; Tycho-2 ID's are in form "ZONE-SEQUENTIAL-NUM" (e.g., 2345-0312-1). ; We return the value (ZONE*10^5) + (SEQUENTIAL) (e.g., 234500312.0); ; we assume that the last component is always '1'. ; ; This function is the opposite of oc_convertid_float_tyc2 . ; ; CATEGORY: ; Star catalogs ; ; CALLING SEQUENCE: ; id_float = oc_convertid_tyc2_float( IDs [, /VERBOSE]) ; ; INPUTS: ; IDs -- Tycho-2 ID(s). String, or array of strings. ; ; OPTIONAL INPUT PARAMETERS: ; None ; ; KEYWORD INPUT PARAMETERS: ; /VERBOSE -- If set, print diagnostics to screen. ; ; KEYWORD OUTPUT PARAMETERS: ; None ; ; OUTPUTS: ; id_float -- floating-point representation of Tycho-2 ID's. ; Scalar or array, with same size as input IDs. ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; None ; ; EXAMPLE: ; print, oc_convertid_tyc2_float(['0001-00017', '2345-312']) ; [Prints "100017.00 2.3450031e+08"] ; ; MODIFICATION HISTORY: ; Written 3-Nov-2005 by Henry Throop, SwRI ; Modified 7-Dec-2005 by HBT. Improved error-handling. ; Modified 27-Feb-2006 by HBT. Improved documentation and formatting. ; Modified 14-Apr-2006 by Leslie Young. Made loop index long. ;;- function oc_convertid_tyc2_float, ids, VERBOSE=verbose num_ids = sizex(ids) ids_out = dblarr(num_ids) for i = 0L, num_ids-1 do begin id = string(ids[i]) ; If we have ' ' if grep(id, ' ') then begin id = ht_str_split(id, char = ' ') ; Make an integer out of it, and chop the third element id = id[0]*1d5 + id[1] end ; If we have '-' if grep(id, '-') then begin id = ht_str_split(id, char = '-') ; Make an integer out of it, and chop the third element id = id[0]*1d5 + id[1] end ; If string, convert to double id = double(id) ids_out[i] = id ; Check that it converted properly if (id eq 0) then begin if keyword_set(VERBOSE) then print, $ 'Error: oc_convertid_tyc2_float.pro: ' + ids[i] + $ ' does not appear to be a valid TYC2 ID.' end end ; Return an array or a scalar, depending on what was passed in. if is_array(ids) then return, ids_out if not(is_array(ids)) then return, ids_out[0] return, ids_out end