NAME

ahgetvector - Extract vectors from a FITS file and output into an ASCII file

USAGE

ahgetvector infile outfile selmode xcol ycol row element

DESCRIPTION

The ahgetvector Perl script extracts vectors from a pair of columns in a FITS file table and formats the data as text in an ASCII file with two columns. This format conversion facilitates the plotting of selected elements in columns with multiple elements.

The input FITS file extension must be in the form of a table where columns are either a single element array or a multi-element array. The task may output the elements in two columns with the same number of elements for a given row by setting 'selmode=2', selecting the row number using the 'row' parameter, and the names of the two columns using the 'xcol' and 'ycol' parameters. Alternatively, the task may output the values in a single-element column, and those for a particular element in a multi-element column, for each row by setting 'selmode=1'. In this case the single-element column is specified by 'xcol', the multi-element column by 'ycol', and the element index is selected using the 'element' parameter. This element index must be within the valid range of vector elements for the 'ycol' column. For example, if the TFORM keyword for 'ycol' is 3E, 'element' must not be larger than three. The file name and extension are determined by the 'infile' parameter. If no extension is specified, the first extension is used.

PARAMETERS

infile [string]
Name of input FITS file with optional extension name.

outfile [string STDOUT|file name]
Name of output ASCII file, or STDOUT to write to screen.

selmode = 1 [integer 1|2]
Select the data by either sub-element ('selmode=1') or by row ('selmode=2'). If selecting by sub-element, the parameter 'element' is required. If selecting by row, the 'row' parameter is required.

xcol = energy [string]
Single column name to output as the first column in the output file.

ycol = refprob01 [string]
Single column name to output as the second column in the output file.

row = 12 [integer]
If 'selmode' is set to 2, the 'row' parameter specifies which row to retrieve. This must be a single row number, not a range of rows. This parameter is ignored when 'selmode=1'.

element = 1 [integer]
If 'selmode' is set to 1, the 'element' parameter specifies which element to retrieve. This must be within the valid range of vector elements for the 'ycol' column. This parameter is ignored when 'selmode=2'.

(cleanup = yes) [boolean yes|no]
Delete temporary files.

(clobber = no) [boolean yes|no]
Overwrites the existing output file if set to yes.

(chatter = 1) [integer 0|1|2|3]
Chatter level for output. Set to 0 to suppress output, or to 1, 2, or 3 for increasing the chatter of the output.

(logfile = !DEFAULT) [string DEFAULT|NONE|file name]
Log file name. If set to DEFAULT, uses the name of the task and, if preceded by "!", overwrites the file if it exists. If set to NONE, no log file is created.

(debug = no) [boolean yes|no]
Diagnostic output is printed to the screen if set to yes.

(history = yes) [boolean yes|no]
Records tool parameters in HISTORY.

EXAMPLES

  1. Extract vectors from a reflectivity probability file by element. Get the reflectivity for every energy, for the second angle in the incident angle array.
       ahgetvector infile="ah_sxt_xrtreftb.fits[AX_SXT_FRONT]" outfile=out.txt selmode=1 xcol=energy ycol=REFPROB01 \
          row=- element=2 
    
    In this example, the input file has 3 columns with the format:
          ENERGY    ANGLE     REFPROB01
          keV       rad       
          1E        2E        2E
    
    And 4 rows under each column:
          ENERGY    ANGLE       REFPROB01
          10        0.02 0.03   0.51 0.29
          12        0.02 0.03   0.44 0.27
          14        0.02 0.03   0.41 0.23
          15        0.02 0.03   0.31 0.17
    
    The output ASCII file out.txt is as follows:
          ENERGY    REFPROB01
          10        0.29
          12        0.27
          14        0.23
          15        0.17  
    
  2. Extract vectors from a reflectivity probability file by row. Get the reflectivity for every angle, for the third energy.
       ahgetvector infile="ah_sxt_xrtreftb.fits[AX_SXT_FRONT]" outfile=out.txt selmode=2 xcol=angle ycol=REFPROB01 \
          row=3 element=-
    
    In this example, the input file has 3 columns with the format:
          ENERGY    ANGLE     REFPROB01
          keV       rad       
          1E        2E        2E
    
    And 4 rows under each column:
          ENERGY    ANGLE       REFPROB01
          10        0.02 0.03   0.51 0.29
          12        0.02 0.03   0.44 0.27
          14        0.02 0.03   0.41 0.23
          15        0.02 0.03   0.31 0.17
    
    The output ASCII file out.txt is as follows:
          ANGLE    REFPROB01
          0.02      0.41
          0.03      0.23
    

LAST MODIFIED

October 4, 2021