tiff2fitsimg

xpolbeamline.sitkconverter.tiff2fitsimg(filename, outpath, statfile=None, overwrite=False)[source]

Convert tif files and associated txt to fits image

This function takes a fits file and the associated txt file (assumed to be found in the same directory and having the same filename except for the extension) and converts that to a standard compliant fits image. It is an error if the txt file is not found.

The imaging data is saved as a 3-D datacube in the primary extension.

Parameters:

filename : string

Filename (incl path if not in the current working directory) of the tif file.

outpath : str

Directory where the fits image is written. The fits file will have the same filename as the input file (except for the extension).

statfile : string or None

Path and filename to a stats file or path to a directory of statsfiles. In the second case, this function will look for a file following the naming convention stats_MM_DD_YY.txt in the given directory. If such a file does not exist, all files with names starting with stats_ will be searched for overlap with the exposure. If statfile=None, “_NoStats” is appended to the name of the output file.

overwrite : bool

If the output file already exists, shall it be replaced?

Returns:

outfile : string

path and filename of the file that was just written