Module for handling IO in SALT software.

All calls to IO functions should go through this module.

Note this is a replacement for the saltio module.


convert relative path to absolute path

saltsafeio.argdefined(argument, value)

has an argument been defined?

saltsafeio.argunpack(argument, value)

For arguments that might be a file or list, unpack to make a single list


Ask for a user response

returns the response


Given a list of fits files returns an index of exposures for use with get_indexed_exposure.


change working directory

saltsafeio.cleanpropcode(pids, propids)

Create the list of appropriate proprosal codes


close ASCII file


close HDU structure

saltsafeio.comparelists(list1, list2, name1, name2)

are two lists the same length?

saltsafeio.copy(file1, file2)

copy file

saltsafeio.copydir(file1, file2)

copy direcotry recursively


create a directory


delete a file


delete a directory, username, password, sender, recipient, bcc, subject, message)

send email

saltsafeio.filedefined(filetype, file)

has a file been defined?


check that a file does not exist


check that a file exists

saltsafeio.filesexist(infiles, path, mode)

check files in list exist


construct FITS table columns

saltsafeio.getSection(section, iraf_format=True)
Given an input string for a section in an image, it will
return the input as a list.
section: An input string given a section in the image
Set to None to return the whole image

iraf_format: It will invert the x and y values

saltsafeio.get_exposure(files, number=1)

Given a list of fits files returns exposure data as numpy array.

By default get_exposure will return the first exposure with data. If number parameter is given it will browse the file list until the requested exposure number is found.

Because of this browing get_exposure is only fast for small exposure number. If the exposure numbers are always big or if you need to access a lot of exposures you should use build_exposure_index and get_indexed_exposure instead.

saltsafeio.get_indexed_exposure(files, index, number=1)

Given a list of fits files and a index generated by build_exposure_index it returns the requested exposure as a numpy array.

By default get_exposure will return the first exposure with data. If number parameter is given it will browse the file list until the requested exposure number is found.

The index consumes a lot of memory. Only use get_indexed_exposure when you need to access a large number of exposures fast, or when the exposure number is always big. Otherwise you should use get_exposure instead.

saltsafeio.listexists(filetype, file)

does a list file exist, i.e. a parameter that begins with the ‘@’ character

saltsafeio.listparse(listtype, inlist, pref, altlist, path)

create a list from a file or parameter


test the log file exists

saltsafeio.move(file1, file2)

move file

saltsafeio.newfitstable(table, infile=None)

write FITS table

saltsafeio.openascii(file, type)

open ASCII file

saltsafeio.openbinary(file, type)

Open binary file.

saltsafeio.openfits(infile, mode='copyonwrite', memmap=False)

open FITS file


open FITS file for updating

saltsafeio.overwrite(infile, clobber)

clobber if file is to be overwritten


check that a path exists and name ends with a /

saltsafeio.readbinary(content, size, format)

read data from a binary file.


read CCD geometry definition file


read gain database file

saltsafeio.readheader(struct, hdu)

read image from HDU structure

saltsafeio.readimage(struct, hdu)

read image from HDU structure

saltsafeio.readimages(filetype, images)

Read in and parse a list of input images


Returns list from epar parameter.

It accepts the following for param A filename prefixed by @, for example:


will read names from the file images. A comma separated list of filenames

saltsafeio.readtab(hdu, infile='')

read FITS table HDU


read crosstalk coefficent file


Remove propcodes that you do not want –namely junk, bias, test


Removing propcodes that are associated with engineering and calibration proposals

create symbolic link


create a temporary file name


update existing FITS file

saltsafeio.writefits(struct, outfile, clobber=True)

write to FITS file

saltsafeio.writeimage(struct, hdu, imagedata)

write image from HDU structure


Ask for a [y/n] user response

returns the response

Previous topic


Next topic


This Page