About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/ascii2fits.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 ascii2fits Context: tools

Synopsis

Convert simple ASCII files to FITS format files

Syntax

ascii2fits [-s nskip] infile [outfile]

Description

The ascii2fits script provides a quick way to convert ASCII files to FITS format files and uses the input/output routines from Varmm to do the conversion. Please note that the script does not have a parameter interface, so all parameters must be specified on the command line when it is called. The script can understand two types of input file:

Simple ASCII files

Tab- or space-delimited columns of numerical data, which will be converted to either single or double-precision floating-point numbers, depending upon the inferred range of the column. Comments are allowed - indicated by a '#' character as the first item in a line - but only at the top of the file (those interspersed with data will appear in the table with undefined values, often zero), and are not propagated to the FITS header.

The output is not well defined if the input file contains non-numeric columns. If the text does not contain any spaces then the the column will be converted to 0's; if it does contain spaces then it is likely that the whole output file will be unusable.

RDB tables

These are tab-delimited flat files which can contain a mixture of string and numeric columns, plus metadata and optional comments (which may appear either at the top of file or interspersed with the data). Header comments are propagated to the FITS file as COMMENT cards.

The output file

If a second parameter is given then it will be used as the name of the output file, otherwise a filename will be automatically generated and printed to the standard output (normally the screen). In the latter case, the new file will be created in the $ASCDS_TMP directory (or /tmp/ if this environment variable does not exist). The block name of the FITS table is set equal to the name of the input file, subject to the constraints of the FITS standard.

Note that the script will over-write any existing file - i.e. it behaves like tools which have their clobber parameter set to yes.

Ignoring lines

The "-s nskip" option can be used to ignore the first "nskip" lines in the input file.

Example 1

ascii2fits in.dat out.fits

Converts the contents of the ASCII file in.dat into a FITS table stored in out.fits. As an example, if in.dat contained

  unix% cat in.dat
  # this is a comment line
  1  10  3.16
  2  11  3.32
  3  14  3.74
  4  19  4.36
  5  26  5.10

then the output (out.fits) would look like

  unix% dmlist out.fits cols

  ----------------------------------------------------------------------
  Columns for Table Block in.dat
  ----------------------------------------------------------------------

  ColNo  Name       Unit   Type        Range
     1   col1               Real4     -Inf:+Inf    label for field   1
     2   col2               Real4     -Inf:+Inf    label for field   2
     3   col3               Real4     -Inf:+Inf    label for field   3

Example 2

ascii2fits in.rdb out.fits

Converts the contents of the ASCII RDB file in.rdb into a FITS table stored in out.fits.

Hardcopy (PDF): A4 | Letter
Last modified: December 2006



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.