How to use the fitsio.hdu.ASCII_TBL 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
"""

        # raised IOError if not found
        hdu_type = self._FITS.movabs_hdu(ext+1)

        if hdu_type == IMAGE_HDU:
            hdu = ImageHDU(self._FITS, ext)
        elif hdu_type == BINARY_TBL:
            hdu = TableHDU(
                self._FITS, ext,
                lower=self.lower, upper=self.upper,
                trim_strings=self.trim_strings,
                vstorage=self.vstorage, case_sensitive=self.case_sensitive,
                iter_row_buffer=self.iter_row_buffer,
                write_bitcols=self.write_bitcols)
        elif hdu_type == ASCII_TBL:
            hdu = AsciiTableHDU(
                self._FITS, ext,
                lower=self.lower, upper=self.upper,
                trim_strings=self.trim_strings,
                vstorage=self.vstorage, case_sensitive=self.case_sensitive,
                iter_row_buffer=self.iter_row_buffer,
                write_bitcols=self.write_bitcols)
        else:
            mess = ("extension %s is of unknown type %s "
                    "this is probably a bug")
            mess = mess % (ext, hdu_type)
            raise IOError(mess)

        self.hdu_list.append(hdu)
        self.hdu_map[ext] = hdu
github esheldon / fitsio / fitsio / fitslib.py View on Github external
def _extract_table_type(type):
    """
    Get the numerical table type
    """
    if isinstance(type, str):
        type = type.lower()
        if type[0:7] == 'binary':
            table_type = BINARY_TBL
        elif type[0:6] == 'ascii':
            table_type = ASCII_TBL
        else:
            raise ValueError(
                "table type string should begin with 'binary' or 'ascii' "
                "(case insensitive)")
    else:
        type = int(type)
        if type not in [BINARY_TBL, ASCII_TBL]:
            raise ValueError(
                "table type num should be BINARY_TBL (%d) or "
                "ASCII_TBL (%d)" % (BINARY_TBL, ASCII_TBL))
        table_type = type

    return table_type