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 presentedKEYWORD PARAMETERS:
-help: if set show the help -columns: [(array of) integers of 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.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 ->RESTRICTIONS: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 are named, COLUMN0, COLUMN1, ... , COLUMNX, where X stands for the total number of columns read.
The file to be read should be formatted as a machine readable datafile. EXAMPLE: meas = read_fmr('smith.dat',col=[2,5,6]) plot,meas.data.column1,ytitle=meas.name[1]+' ('+meas.unit[1]+')' and data = read_fmr('smith.dat',col=['Name','Date']) print,meas.data.column0MODIFICATION 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: Updated to be compatible with older versions of IDL. Removed keyword /read from file_exist Replaced strplit with str_sep Fixed bug where column=[3,4] always returned the first few columns
Program has been sucessufully compiled and tested on IDL 5.2 running on a SUN Ultra 10.
Please contact the author, Sacha Hony, for questions or comments about this program.
Click here to download read_fmr.pro