fits

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fits reads the images in FITS files as the FITS Standard 4.0 describes them, and refuses the rest. It reads a header's cards and an image's pixels a row at a time. It reads where the image lies on the sky.

The image is the primary array or an `IMAGE` extension. Its pixels are any of the six types the standard allows. They are scaled by `BSCALE` and `BZERO`, and `BLANK` is read as no value.

Where it lies on the sky is read from the world coordinate cards. The projections read are TAN and CAR, in equatorial or galactic coordinates.

Anything else is refused, and each refusal says why in words.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Refused

func Refused() error

Refused is wrapped by each error about a file this package does not read: a part of the standard it does not read, or a file that breaks the standard.

Types

type Frame

type Frame string

Frame is the coordinates an image's axes are in.

const (
	// Equatorial is right ascension and declination, ICRS. FK5 at the
	// J2000 equinox is read as ICRS: the two differ by tens of
	// milliarcseconds, far below any pixel here.
	Equatorial Frame = "equatorial"
	// Galactic is galactic longitude and latitude.
	Galactic Frame = "galactic"
)

The frames an image may be in.

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

Header is a header's cards by keyword. Each value is kept as its card writes it, with its comment taken off.

func ReadHeader

func ReadHeader(from io.Reader) (*Header, error)

ReadHeader is the header at the front of a reader, read a block at a time to its END card. Headers that end before their END card are refused.

func (*Header) Has

func (read *Header) Has(key string) bool

Has is whether the header has a card for a keyword.

func (*Header) Number

func (read *Header) Number(key string) (float64, error)

Number is a keyword's value as a number. Some writers put a D in the exponent, and it is read as E.

func (*Header) Text

func (read *Header) Text(key string) (string, error)

Text is a keyword's string value with its quotes taken off. Doubled quotes are read as one. The spaces after the value are dropped.

type Image

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

Image is a two-dimensional image in a FITS file. Its rows are read as they are asked for.

func Open

func Open(file io.ReaderAt) (*Image, error)

Open is the first two-dimensional image in a file: the primary array or an IMAGE extension. HDUs that hold no image are stepped over. Tables and empty primaries are such. Files with no image are refused.

func (*Image) Header

func (image *Image) Header() *Header

Header is the image's header.

func (*Image) Height

func (image *Image) Height() int

Height is the image's rows.

func (*Image) Row

func (image *Image) Row(y int) ([]float64, error)

Row is the values of one row. The first row is the bottom one, as the standard counts them. Each is BZERO more than BSCALE times the stored value. Stored BLANKs are NaN, and so are floats that are not a number.

func (*Image) Sky

func (image *Image) Sky() (*Sky, error)

Sky is where the image's pixels lie on the sky.

func (*Image) Width

func (image *Image) Width() int

Width is the image's pixels a row.

type Sky

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

Sky is where an image's pixels lie on the sky: a projection about a reference point, and the matrix that turns pixels into degrees.

func SkyOf

func SkyOf(header *Header) (*Sky, error)

SkyOf is where a header says its image lies on the sky. It refuses a projection or a frame it does not read, and axes not in degrees.

It refuses a CAR grid not about the equator and a pole moved from where the projection puts it. It refuses an equinox other than J2000 and a pixel matrix with no inverse.

func (*Sky) Frame

func (read *Sky) Frame() Frame

Frame is the coordinates the image's axes are in.

func (*Sky) Pixel

func (read *Sky) Pixel(lon, lat float64) (x, y float64, seen bool)

Pixel is the pixel at a longitude and latitude, in degrees in the image's frame. seen is false for a place a tangent projection cannot show: on the far half of the sky from its centre.

func (*Sky) Place

func (read *Sky) Place(x, y float64) (lon, lat float64)

Place is the longitude and latitude at a pixel, in degrees in the image's frame. Pixels are counted as the standard counts them: the centre of the first is at one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL