How to use the fitsio.util.IS_PY3 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 / hdu / image.py View on Github external
You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

"""
from __future__ import with_statement, print_function
from functools import reduce

import numpy

from math import floor
from .base import HDUBase, IMAGE_HDU
from ..util import IS_PY3, array_to_native

# for python3 compat
if IS_PY3:
    xrange = range


class ImageHDU(HDUBase):
    def _update_info(self):
        """
        Call parent method and make sure this is in fact a
        image HDU.  Set dims in C order
        """
        super(ImageHDU, self)._update_info()

        if self._info['hdutype'] != IMAGE_HDU:
            mess = "Extension %s is not a Image HDU" % self.ext
            raise ValueError(mess)

        # convert to c order
github esheldon / fitsio / fitsio / fitslib.py View on Github external
"""
from __future__ import with_statement, print_function
import os
import numpy

from . import _fitsio_wrap
from .util import IS_PY3, mks, array_to_native, isstring
from .header import FITSHDR
from .hdu import (
    ANY_HDU, IMAGE_HDU, BINARY_TBL, ASCII_TBL,
    ImageHDU, AsciiTableHDU, TableHDU,
    _table_npy2fits_form, _npy2fits, _hdu_type_map)

# for python3 compat
if IS_PY3:
    xrange = range


READONLY = 0
READWRITE = 1

NOCOMPRESS = 0
RICE_1 = 11
GZIP_1 = 21
GZIP_2 = 22
PLIO_1 = 31
HCOMPRESS_1 = 41


def read(filename, ext=None, extver=None, columns=None, rows=None,
         header=False, case_sensitive=False, upper=False, lower=False,
github esheldon / fitsio / fitsio / hdu / table.py View on Github external
if (isinstance(dlist[0], str) or
                        (IS_PY3 and isinstance(dlist[0], bytes))):
                    is_string = True
                else:
                    is_string = False

                if array[name].dtype.descr[0][1][1] == 'O':
                    # storing in object array
                    # get references to each, no copy made
                    for irow, item in enumerate(dlist):
                        if IS_PY3 and isinstance(item, bytes):
                            item = item.decode('ascii')
                        array[name][irow] = item
                else:
                    for irow, item in enumerate(dlist):
                        if IS_PY3 and isinstance(item, bytes):
                            item = item.decode('ascii')

                        if is_string:
                            array[name][irow] = item
                        else:
                            ncopy = len(item)

                            if IS_PY3:
                                ts = array[name].dtype.descr[0][1][1]
                                if ts != 'S' and ts != 'U':
                                    array[name][irow][0:ncopy] = item[:]
                                else:
                                    array[name][irow] = item
                            else:
                                array[name][irow][0:ncopy] = item[:]
github esheldon / fitsio / fitsio / header.py View on Github external
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

"""
from __future__ import with_statement, print_function
import warnings

from . import _fitsio_wrap
from .util import isstring, FITSRuntimeWarning, IS_PY3

# for python3 compat
if IS_PY3:
    xrange = range

TYP_STRUC_KEY = 10
TYP_CMPRS_KEY = 20
TYP_SCAL_KEY = 30
TYP_NULL_KEY = 40
TYP_DIM_KEY = 50
TYP_RANG_KEY = 60
TYP_UNIT_KEY = 70
TYP_DISP_KEY = 80
TYP_HDUID_KEY = 90
TYP_CKSUM_KEY = 100
TYP_WCS_KEY = 110
TYP_REFSYS_KEY = 120
TYP_COMM_KEY = 130
TYP_CONT_KEY = 140