;+ ; NAME: ; oc_convertid_float_tyc2 ; ; PURPOSE: (one line) ; Convert TY2 ID's from an internal floating-point format to standard format ; ; DESCRIPTION: ; Convert Tycho-2 ID's from an internal floating-point format to standard ; format to an internal floating-point format. The 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). ; The floating point values is (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_tyc2_float. ; ; CATEGORY: ; Star catalogs ; ; CALLING SEQUENCE: ; id_float = oc_convertid_float_tyc2( IDs [, CHAR=char], $ ; [, /VERBOSE] [, /SHORT]) ; ; INPUTS: ; IDs -- Tycho-2 ID(s). Double, or array of doubles. ; ; OPTIONAL INPUT PARAMETERS: ; CHAR=char -- If set, use a delimiter rather than '-' between the ; Tycho-2 ID components. ; ; KEYWORD INPUT PARAMETERS: ; /VERBOSE -- If set, print diagnostics to screen. ; /SHORT -- If set, omit the last TY2 component on output (usually "-1") ; ; KEYWORD OUTPUT PARAMETERS: ; None ; ; OUTPUTS: ; id_float -- Standard representation of Tycho-2 ID's, string format. ; Scalar or array, with same size as input IDs. ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None ; ; RESTRICTIONS: ; None ; ; EXAMPLE: ; print, oc_convertid_float_tyc2([000100017d, 234500312d]) ; [Prints "0001-00017-1 2345-00312-1"] ; ; MODIFICATION HISTORY: ; Written 3-Nov-2005 by Henry Throop, SwRI ; Modified 27-Feb-2006 by HBT. Improved documentation and formatting. ; Modified 14-Apr-2006 by Leslie Young. Made loop index long. ; ;- function oc_convertid_float_tyc2, ids, CHAR=char, SHORT=short, VERBOSE=verbose num_ids = sizex(ids) ids_out = strarr(num_ids) for i = 0L, num_ids-1 do begin id = ids[i] id_1 = long(id/1d5) id_2 = id - (1d5 * id_1) id_3 = 1 id_string = string(id_1, id_2, id_3, format = '(I4, "-", I5, "-", I1)') id_string = str_replace(id_string, ' ', '0', /ALL) if keyword_set(CHAR) then id_string = $ str_replace(id_string, "-", char, /ALL) if keyword_set(SHORT) then id_string = $ strmid(id_string, 0, 10) ids_out[i] = id_string 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