How to use the fitsio.hdu._npy2fits 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
"ascii tables: '%s'" % npy_dtype)
            if npy_dtype in ['u2']:
                raise ValueError(
                    "unsigned 2-byte integers are not supported for "
                    "ascii tables: '%s'" % npy_dtype)

        if npy_dtype[0] == 'O':
            # this will be a variable length column 1Pt(len) where t is the
            # type and len is max length.  Each element must be convertible to
            # the same type as the first
            name = d[0]
            form, dim = npy_obj2fits(data, name)
        elif npy_dtype[0] == "V":
            continue
        else:
            name, form, dim = _npy2fits(
                d, table_type=table_type, write_bitcols=write_bitcols)

        if name == '':
            raise ValueError("field name is an empty string")

        """
        if is_ascii:
            if dim is not None:
                raise ValueError("array columns are not supported for "
                                 "ascii tables")
        """
        name_nocase = name.upper()
        if name_nocase in names_nocase:
            raise ValueError(
                "duplicate column name found: '%s'.  Note "
                "FITS column names are not case sensitive" % name_nocase)
github esheldon / fitsio / fitsio / fitslib.py View on Github external
"ascii tables: '%s'" % dname)
            if dname in ['u2']:
                raise ValueError(
                    "unsigned 2-byte integers are not supported for "
                    "ascii tables: '%s'" % dname)

        if dname[0] == 'O':
            # this will be a variable length column 1Pt(len) where t is the
            # type and len is max length.  Each element must be convertible to
            # the same type as the first
            form, dim = npy_obj2fits(this_data)
        else:
            send_dt = dt
            if len(this_data.shape) > 1:
                send_dt = list(dt) + [this_data.shape[1:]]
            _, form, dim = _npy2fits(
                send_dt, table_type=table_type, write_bitcols=write_bitcols)

        formats.append(form)
        dims.append(dim)

    return names, formats, dims
github esheldon / fitsio / fitsio / fitslib.py View on Github external
for d in descr:

        """
        npy_dtype = d[1][1:]
        if is_ascii and npy_dtype in ['u1','i1']:
            raise ValueError("1-byte integers are not supported for "
                             "ascii tables")
        """

        if d[1][1] == 'O':
            raise ValueError(
                'cannot automatically declare a var column without '
                'some data to determine max len')

        name, form, dim = _npy2fits(
            d, table_type=table_type, write_bitcols=write_bitcols)

        if name == '':
            raise ValueError("field name is an empty string")

        """
        if is_ascii:
            if dim is not None:
                raise ValueError("array columns are not supported "
                                 "for ascii tables")
        """

        names.append(name)
        formats.append(form)
        dims.append(dim)