;+ ; NAME: ; oc_getline_ucac2_2006 ; PURPOSE: (one line) ; return lines in an UCAC2 ucac2_2006 file ; DESCRIPTION: ; return lines in an UCAC2 ucac2_2006 file given id (id = line number, 1-indexed) ; CATEGORY: ; occultation ; CALLING SEQUENCE: ; lines = oc_getline_ucac2_2006(ids, count=count, VERBOSE=verbose, all=all) ; INPUTS: ; filename = ucac2_2006 file ; id = list of ids (line numbers) ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; verbose = print out error messages ; all = return all lines (ids gets set) ; KEYWORD OUTPUT PARAMETERS: ; count = number of lines found ; OUTPUTS: ; the lines for the id's ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; RESTRICTIONS: ; None ; PROCEDURE: ; MODIFICATION HISTORY: ; January 7, 2006 Leslie Young, SwRI ; Mar 10, 2006 LAY. Added "all", moved into $idl/lyoung ;- ;0 1 2 3 4 ;0123456789012345678901234567890123456789012345 ; 984001505 256280091 1407 21 1 2 1 9409 function oc_getline_ucac2_2006, ids, count=count, $ VERBOSE=verbose, ALL=all filename = '~/reference/stellar_cat/UCAC2_2006/cpos_07.p' if not isfile(filename) then begin if keyword_set(verbose) then begin print, 'oc_getline_ucac2_2006: filename not found' end count = 0 return, -1 end if keyword_set(all) then begin nid = numlines(filename) ids = lindgen(nid) + 1 end ; set up blank lines to return nid = n_elements(ids) reclen = strlen(' 984001505 256280091 1407 21 1 2 1 9409') finfo = file_info(filename) nrec = finfo.size / reclen blank = string(replicate(byte(' '), reclen)) count = 0L lines = replicate(blank, nid) ; make an associated variable openr, lun, filename, /get_lun av = ASSOC(lun, bytarr(reclen+1)) ; get the ids as long integers for iid = 0L, nid-1 do begin id = ids[iid] ok = 1 case size(id, /type) of 1: rec = long(id) ; byte 2: rec = long(id) ; integer 3: rec = id ; long 4: rec = long(id) ; floating point 5: rec = long(id) ; double 6: rec = long(id) ; complex 7: ok = strnumber(id, rec) ; string 8: ok = 0 ; structure endcase if ok then ok = (rec ge 1 and rec le nrec) if ok then begin lines[iid] = string( (av[rec-1])[0:reclen-1] ) count = count + 1 endif endfor close, lun free_lun, lun return, lines end