Class FitsFile
A whole FITS file, for the numbers rather than a picture: every HDU's header cards, and an image's physical values,
BZERO + BSCALE × stored, unstretched, with missing pixels (BLANK, NaN, damaged tiles, data past the file's end)
as NaN. Tile-compressed images decode as plain ones. World coordinate (WCS) keywords are in the header; Egami does no sky
coordinate math.
public sealed class FitsFile
- Inheritance
-
FitsFile
- Inherited Members
Examples
// FitsFile lists every HDU with its header, tables included, and reads an image's values in file order.
FitsFile file = FitsFile.Load("m51.fits");
foreach (FitsHdu hdu in file.Hdus)
{
Console.WriteLine($"HDU {hdu.Index}: {hdu.Kind}, {string.Join(" × ", hdu.Axes)}");
}
FitsHdu image = file.FirstImage!;
double exposure = image.Header.GetReal("EXPTIME") ?? 0;
double[] counts = file.ReadValues(image);
using Raster<GrayF32> plane = file.ReadPlane(image);
Properties
FirstImage
Gets the first HDU that holds an image, or null.
public FitsHdu? FirstImage { get; }
Property Value
Hdus
Gets every HDU, the primary one first.
public IReadOnlyList<FitsHdu> Hdus { get; }
Property Value
Methods
Load(Stream, EgamiContext?)
Reads a FITS file from a stream, to its end.
public static FitsFile Load(Stream stream, EgamiContext? context = null)
Parameters
streamStreamThe stream.
contextEgamiContextThe context whose safety limits apply, or null for the default.
Returns
- FitsFile
The file, its headers read.
Exceptions
- ArgumentNullException
streamis null.- CorruptDataException
The primary header is not FITS or is damaged.
Load(string, EgamiContext?)
Reads a FITS file from a path.
public static FitsFile Load(string path, EgamiContext? context = null)
Parameters
pathstringThe file.
contextEgamiContextThe context whose safety limits apply, or null for the default.
Returns
- FitsFile
The file, its headers read.
Exceptions
- ArgumentNullException
pathis null.- CorruptDataException
The primary header is not FITS or is damaged.
ReadPlane(FitsHdu, int)
Returns one plane of an image HDU as physical values in GrayF32, the file's first row at the bottom as Load gives
it.
public Raster<GrayF32> ReadPlane(FitsHdu hdu, int plane = 0)
Parameters
Returns
Exceptions
- ArgumentException
hduis not an image of this file.- ArgumentOutOfRangeException
planeis outside the cube.- UnsupportedFormatException
The image uses a tile compression Egami does not read.
ReadValues(FitsHdu)
Returns an image HDU's physical values, every plane, in the file's order: along a row first, then up the rows from the file's first, then plane by plane.
public double[] ReadValues(FitsHdu hdu)
Parameters
hduFitsHduAn image HDU of this file.
Returns
- double[]
The values.
Exceptions
- ArgumentException
hduis not an image of this file.- UnsupportedFormatException
The image uses a tile compression Egami does not read.