{ } Raw JSON

bundles / astropy latest / astropy / io / fits / hdu / hdulist / fitsopen

function

astropy.io.fits.hdu.hdulist:fitsopen

source: /astropy/io/fits/hdu/hdulist.py :48

Signature

def   fitsopen ( name mode = readonly memmap = None save_backup = False cache = True lazy_load_hdus = None ignore_missing_simple = False * use_fsspec = None fsspec_kwargs = None decompress_in_memory = False ** kwargs )

Summary

Factory function to open a FITS file and return an HDUList object.

Parameters

name : str, file-like or `pathlib.Path`

File to be opened.

mode : str, optional

Open mode, 'readonly', 'update', 'append', 'denywrite', or 'ostream'. Default is 'readonly'.

If name is a file object that is already opened, mode must match the mode the file was opened with, readonly (rb), update (rb+), append (ab+), ostream (w), denywrite (rb)).

memmap : bool, optional

Is memory mapping to be used? This value is obtained from the configuration item astropy.io.fits.Conf.use_memmap. Default is True.

save_backup : bool, optional

If the file was opened in update or append mode, this ensures that a backup of the original file is saved before any changes are flushed. The backup has the same name as the original file with ".bak" appended. If "file.bak" already exists then "file.bak.1" is used, and so on. Default is False.

cache : bool, optional

If the file name is a URL, download_file is used to open the file. This specifies whether or not to save the file locally in Astropy's download cache. Default is True.

lazy_load_hdus : bool, optional

To avoid reading all the HDUs and headers in a FITS file immediately upon opening. This is an optimization especially useful for large files, as FITS has no way of determining the number and offsets of all the HDUs in a file without scanning through the file and reading all the headers. Default is True.

To disable lazy loading and read all HDUs immediately (the old behavior) use lazy_load_hdus=False. This can lead to fewer surprises--for example with lazy loading enabled, len(hdul) can be slow, as it means the entire FITS file needs to be read in order to determine the number of HDUs. lazy_load_hdus=False ensures that all HDUs have already been loaded after the file has been opened.

uint : bool, optional

Interpret signed integer data where BZERO is the central value and BSCALE == 1 as unsigned integer data. For example, int16 data with BZERO = 32768 and BSCALE = 1 would be treated as uint16 data. Default is True so that the pseudo-unsigned integer convention is assumed.

ignore_missing_end : bool, optional

Do not raise an exception when opening a file that is missing an END card in the last header. Default is False.

ignore_missing_simple : bool, optional

Do not raise an exception when the SIMPLE keyword is missing. Note that io.fits will raise a warning if a SIMPLE card is present but written in a way that does not follow the FITS Standard. Default is False.

checksum : bool, str, optional

If True, verifies that both DATASUM and CHECKSUM card values (when present in the HDU header) match the header and data of all HDU's in the file. Updates to a file that already has a checksum will preserve and update the existing checksums unless this argument is given a value of 'remove', in which case the CHECKSUM and DATASUM values are not checked, and are removed when saving changes to the file. Default is False.

disable_image_compression : bool, optional

If True, treats compressed image HDU's like normal binary table HDU's. Default is False.

do_not_scale_image_data : bool, optional

If True, image data is not scaled using BSCALE/BZERO values when read. Default is False.

character_as_bytes : bool, optional

Whether to return bytes for string columns, otherwise unicode strings are returned, but this does not respect memory mapping and loads the whole column in memory when accessed. Default is False.

ignore_blank : bool, optional

If True, the BLANK keyword is ignored if present. Default is False.

scale_back : bool, optional

If True, when saving changes to a file that contained scaled image data, restore the data to the original type and reapply the original BSCALE/BZERO values. This could lead to loss of accuracy if scaling back to integer values after performing floating point operations on the data. Default is False.

output_verify : str

Output verification option. Must be one of "fix", "silentfix", "ignore", "warn", or "exception". May also be any combination of "fix" or "silentfix" with "+ignore", +warn, or +exception" (e.g. ``"fix+warn"). See astropy:verify for more info.

use_fsspec : bool, optional

Use fsspec.open to open the file? Defaults to False unless name starts with the Amazon S3 storage prefix s3:// or the Google Cloud Storage prefix gs://. Can also be used for paths with other prefixes (e.g., http://) but in this case you must explicitly pass use_fsspec=True. Use of this feature requires the optional fsspec package. A ModuleNotFoundError will be raised if the dependency is missing.

fsspec_kwargs : dict, optional

Keyword arguments passed on to fsspec.open. This can be used to configure cloud storage credentials and caching behavior. For example, pass fsspec_kwargs={"anon": True} to enable anonymous access to Amazon S3 open data buckets. See fsspec's documentation for available parameters.

decompress_in_memory : bool, optional

By default files are decompressed progressively depending on what data is needed. This is good for memory usage, avoiding decompression of the whole file, but it can be slow. With decompress_in_memory=True it is possible to decompress instead the whole file in memory.

Returns

hdulist : `HDUList`

HDUList containing all of the header data units in the file.

Aliases

  • astropy.io.fits.open

Referenced by