How to use the fitsio._fitsio_wrap.FITS function in fitsio

To help you get started, we’ve selected a few fitsio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esheldon / fitsio / fitsio / fitslib.py View on Github external
header.  Send extver= to select a particular version.  If extver is not
        sent, the first one will be selected.  If ext is an integer, the extver
        is ignored.
    case_sensitive: bool, optional
        Match extension names with case-sensitivity.  Default is False.
    """

    filename = extract_filename(filename)

    dont_create = 0
    try:
        hdunum = ext+1
    except TypeError:
        hdunum = None

    _fits = _fitsio_wrap.FITS(filename, READONLY, dont_create)

    if hdunum is None:
        extname = mks(ext)
        if extver is None:
            extver_num = 0
        else:
            extver_num = extver

        if not case_sensitive:
            # the builtin movnam_hdu is not case sensitive
            hdunum = _fits.movnam_hdu(ANY_HDU, extname, extver_num)
        else:
            # for case sensitivity we'll need to run through
            # all the hdus
            found = False
            current_ext = 0
github esheldon / fitsio / fitsio / fitslib.py View on Github external
# Will not test existence when reading, let cfitsio
        # do the test and report an error.  This allows opening
        # urls etc.
        create = 0
        if self.mode in [READWRITE, 'rw']:
            if clobber:
                create = 1
                if os.path.exists(filename):
                    os.remove(filename)
            else:
                if os.path.exists(filename):
                    create = 0
                else:
                    create = 1

        self._FITS = _fitsio_wrap.FITS(filename, self.intmode, create)
github esheldon / fitsio / fitsio / fitslib.py View on Github external
def reopen(self):
        """
        close and reopen the fits file with the same mode
        """
        self._FITS.close()
        del self._FITS
        self._FITS = _fitsio_wrap.FITS(self._filename, self.intmode, 0)
        self.update_hdu_list()