Recipe: Read an ASCII data table into AIPS++ and make plots of the data

Goals: Read an ASCII data table into AIPS++ and make plots of the data.

Using: tablefromascii function, the Table system, and the PGPlotter.

Results: Data in Glish vectors and plots of these data.

Assume: You have an input file of ASCII data in columns. In this recipe the ASCII data file sampleData.txt has three columns of numbers. The tablefromascii function will automatically decipher the format of the table in this example, but it is also possible to specify the format explicitly. See the documentation of tablefromascii in the AIPS++ User's Reference Manual for details. The ASCII data file must be in the directory from which you started AIPS++.

Script: recipe1.g

AIPS++/Glish commands and results   Purpose and Background
    
include 'pgplotter.g';
 
Include the necessary startup script for the pgplotter tool.
    
t := tablefromascii('sample', 'sampleData.txt',,T);
 
Put ASCII data into an AIPS++ table using the AIPS++ tablefromascii function. For details on what you can do with AIPS++ tables see the User's Reference Manual.

Invoking tablefromascii results in an AIPS++ Table named sample written to disk. Henceforth the table t can be recalled using t := table('sample'), without the need for this conversion step.

    
t.colnames();
 
Show column names defined in the table
    
Column1 Column2 Column3
 
Resulting list of column names.
    
x := t.getcol('Column1'); y1 := t.getcol('Column2'); y2 := t.getcol('Column3');
 
Extract data from the columns and assign them to vectors using getcol on the table t.
    
pg := pgplotter();
 
Create a pgplotter tool named pg and open a plotting window on the screen.
    
pg.plotxy1(x,y1); pg.plotxy1(x,y2);
 
Plot the data.
    

In the Pgplotter window, File can be used to preview, print, save, and load the plot. The Tools menu includes a zoom feature. The plot commands can be modified using the Edit menu options.

Contributions of recipes and other material for AIPS++ documentation are welcome. Please send them to tcornwel@nrao.edu.