If the specified input HDU is a table, then ftcopy can:
Additional information on the syntax for specifying the file filters is available in the following help files: filenames, imfilter, colfilter, rowfilter, binfilter. calc_express. The file filtering syntax is also explained in the CFITSIO User's Guide.
Note that use of a filters on the input file normally requires that the resulting virtual file be constructed entirely in memory before it is copied to the output file. This operation may fail if the virtual file is too large to fit in the available memory. One may force the virtual file to be constructed on disk, not in memory, by specifying an explicit temporary output file (e.g., 'file.fit(tempfile.fit)[events][col -PI]').
The following examples illustrate operations that can be performed on the input HDU if it is a primary array or image extension:
1. Copy a 100 X 100 pixel subset from a larger image.
ftcopy 'image.fits[101:200, 101:200]' out.fits2. Make a copy of the whole input image, reversing the pixels along the X axis. Do not copy any other HDUs in the input file.
ftcopy 'image.fits[-*,*]' out.fits copyall=NO3. Copy the odd numbered pixel from the 512 X 512 input image, creating a 256 X 256 output image
ftcopy 'image.fits[1:512:2, 1:512:2]' out.fits4. Convert an IRAF format image to a FITS image.
ftcopy irafimage.imh outimage.fits5. Convert a file containing an array of raw binary numbers into a FITS image. The data type and dimensions of the array are enclosed in square brackets following the file name. The first letter indicates the data type (b = 8-bit unsigned byte, i = 16-bit signed integer, u = 16-bit unsigned integer, j = 32-bit signed integer, r = 32-bit floating point, d = 64-bit double precision floating point). A second optional letter may be present to indicate the byte order in the array, where b = big endian (as on SUN workstations and Mac PCs) or l ('el') = little endian (as on IBM PCs). If omitted, the native byte order for the local machine is assumed. This is followed by a series of one or more integers separated by commas which define the size of each dimension of the raw array. Finally, a byte offset to the position of the first pixel in the raw file may be specified by separating it with a colon (':') from the last dimension value. This parameter may be used to skip over any header information in the file that preceeds the binary data.
ftcopy 'raw.dat[i1000]' - 1-D 1000 pixel integer*2 array ftcopy 'raw.dat[rb512,512]' - 2-D big endian real*4 image ftcopy 'raw.dat[i512,512:2880]' - skip the first 2880 bytesThe following examples illustrate operations that can be performed on table HDUs
1. Filter an EVENTS table extension, copying only those rows that have a PI column value > 20.
ftcopy 'infile.fits[EVENTS][PI > 20]' outfile.fits2. Filter an EVENTS table extension, using the row filter expression that is given in the rowfilt.txt ASCII file.
ftcopy 'infile.fits[EVENTS][@rowfilt.txt]' outfile.fits3. Filter an EVENTS table extension using the GTI (good time interval) extension contained in the input file, or (in the 2nd case) a spatial region defined in the "pow.reg" ASCII file.
ftcopy 'infile.fits[EVENTS][gtifilter()]' outfile.fits ftcopy 'infile.fits[EVENTS][regfilter("pow.reg")]' out.fits4. Copy only the X, Y and Time columns from the input events extension to the output file.
ftcopy 'infile.fits[3][col X; Y; Time]' outfile.fits5. Copy all columns except the Time column from the input events extension to the output file. Only the first 100 rows of the table are copied.
ftcopy 'infile.fits[3][col -Time][#row <101]' outfile.fits6. Copy all the columns whose names begin with X or Y from the input events extension to the output file.
ftcopy 'infile.fits[3][col X*; Y*]' outfile.fits7. Copy the table in the 3rd extension of infile.fits, and create a new column called 'LogRate' that is equal to the logarithm of the 'Counts' column divided by the Exposure keyword (or column).
ftcopy 'infile.fits[3][col LogRate = log10(Counts/Exposure)]' outfile.fits8. Create a 2-D image (histogram) from the DETX and DETY columns of an EVENTS table, and write HISTORY keyword to the output file.
ftcopy 'infile.fits[EVENTS][bin (DETX,DETY)=1:1024:16]' outfile.fits history=YES9. Copy a FITS file from the FTP site on the legacy machine;
ftcopy ftp://heasarc.gsfc.nasa.gov/rosat/data/pspc/images/fits/rp200027_im1.fits outfile.fits
fv, the interactive FITS file editor, can also be used to copy FITS files.
The design of this task is based on the fcopy and fextract tasks in the ftools package.