NAME

sumvec - A Perl script to create a new column that is the sum of elements in a vector column

USAGE

sumvec infile colname elements outcol outfile [clobber]

DESCRIPTION

This Perl script is designed to add up specified elements of a vector column and write the value to a new column. The user specifies the vector column within the input FITS file they would like to use. The vector column consists of n elements (col[1,2,...,n]). A list of elements is given to be summed, either as a comma-separated list, a range, or a combination of the two. A new column, outcol, is written that contains the sum of the elements from the vector for each row.

PARAMETERS

infile [filename]
Input filename

colname [string]
Name of vector column in infile whose elements will be summed.

elements [string]
The elements in colname to be summed. These can be given as a comma-separated list (e.g. 1,4,7), a range (e.g. 2-10), or a combination of the two (e.g. 1,3-5,10). Also accepts 'all' as input. Values start from 1. Default: 'all'

outcol [string]
Name of the output column containing the sum of the elements.

outfile [string]
Name of the output file.

(clobber = no) [boolean]
Overwrite existing file(s)?

EXAMPLES

The following examples illustrate

1. Adding the elements 1, 5, and 7 in the column COUNTS within file input.fits. The output file test.fits will contain the same columns as input.fits plus the additional column SUM, which contains the sum of the aforementioned elements.

      sumvec infile=input.fits colname=COUNTS elements="1,5,7" outcol=SUM outfile=test.fits 
2. Adding the elements 2 through 10 in the column PHA within file input.fits. The column SUM_1 containing the sum of all the elements is written to input.fits since outfile is set to the same name. Clobber is set to yes since the input file is being overwritten.

      sumvec infile=input.fits colname=PHA elements="2-10" outcol=SUM_1 outfile=input.fits clobber=yes 

SEE ALSO

LAST MODIFIED

February 2025