idlastro / Disk I/O (e.g. IRAF files): READ_FMR

[Source code]

NAME
READ_FMR
PURPOSE
Read a journal (ApJ, AJ) machine-readable table into IDL
EXPLANATION
Given a machine readable table name and optionally column
numbers, this FUNCTION reads the format information in the
meta-header and outputs a IDL function containing either the
complete table or only the requested columns.
CALLING SEQUENCE
data = read_fmr(filename)
INPUTS
filename [STRING]: the name of the file containing the machine
readable table. If filename is missing a dialog to select the
filename will be presented
INPUT KEYWORD PARAMETERS
/HELP  - if set show the help
COLUMNS -  [(array of) integers or strings] of column(s) to be returned.
  If columns is of type integer they represent indices for which
  column numbers to return, if they are strings the columns with the
  corresponding names will be returned in the order as given.
MISSINGVALUE [float]: value with which to replace the missing values in the 
     table, default is NaN.
/USE_COLNUM - If  specified and non-zero then column names will be generated
     as 'C1, C2,  .... Cn'  for the number of columns in the table, rather
     than using the table names.
OUTPUTS
The ouput data structure will look like:
  TYPE            STRING    'mr_structure'
  NAME            STRING    Array[X]
  UNIT            STRING    Array[X]
  DESCRIPTION     STRING    Array[X]
  DATA            STRUCT    ->  Array[1]
where name contains the names of each columns
unit contains the given units
description contains the short descriptions and
data holds the values of the separate columns.   By default the tag names are
taken from the column names, with modifications necessary to make them a 
valid tag name.    For example, the column name 'B-V' will be converted to 
'B_V' to become a valid tag name.    If the /USE_COLNUM keyword is set, then
the column will be named  C0,  C1, ... , CX, where X stands for the total 
number of columns read.
RESTRICTIONS
(1) The file to be read should be formatted as a machine readable datafile.
(2) Use of the COLUMN keyword currently requires use of the EXECUTE function,
    and so cannot be used with the IDL Virtual machine.
EXAMPLE
meas = read_fmr('smith.dat',col=[2,5,6], /Use_colnum)
 plot,meas.data.c1,ytitle=meas.name[1]+' ('+meas.unit[1]+')'
and
data = read_fmr('smith.dat',col=['Name','Date'], /Use_colnum)
 print,meas.data.c0
MODIFICATION HISTORY
Version 1:
Written by Sacha Hony (ESA) Nov 14 2003
 Based heavily on mrcolextract by Greg Schwarz (AAS Journals
 staff scientist) on 8/16/00.
Version 1.1:
  Fixed bug where column=[3,4] always returned the first few columns
VErsion 2.0 By default use column names as tag names W. Landsman Feb 2010
Version 3.0 Use long integers W. Landsman/T. Ellsworth-Bowers May 2013
Version 3.1 Assume since IDL V6.4  W.L. Aug 2013