fitsio: github.com/astrogo/fitsio Index | Files | Directories

package fitsio

import "github.com/astrogo/fitsio"

fitsio provides read and write access to FITS files.

Index

Package Files

binary.go card.go column.go consts.go decode.go doc.go encode.go file.go hdu.go header.go image.go phdu.go reader.go rows.go table.go type.go utils.go

Constants

const (
    ReadOnly  Mode = Mode(os.O_RDONLY) // open the file read-only
    WriteOnly      = Mode(os.O_WRONLY) // open the file write-only
    ReadWrite      = Mode(os.O_RDWR)   // open the file read-write
)

func CopyHDU Uses

func CopyHDU(dst, src *File, i int) error

CopyHDU copies the i-th HDU from the src FITS file into the dst one.

func CopyTable Uses

func CopyTable(dst, src *Table) error

CopyTable copies all the rows from src into dst.

func CopyTableRange Uses

func CopyTableRange(dst, src *Table, beg, end int64) error

CopyTableRange copies the rows interval [beg,end) from src into dst

func NewImage Uses

func NewImage(bitpix int, axes []int) *imageHDU

NewImage creates a new Image with bitpix size for the pixels and axes as its axes

type Card Uses

type Card struct {
    Name    string
    Value   Value
    Comment string
}

Card is a record block in a Header

type Column Uses

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
    // contains filtered or unexported fields
}

Column represents a column in a FITS table

func NewColumn Uses

func NewColumn(name string, v interface{}) (Column, error)

NewColumn creates a new Column with name `name` and Format inferred from the type of value

func (*Column) Type Uses

func (col *Column) Type() reflect.Type

Type returns the Go reflect.Type associated with this Column

type Decoder Uses

type Decoder interface {
    DecodeHDU() (HDU, error)
}

func NewDecoder Uses

func NewDecoder(r io.Reader) Decoder

NewDecoder creates a new Decoder according to the capabilities of the underlying io.Reader

type Encoder Uses

type Encoder interface {
    EncodeHDU(hdu HDU) error
}

func NewEncoder Uses

func NewEncoder(w io.Writer) Encoder

NewEncoder creates a new Encoder according to the capabilities of the underlying io.Writer

type File Uses

type File struct {
    // contains filtered or unexported fields
}

File represents a FITS file.

func Create Uses

func Create(w io.Writer) (*File, error)

Create creates a new FITS file in write-only mode

func Open Uses

func Open(r io.Reader) (*File, error)

Open opens a FITS file in read-only mode.

func (*File) Close Uses

func (f *File) Close() error

Close releases resources held by a FITS file.

It does not close the underlying io.Reader or io.Writer.

func (*File) Get Uses

func (f *File) Get(name string) HDU

Get returns the HDU with name `name` or nil

func (*File) HDU Uses

func (f *File) HDU(i int) HDU

HDU returns the i-th HDU

func (*File) HDUs Uses

func (f *File) HDUs() []HDU

HDUs returns the list of all Header-Data Unit blocks in the file

func (*File) Has Uses

func (f *File) Has(name string) bool

Has returns whether the File has a HDU with name `name`.

func (*File) Mode Uses

func (f *File) Mode() Mode

Mode returns the access-mode of this FITS file

func (*File) Name Uses

func (f *File) Name() string

Name returns the name of the FITS file

func (*File) Write Uses

func (f *File) Write(hdu HDU) error

Write writes a HDU to file

type HDU Uses

type HDU interface {
    Close() error
    Type() HDUType
    Name() string
    Version() int
    Header() *Header
}

HDU is a "Header-Data Unit" block

type HDUType Uses

type HDUType int

HDUType is the type of a Header-Data Unit

const (
    IMAGE_HDU  HDUType = iota // Primary Array or IMAGE HDU
    ASCII_TBL                 // ASCII table HDU
    BINARY_TBL                // Binary table HDU
    ANY_HDU                   // matches any HDU type
)

func (HDUType) String Uses

func (htype HDUType) String() string
type Header struct {
    // contains filtered or unexported fields
}

Header describes a Header-Data Unit of a FITS file

func NewDefaultHeader Uses

func NewDefaultHeader() *Header

NewDefaultHeader creates a Header with CFITSIO default Cards, of type IMAGE_HDU and bitpix=8, no axes.

func NewHeader Uses

func NewHeader(cards []Card, htype HDUType, bitpix int, axes []int) *Header

NewHeader creates a new Header from a set of Cards, HDU Type, bitpix and axes.

func (*Header) Append Uses

func (hdr *Header) Append(cards ...Card) error

Append appends a set of Cards to this Header

func (*Header) Axes Uses

func (hdr *Header) Axes() []int

Axes returns the axes for this Header.

func (*Header) Bitpix Uses

func (hdr *Header) Bitpix() int

Bitpix returns the bitpix value.

func (*Header) Card Uses

func (hdr *Header) Card(i int) *Card

Card returns the i-th card. Card panics if the index is out of range.

func (*Header) Clear Uses

func (hdr *Header) Clear()

Clear resets the Header to the default state.

func (*Header) Comment Uses

func (hdr *Header) Comment() string

Comment returns the whole comment string for this Header.

func (*Header) Get Uses

func (hdr *Header) Get(n string) *Card

Get returns the Card with name n or nil if it doesn't exist. If multiple cards with the same name exist, the first one is returned.

func (*Header) History Uses

func (hdr *Header) History() string

History returns the whole history string for this Header.

func (*Header) Index Uses

func (hdr *Header) Index(n string) int

Index returns the index of the Card with name n, or -1 if it doesn't exist

func (*Header) Keys Uses

func (hdr *Header) Keys() []string

Keys returns the name of all the Cards of this Header.

func (*Header) Set Uses

func (hdr *Header) Set(n string, v interface{}, comment string)

Set modifies the value and comment of a Card with name n.

func (*Header) Text Uses

func (hdr *Header) Text() string

Text returns the header's cards content as 80-byte lines

func (*Header) Type Uses

func (hdr *Header) Type() HDUType

Type returns the Type of this Header

type Image Uses

type Image interface {
    HDU
    Read(ptr interface{}) error
    Write(ptr interface{}) error
    Raw() []byte
    Image() image.Image
    // contains filtered or unexported methods
}

Image represents a FITS image

func NewPrimaryHDU Uses

func NewPrimaryHDU(hdr *Header) (Image, error)

NewPrimaryHDU creates a new PrimaryHDU with Header hdr. If hdr is nil, a default Header will be created.

type Mode Uses

type Mode int

Mode defines a FITS file access mode (r/w)

type Reader Uses

type Reader struct {
    // contains filtered or unexported fields
}

func NewReader Uses

func NewReader(r io.Reader) *Reader

type Rows Uses

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 Uses

func (rows *Rows) Close() error

Close closes the Rows, preventing further enumeration. Close is idempotent and does not affect the result of Err.

func (*Rows) Err Uses

func (rows *Rows) Err() error

Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.

func (*Rows) Next Uses

func (rows *Rows) Next() bool

Next prepares the next result row for reading with the Scan method. It returns true on success, false if there is no next result row. Every call to Scan, even the first one, must be preceded by a call to Next.

func (*Rows) Scan Uses

func (rows *Rows) Scan(args ...interface{}) error

Scan copies the columns in the current row into the values pointed at by dest.

type Table Uses

type Table struct {
    // contains filtered or unexported fields
}

func NewTable Uses

func NewTable(name string, cols []Column, hdutype HDUType) (*Table, error)

NewTable creates a new table in the given FITS file

func NewTableFrom Uses

func NewTableFrom(name string, v Value, hdutype HDUType) (*Table, error)

NewTableFrom creates a new table in the given FITS file, using the struct v as schema

func (*Table) Close Uses

func (t *Table) Close() error

Close closes this HDU, cleaning up cycles (if any) for garbage collection

func (*Table) Col Uses

func (t *Table) Col(i int) *Column

func (*Table) Cols Uses

func (t *Table) Cols() []Column

func (*Table) Data Uses

func (t *Table) Data() (Value, error)

Data returns the image payload

func (*Table) Header Uses

func (t *Table) Header() *Header

Header returns the Header part of this HDU block.

func (*Table) Index Uses

func (t *Table) Index(n string) int

Index returns the index of the first column with name `n` or -1

func (*Table) Name Uses

func (t *Table) Name() string

Name returns the value of the 'EXTNAME' Card.

func (*Table) NumCols Uses

func (t *Table) NumCols() int

func (*Table) NumRows Uses

func (t *Table) NumRows() int64

func (*Table) Read Uses

func (t *Table) Read(beg, end int64) (*Rows, error)

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

func (*Table) ReadRange Uses

func (t *Table) ReadRange(beg, end, inc int64) (*Rows, error)

ReadRange 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+=inc {...}` loop

func (*Table) Type Uses

func (t *Table) Type() HDUType

Type returns the Type of this HDU

func (*Table) Version Uses

func (t *Table) Version() int

Version returns the value of the 'EXTVER' Card (or 1 if none)

func (*Table) Write Uses

func (t *Table) Write(args ...interface{}) error

Write writes the data into the columns at the current row.

type Type Uses

type Type struct {
    // contains filtered or unexported fields
}

Type describes a FITS type and its associated Go type

type Value Uses

type Value interface{}

Directories

PathSynopsis
cmd/go-fitsio-fitscopy
cmd/go-fitsio-listhead
cmd/go-fitsio-mergefiles
cmd/go-fitsio-tablist
cmd/view-fitsview-fits is a simple program to display images in a FITS file.
fltimgfltimg provides image.Image implementations for the float32- and float64-image encodings of FITS.

Package fitsio imports 13 packages (graph) and is imported by 9 packages. Updated 2018-11-26. Refresh now. Tools for package owners.