Table of Contents

Class FitsHeader

Namespace
FitsModel
Assembly
FitsModel.dll

A series of keyword records organized within one or more header blocks that describes structures and/or data that follow it in the FITS file.

public class FitsHeader
Inheritance
FitsHeader
Inherited Members

Constructors

FitsHeader()

Creates an empty Primary Header

public FitsHeader()

FitsHeader(BitPix, int, IEnumerable<int>?)

Creates a new instance of FitsHeader with the specified bitPix.

public FitsHeader(BitPix bitPix, int nAxis = 0, IEnumerable<int>? axisSizes = null)

Parameters

bitPix BitPix

Number of bits per pixel

nAxis int

Number of data axis

axisSizes IEnumerable<int>

Number of pixels per axis

Exceptions

ArgumentNullException

Thrown if naxis > 0 but no axis sizes supplied

ArgumentException

Thrown if the number of axis sizes does not match the number of axis

ArgumentOutOfRangeException

Thrown if any of the axis sizes are negative

FitsHeader(BitPix, int, int)

Creates a header of the specified bitPix, width and height with an empty data array.

public FitsHeader(BitPix bitPix, int width, int height)

Parameters

bitPix BitPix
width int
height int

FitsHeader(IEnumerable<FitsHeaderEntry>)

Create a new instance of FitsHeader from the specified entries.

public FitsHeader(IEnumerable<FitsHeaderEntry> entries)

Parameters

entries IEnumerable<FitsHeaderEntry>

Properties

AxisSizes

Number of pixels in each axis. The number of axis is given by NumberOfAxis.

public List<int> AxisSizes { get; set; }

Property Value

List<int>

BZero

See BZeroStr This keyword shall be used, along with the BSCALE keyword, to linearly scale the array pixel values(i.e., the actual values stored in the FITS file) to transform them into the physical values that they represent using Eq. 3. The value field shall contain a floating-point number representing the physical value corresponding to an array value of zero.The default value for this keyword is 0.0.

public long BZero { get; set; }

Property Value

long

BitsPerPixel

4.4.1.1. Primary header
The value field shall contain an integer. The absolute value is used in computing the sizes of data structures. It shall specify the number of bits that represent a data value in the associated data array. The only valid values of BITPIX are given here.

public BitPix BitsPerPixel { get; set; }

Property Value

BitPix

BytesPerPixel

The number of 8 bit bytes used to represent a value in the data.

public int BytesPerPixel { get; }

Property Value

int

HeaderEntries

Raw FitsHeaderEntrys that make up the header."

public List<FitsHeaderEntry> HeaderEntries { get; }

Property Value

List<FitsHeaderEntry>

Height

The height of the image in pixels. If the header does not represent an image, this will be 0.

public int Height { get; }

Property Value

int

IsImage

A header is considered an image if it has exactly two axes (i.e., a 2D array).

public bool IsImage { get; }

Property Value

bool

KeyValuePairs

Collection of key-value pairs parsed from the header entries for easy access.

public Dictionary<string, string?> KeyValuePairs { get; }

Property Value

Dictionary<string, string>

NumberOfAxis

The value field shall contain a non-negative integer no greater than 999 representing the number of axes in the associated data array.A value of zero signifies that no data follow the header in the HDU.

public int NumberOfAxis { get; set; }

Property Value

int

NumberOfDataBlocks

The number of 2880-byte data blocks needed to contain the primary data array.

public long NumberOfDataBlocks { get; }

Property Value

long

NumberOfDataBytes

Number of data bytes in the primary data array. Note, this includes any padding that may be needed to complete the last 2880-byte data block.

public long NumberOfDataBytes { get; }

Property Value

long

NumberOfHeaderBlocks

Each 2880-byte header block contains 36 keyword records. The last header block must contain the END keyword (defined in Sect. 4.4.1), which marks the logical end of the header. Keyword records without information (e.g., following the END keyword) shall be filled with ASCII spaces (decimal 32 or hexadecimal 20).

public long NumberOfHeaderBlocks { get; }

Property Value

long

NumberOfImageBytes

The number of bytes used to represent the image data. (Excludes any padding)

public long NumberOfImageBytes { get; }

Property Value

long

NumberOfPixelBytes

The total number of bits in the primary data array, exclusive of fill that is needed after the data to complete the last 2880-byte data block(Sect. 3.3.2), is given by the following expression: Nbits = |BITPIX| × (NAXIS1 × NAXIS2 × · · · × NAXISm), where Nbits must be non-negative and is the number of bits excluding fill, m is the value of NAXIS, and BITPIX and the NAXISn represent the values associated with those keywords

public long NumberOfPixelBytes { get; }

Property Value

long

NumberOfPixels

The number of pixels for the data array represented by this header.

public int NumberOfPixels { get; }

Property Value

int

Width

The width of the image in pixels. If the header does not represent an image, this will be 0.

public int Width { get; }

Property Value

int

Methods

CreateImageHeader(BitPix, int, int, List<string>?)

Creates a new image header with the specified bitPix, width and height.

public static FitsHeader CreateImageHeader(BitPix bitPix, int width, int height, List<string>? additionalEntries = null)

Parameters

bitPix BitPix
width int
height int
additionalEntries List<string>

Returns

FitsHeader

CreatePrimaryHeader(IEnumerable<FitsHeaderEntry>)

Creates a new default primary header with any additional additionalEntries added.

public static FitsHeader CreatePrimaryHeader(IEnumerable<FitsHeaderEntry> additionalEntries)

Parameters

additionalEntries IEnumerable<FitsHeaderEntry>

Any additional FitsHeaderEntries to add to the primary HDU.

Returns

FitsHeader

A new default primary header with any additional additionalEntries added.

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

PadBlockLength(long)

Calculates the number of bytes needed to pad a length of data to be a multiple of 2880

public static long PadBlockLength(long length)

Parameters

length long

Returns

long

The number of bytes needed to pad a data block

ToString()

public override string ToString()

Returns

string

ValidateExtensionHeader(FitsHeader)

Validates that the given header is a valid extension header.

public static void ValidateExtensionHeader(FitsHeader header)

Parameters

header FitsHeader

ValidatePrimaryHeader(FitsHeader)

Validates that the given header is a valid primary header.
The SIMPLE keyword is required to be the first keyword in the primary header of all FITS files.The primary header must contain the other mandatory keywords "Simple", "BitPix", "NAxis" in the order given. Other keywords must not intervene between the SIMPLE keyword and the last NAXISn keyword

public static void ValidatePrimaryHeader(FitsHeader header)

Parameters

header FitsHeader

Exceptions

ArgumentNullException

WriteToStream(Stream)

Writes the header entries to the specified stream

public Task WriteToStream(Stream stream)

Parameters

stream Stream

Returns

Task

WriteToStream(Stream, CancellationToken)

Writes the header entries to the specified stream until the cancellationToken is triggered.

public Task WriteToStream(Stream stream, CancellationToken cancellationToken)

Parameters

stream Stream
cancellationToken CancellationToken

Returns

Task