How to use the fitsio.util.FITSRuntimeWarning 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 / header.py View on Github external
elif front == _BLANK:
                    self._set_as_blank()
                else:
                    # note anything without an = and not history and not blank
                    # key comment is treated as COMMENT; this is built into
                    # cfitsio as well
                    self._set_as_comment()

                if self.has_equals():
                    mess = (
                        "warning: It is not FITS-compliant for a %s header "
                        "card to include an = sign. There may be slight "
                        "inconsistencies if you write this back out to a "
                        "file.")
                    mess = mess % (card_string[:8])
                    warnings.warn(mess, FITSRuntimeWarning)
            else:
                self._set_as_key()
github esheldon / fitsio / fitsio / hdu / table.py View on Github external
else:
            stype = str

        dlist = self._FITS.read_var_column_as_list(self._ext+1, colnum+1, rows)

        if vstorage == 'fixed':
            tform = self._info['colinfo'][colnum]['tform']
            max_size = _extract_vararray_max(tform)

            if max_size <= 0:
                name = self._info['colinfo'][colnum]['name']
                mess = 'Will read as an object field'
                if max_size < 0:
                    mess = "Column '%s': No maximum size: '%s'. %s"
                    mess = mess % (name, tform, mess)
                    warnings.warn(mess, FITSRuntimeWarning)
                else:
                    mess = "Column '%s': Max size is zero: '%s'. %s"
                    mess = mess % (name, tform, mess)
                    warnings.warn(mess, FITSRuntimeWarning)

                # we are forced to read this as an object array
                return self._read_var_column(colnum, rows, 'object')

            if isinstance(dlist[0], stype):
                descr = 'S%d' % max_size
                array = numpy.fromiter(dlist, descr)
                if IS_PY3:
                    array = array.astype('U', copy=False)
            else:
                descr = dlist[0].dtype.str
                array = numpy.zeros((len(dlist), max_size), dtype=descr)
github esheldon / fitsio / fitsio / hdu / table.py View on Github external
descr = (name, 'O')
            else:
                tform = self._info['colinfo'][colnum]['tform']
                max_size = _extract_vararray_max(tform)

                if max_size <= 0:
                    name = self._info['colinfo'][colnum]['name']
                    mess = 'Will read as an object field'
                    if max_size < 0:
                        mess = "Column '%s': No maximum size: '%s'. %s"
                        mess = mess % (name, tform, mess)
                        warnings.warn(mess, FITSRuntimeWarning)
                    else:
                        mess = "Column '%s': Max size is zero: '%s'. %s"
                        mess = mess % (name, tform, mess)
                        warnings.warn(mess, FITSRuntimeWarning)

                    # we are forced to read this as an object array
                    return self.get_rec_column_descr(colnum, 'object')

                if npy_type[0] == 'S':
                    # variable length string columns cannot
                    # themselves be arrays I don't think
                    npy_type = 'S%d' % max_size
                    descr = (name, npy_type)
                elif npy_type[0] == 'U':
                    # variable length string columns cannot
                    # themselves be arrays I don't think
                    npy_type = 'U%d' % max_size
                    descr = (name, npy_type)
                else:
                    descr = (name, npy_type, max_size)
github esheldon / fitsio / fitsio / hdu / base.py View on Github external
int(value),
                                      str(comment))
        elif isinstance(value, (tuple, list)):
            vl = [str(el) for el in value]
            sval = ','.join(vl)
            self._FITS.write_string_key(self._ext+1,
                                        str(name),
                                        sval,
                                        str(comment))
        else:
            sval = str(value)
            mess = (
                "warning, keyword '%s' has non-standard "
                "value type %s, "
                "Converting to string: '%s'")
            warnings.warn(mess % (name, type(value), sval), FITSRuntimeWarning)
            self._FITS.write_string_key(self._ext+1,
                                        str(name),
                                        sval,
                                        str(comment))