Documentation ¶
Overview ¶
Package cfitsio is a wrapper around the CFITSIO library.
Index ¶
- func CopyHDU(dst, src *File, morekeys int) error
- func CopyTable(dst, src *Table) error
- func CopyTableRange(dst, src *Table, beg, end int64) error
- func Version() float32
- func WriteHDU(w io.Writer, src *File) error
- type Card
- type Column
- type Error
- type File
- func (f *File) CHDU() HDU
- func (f *File) Close() error
- func (f *File) Copy(out *File, previous, current, following bool) error
- func (f *File) Delete() error
- func (f *File) HDU(i int) HDU
- func (f *File) HDUNum() int
- func (f *File) HDUType() (HDUType, error)
- func (f *File) HDUs() []HDU
- func (f *File) Mode() (Mode, error)
- func (f *File) Name() (string, error)
- func (f *File) NumHDUs() (int, error)
- func (f *File) SeekHDU(hdu int, whence int) error
- func (f *File) SeekHDUByName(hdu HDUType, extname string, extvers int) error
- func (f *File) UrlType() (string, error)
- type HDU
- type HDUType
- type Header
- func (h *Header) AddComment(v string)
- func (h *Header) AddHistory(v string)
- func (h *Header) Append(cards ...Card) *Header
- func (h *Header) Axes() []int64
- func (h *Header) Bitpix() int64
- func (h *Header) Clear()
- func (h *Header) Comment() string
- func (h *Header) Get(n string) *Card
- func (h *Header) History() string
- func (h *Header) Index(n string) int
- func (h *Header) Keys() []string
- func (h *Header) Set(n string, v interface{}, comment string)
- type ImageHDU
- type Mode
- type PrimaryHDU
- type Rows
- type Table
- func (hdu *Table) Close() error
- func (hdu *Table) Col(i int) *Column
- func (hdu *Table) Cols() []Column
- func (hdu *Table) Data(interface{}) error
- func (hdu *Table) Header() Header
- func (hdu *Table) Index(n string) int
- func (hdu *Table) Name() string
- func (hdu *Table) NumCols() int
- func (hdu *Table) NumRows() int64
- func (hdu *Table) Read(beg, end int64) (*Rows, error)
- func (hdu *Table) ReadRange(beg, end, inc int64) (*Rows, error)
- func (hdu *Table) Type() HDUType
- func (hdu *Table) Version() int
- func (hdu *Table) Write(args ...interface{}) error
- type TypeCode
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyHDU ¶
CopyHDU copies the current HDU from the FITS file associated with infptr and append it to the end of the FITS file associated with outfptr. Space may be reserved for MOREKEYS additional keywords in the output header.
func CopyTableRange ¶
CopyTableRange copies the rows interval [beg,end) from src into dst
Types ¶
type Column ¶
type Column struct { Name string // column name, corresponding to “TTYPE“ keyword Format string // column format, corresponding to “TFORM“ keyword Unit string // column unit, corresponding to “TUNIT“ keyword Null string // null value, corresponding to “TNULL“ keyword Bscale float64 // bscale value, corresponding to “TSCAL“ keyword Bzero float64 // bzero value, corresponding to “TZERO“ keyword Display string // display format, corresponding to “TDISP“ keyword Dim []int64 // column dimension corresponding to “TDIM“ keyword Start int64 // column starting position, corresponding to “TBCOL“ keyword Type TypeCode Len int // repeat. if <= 1: scalar Value Value // value at current row }
Column represents a column in a FITS table
type Error ¶
type Error int
Error is a CFITSIO error status code
var ( CREATE_DISK_FILE Error = C.CREATE_DISK_FILE OPEN_DISK_FILE Error = C.OPEN_DISK_FILE SKIP_TABLE Error = C.SKIP_TABLE SKIP_IMAGE Error = C.SKIP_IMAGE SKIP_NULL_PRIMARY Error = C.SKIP_NULL_PRIMARY USE_MEM_BUFF Error = C.USE_MEM_BUFF OVERFLOW_ERR Error = C.OVERFLOW_ERR PREPEND_PRIMARY Error = C.PREPEND_PRIMARY SAME_FILE Error = C.SAME_FILE TOO_MANY_FILES Error = C.TOO_MANY_FILES FILE_NOT_OPENED Error = C.FILE_NOT_OPENED FILE_NOT_CREATED Error = C.FILE_NOT_CREATED WRITE_ERROR Error = C.WRITE_ERROR END_OF_FILE Error = C.END_OF_FILE READ_ERROR Error = C.READ_ERROR FILE_NOT_CLOSED Error = C.FILE_NOT_CLOSED ARRAY_TOO_BIG Error = C.ARRAY_TOO_BIG READONLY_FILE Error = C.READONLY_FILE MEMORY_ALLOCATION Error = C.MEMORY_ALLOCATION BAD_FILEPTR Error = C.BAD_FILEPTR NULL_INPUT_PTR Error = C.NULL_INPUT_PTR SEEK_ERROR Error = C.SEEK_ERROR BAD_URL_PREFIX Error = C.BAD_URL_PREFIX TOO_MANY_DRIVERS Error = C.TOO_MANY_DRIVERS DRIVER_INIT_FAILED Error = C.DRIVER_INIT_FAILED NO_MATCHING_DRIVER Error = C.NO_MATCHING_DRIVER URL_PARSE_ERROR Error = C.URL_PARSE_ERROR RANGE_PARSE_ERROR Error = C.RANGE_PARSE_ERROR SHARED_ERRBASE Error = C.SHARED_ERRBASE SHARED_BADARG Error = C.SHARED_BADARG SHARED_NULPTR Error = C.SHARED_NULPTR SHARED_TABFULL Error = C.SHARED_TABFULL SHARED_NOTINIT Error = C.SHARED_NOTINIT SHARED_IPCERR Error = C.SHARED_IPCERR SHARED_NOMEM Error = C.SHARED_NOMEM SHARED_AGAIN Error = C.SHARED_AGAIN SHARED_NOFILE Error = C.SHARED_NOFILE SHARED_NORESIZE Error = C.SHARED_NORESIZE HEADER_NOT_EMPTY Error = C.HEADER_NOT_EMPTY KEY_NO_EXIST Error = C.KEY_NO_EXIST KEY_OUT_BOUNDS Error = C.KEY_OUT_BOUNDS VALUE_UNDEFINED Error = C.VALUE_UNDEFINED NO_QUOTE Error = C.NO_QUOTE BAD_INDEX_KEY Error = C.BAD_INDEX_KEY BAD_KEYCHAR Error = C.BAD_KEYCHAR BAD_ORDER Error = C.BAD_ORDER NOT_POS_INT Error = C.NOT_POS_INT NO_END Error = C.NO_END BAD_BITPIX Error = C.BAD_BITPIX BAD_NAXIS Error = C.BAD_NAXIS BAD_NAXES Error = C.BAD_NAXES BAD_PCOUNT Error = C.BAD_PCOUNT BAD_GCOUNT Error = C.BAD_GCOUNT BAD_TFIELDS Error = C.BAD_TFIELDS NEG_WIDTH Error = C.NEG_WIDTH NEG_ROWS Error = C.NEG_ROWS COL_NOT_FOUND Error = C.COL_NOT_FOUND BAD_SIMPLE Error = C.BAD_SIMPLE NO_SIMPLE Error = C.NO_SIMPLE NO_BITPIX Error = C.NO_BITPIX NO_NAXIS Error = C.NO_NAXIS NO_NAXES Error = C.NO_NAXES NO_XTENSION Error = C.NO_XTENSION NOT_ATABLE Error = C.NOT_ATABLE NOT_BTABLE Error = C.NOT_BTABLE NO_PCOUNT Error = C.NO_PCOUNT NO_GCOUNT Error = C.NO_GCOUNT NO_TFIELDS Error = C.NO_TFIELDS NO_TBCOL Error = C.NO_TBCOL NO_TFORM Error = C.NO_TFORM NOT_IMAGE Error = C.NOT_IMAGE BAD_TBCOL Error = C.BAD_TBCOL NOT_TABLE Error = C.NOT_TABLE COL_TOO_WIDE Error = C.COL_TOO_WIDE COL_NOT_UNIQUE Error = C.COL_NOT_UNIQUE BAD_ROW_WIDTH Error = C.BAD_ROW_WIDTH UNKNOWN_EXT Error = C.UNKNOWN_EXT UNKNOWN_REC Error = C.UNKNOWN_REC END_JUNK Error = C.END_JUNK BAD_HEADER_FILL Error = C.BAD_HEADER_FILL BAD_DATA_FILL Error = C.BAD_DATA_FILL BAD_TFORM Error = C.BAD_TFORM BAD_TFORM_DTYPE Error = C.BAD_TFORM_DTYPE BAD_TDIM Error = C.BAD_TDIM BAD_HEAP_PTR Error = C.BAD_HEAP_PTR BAD_HDU_NUM Error = C.BAD_HDU_NUM BAD_COL_NUM Error = C.BAD_COL_NUM NEG_FILE_POS Error = C.NEG_FILE_POS NEG_BYTES Error = C.NEG_BYTES BAD_ROW_NUM Error = C.BAD_ROW_NUM BAD_ELEM_NUM Error = C.BAD_ELEM_NUM NOT_ASCII_COL Error = C.NOT_ASCII_COL NOT_LOGICAL_COL Error = C.NOT_LOGICAL_COL BAD_ATABLE_FORMAT Error = C.BAD_ATABLE_FORMAT BAD_BTABLE_FORMAT Error = C.BAD_BTABLE_FORMAT NO_NULL Error = C.NO_NULL NOT_VARI_LEN Error = C.NOT_VARI_LEN BAD_DIMEN Error = C.BAD_DIMEN BAD_PIX_NUM Error = C.BAD_PIX_NUM ZERO_SCALE Error = C.ZERO_SCALE NEG_AXIS Error = C.NEG_AXIS NOT_GROUP_TABLE Error = C.NOT_GROUP_TABLE HDU_ALREADY_MEMBER Error = C.HDU_ALREADY_MEMBER MEMBER_NOT_FOUND Error = C.MEMBER_NOT_FOUND GROUP_NOT_FOUND Error = C.GROUP_NOT_FOUND BAD_GROUP_ID Error = C.BAD_GROUP_ID TOO_MANY_HDUS_TRACKED Error = C.TOO_MANY_HDUS_TRACKED HDU_ALREADY_TRACKED Error = C.HDU_ALREADY_TRACKED BAD_OPTION Error = C.BAD_OPTION IDENTICAL_POINTERS Error = C.IDENTICAL_POINTERS BAD_GROUP_ATTACH Error = C.BAD_GROUP_ATTACH BAD_GROUP_DETACH Error = C.BAD_GROUP_DETACH BAD_I2C Error = C.BAD_I2C BAD_F2C Error = C.BAD_F2C BAD_INTKEY Error = C.BAD_INTKEY BAD_LOGICALKEY Error = C.BAD_LOGICALKEY BAD_FLOATKEY Error = C.BAD_FLOATKEY BAD_DOUBLEKEY Error = C.BAD_DOUBLEKEY BAD_C2I Error = C.BAD_C2I BAD_C2F Error = C.BAD_C2F BAD_C2D Error = C.BAD_C2D BAD_DATATYPE Error = C.BAD_DATATYPE BAD_DECIM Error = C.BAD_DECIM NUM_OVERFLOW Error = C.NUM_OVERFLOW DATA_COMPRESSION_ERR Error = C.DATA_COMPRESSION_ERR DATA_DECOMPRESSION_ERR Error = C.DATA_DECOMPRESSION_ERR NO_COMPRESSED_TILE Error = C.NO_COMPRESSED_TILE BAD_DATE Error = C.BAD_DATE PARSE_SYNTAX_ERR Error = C.PARSE_SYNTAX_ERR PARSE_BAD_TYPE Error = C.PARSE_BAD_TYPE PARSE_LRG_VECTOR Error = C.PARSE_LRG_VECTOR PARSE_NO_OUTPUT Error = C.PARSE_NO_OUTPUT PARSE_BAD_COL Error = C.PARSE_BAD_COL PARSE_BAD_OUTPUT Error = C.PARSE_BAD_OUTPUT ANGLE_TOO_BIG Error = C.ANGLE_TOO_BIG BAD_WCS_VAL Error = C.BAD_WCS_VAL WCS_ERROR Error = C.WCS_ERROR BAD_WCS_PROJ Error = C.BAD_WCS_PROJ NO_WCS_KEY Error = C.NO_WCS_KEY APPROX_WCS_KEY Error = C.APPROX_WCS_KEY NO_CLOSE_ERROR Error = C.NO_CLOSE_ERROR /*------- following error codes are used in the grparser.c file -----------*/ NGP_ERRBASE Error = C.NGP_ERRBASE NGP_OK Error = C.NGP_OK NGP_NO_MEMORY Error = C.NGP_NO_MEMORY NGP_READ_ERR Error = C.NGP_READ_ERR NGP_NUL_PTR Error = C.NGP_NUL_PTR NGP_EMPTY_CURLINE Error = C.NGP_EMPTY_CURLINE NGP_UNREAD_QUEUE_FULL Error = C.NGP_UNREAD_QUEUE_FULL NGP_INC_NESTING Error = C.NGP_INC_NESTING NGP_ERR_FOPEN Error = C.NGP_ERR_FOPEN NGP_EOF Error = C.NGP_EOF NGP_BAD_ARG Error = C.NGP_BAD_ARG NGP_TOKEN_NOT_EXPECT Error = C.NGP_TOKEN_NOT_EXPECT )
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a handle to a FITS file
func Open ¶
Open an existing FITS file Open will create HDU values, loading the Header part but leaving the Data part on disk.
func (*File) Copy ¶
Copy all or part of the HDUs in the FITS file associated with infptr and append them to the end of the FITS file associated with outfptr. If 'previous' is true, then any HDUs preceding the current HDU in the input file will be copied to the output file. Similarly, 'current' and 'following' determine whether the current HDU, and/or any following HDUs in the input file will be copied to the output file. Thus, if all 3 parameters are true, then the entire input file will be copied. On exit, the current HDU in the input file will be unchanged, and the last HDU in the output file will be the current HDU.
func (*File) HDUNum ¶
HDUNum returns the number of the current HDU (CHDU) in the FITS file (where the primary array = 1). This function returns the HDU number rather than a status value. Note: 0-based index
func (*File) HDUType ¶
HDUType returns the type of the current HDU in the FITS file. The possible values for hdutype are: IMAGE_HDU, ASCII_TBL, or BINARY_TBL.
func (*File) NumHDUs ¶
NumHDUs returns the total number of HDUs in the FITS file. This returns the number of completely defined HDUs in the file. If a new HDU has just been added to the FITS file, then that last HDU will only be counted if it has been closed, or if data has been written to the HDU. The current HDU remains unchanged by this routine.
func (*File) SeekHDU ¶
SeekHDU moves to a different HDU in the file, according to whence: 0 means relative to origin of the file, 1 means relative to current position.
func (*File) SeekHDUByName ¶
SeekHDUByName moves to a different HDU in the file
type HDU ¶
type HDU interface { Close() error Header() Header Type() HDUType Name() string Version() int Data(data interface{}) error }
HDU represents a "Header-Data Unit" block
type HDUType ¶
type HDUType int
HDUType is the type of a "Header-Data Unit" (IMAGE_HDU, ASCII_TBL or BINARY_TBL)
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
func NewDefaultHeader ¶
func NewDefaultHeader() Header
NewDefaultHeader creates a Header with CFITSIO default Cards, of type IMAGE_HDU and bitpix=8, no axes.
func (*Header) AddComment ¶
func (*Header) AddHistory ¶
type ImageHDU ¶
type ImageHDU struct {
// contains filtered or unexported fields
}
ImageHDU is a Header-Data-Unit extension holding an image as data payload.
func (*ImageHDU) Close ¶
Close closes this HDU, cleaning up cycles for the proper garbage collection.
func (*ImageHDU) Data ¶
Data loads the image data associated with this HDU into data, which should be a pointer to a slice []T. cfitsio will return an error if the image payload can not be converted into Ts. It panics if data isn't addressable.
type PrimaryHDU ¶
type PrimaryHDU struct {
ImageHDU
}
PrimaryHDU is the primary HDU
func (*PrimaryHDU) Name ¶
func (hdu *PrimaryHDU) Name() string
Name returns the value of the 'EXTNAME' Card (or "PRIMARY" if none)
func (*PrimaryHDU) Version ¶
func (hdu *PrimaryHDU) Version() int
Version returns the value of the 'EXTVER' Card (or 1 if none)
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is the result of a query on a FITS Table. Its cursors starts before the first row of the result set. Use Next to advance through the rows:
rows, err := table.Read(0, -1) ... for rows.Next() { var id int var x float64 err = rows.Scan(&id, &x) ... } err = rows.Err() // get any error encountered during iteration ...
func (*Rows) Close ¶
Close closes the Rows, preventing further enumeration. Close is idempotent and does not affect the result of Err.
func (*Rows) Err ¶
Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func NewTableFrom ¶
NewTableFrom creates a new table in the given FITS file, using the struct v as schema
func (*Table) Read ¶
Read reads rows over the range [beg, end) and returns the corresponding iterator. if end > maxrows, the iteration will stop at maxrows ReadRange has the same semantics than a `for i=0; i < max; i++ {...}` loop
type TypeCode ¶
type TypeCode int
const ( TBIT TypeCode = C.TBIT /* codes for FITS table data types */ TBYTE TypeCode = C.TBYTE TSBYTE TypeCode = C.TSBYTE TLOGICAL TypeCode = C.TLOGICAL TSTRING TypeCode = C.TSTRING TUSHORT TypeCode = C.TUSHORT TSHORT TypeCode = C.TSHORT TUINT TypeCode = C.TUINT TINT TypeCode = C.TINT TULONG TypeCode = C.TULONG TLONG TypeCode = C.TLONG TINT32BIT TypeCode = C.TINT32BIT /* used when returning datatype of a column */ TFLOAT TypeCode = C.TFLOAT TLONGLONG TypeCode = C.TLONGLONG TDOUBLE TypeCode = C.TDOUBLE TCOMPLEX TypeCode = C.TCOMPLEX TDBLCOMPLEX TypeCode = C.TDBLCOMPLEX // variable length arrays TVLABIT TypeCode = -C.TBIT /* codes for FITS table data types */ TVLABYTE TypeCode = -C.TBYTE TVLASBYTE TypeCode = -C.TSBYTE TVLALOGICAL TypeCode = -C.TLOGICAL TVLASTRING TypeCode = -C.TSTRING TVLAUSHORT TypeCode = -C.TUSHORT TVLASHORT TypeCode = -C.TSHORT TVLAUINT TypeCode = -C.TUINT TVLAINT TypeCode = -C.TINT TVLAULONG TypeCode = -C.TULONG TVLALONG TypeCode = -C.TLONG TVLAINT32BIT TypeCode = -C.TINT32BIT /* used when returning datatype of a column */ TVLAFLOAT TypeCode = -C.TFLOAT TVLALONGLONG TypeCode = -C.TLONGLONG TVLADOUBLE TypeCode = -C.TDOUBLE TVLACOMPLEX TypeCode = -C.TCOMPLEX TVLADBLCOMPLEX TypeCode = -C.TDBLCOMPLEX )