Skip to main content

Header

Struct Header 

Source
pub struct Header { /* private fields */ }
Expand description

Ordered list of header cards, without the END card or fill.

Implementations§

Source§

impl Header

Source

pub fn is_compressed_image(&self) -> bool

True when this HDU is a tiled compressed image (ZIMAGE = T).

Source

pub fn zimage_info(&self, nrows: i64) -> Result<ZImageInfo>

Parse ZIMAGE keywords. nrows is NAXIS2 of the binary table.

Source§

impl Header

Source

pub fn new() -> Self

Empty header (no cards yet).

Source

pub fn from_cards(cards: Vec<Card>) -> Self

Header from an ordered list of cards (no END).

Source

pub fn is_primary(&self) -> bool

True if this header is a primary array (SIMPLE present).

Source

pub fn empty_primary() -> Result<Self>

CFITSIO empty primary: SIMPLE/BITPIX=8/NAXIS=0/EXTEND plus COMMENTs.

Source

pub fn len(&self) -> usize

Number of keyword cards (not counting END or fill).

Source

pub fn is_empty(&self) -> bool

True if no cards have been written.

Source

pub fn push(&mut self, card: Card)

Append a fully formatted card.

Source

pub fn replace_record_idx(&mut self, idx: usize, card: Card) -> Result<()>

Replace 0-based card idx.

Source

pub fn cards(&self) -> &[Card]

Cards in order.

Source

pub fn write_logical( &mut self, name: &str, value: bool, comm: Option<&str>, ) -> Result<()>

fits_write_key_log / ffpkyl.

Source

pub fn write_long( &mut self, name: &str, value: i64, comm: Option<&str>, ) -> Result<()>

fits_write_key_lng / ffpkyj.

Source

pub fn write_string( &mut self, name: &str, value: &str, comm: Option<&str>, ) -> Result<()>

fits_write_key_str / ffpkys.

Source

pub fn write_fixed_double( &mut self, name: &str, value: f64, decim: usize, comm: Option<&str>, ) -> Result<()>

fits_write_key_fixdbl / ffpkyg.

Source

pub fn primary_image(ty: ImageType, naxes: &[i64]) -> Result<Self>

Required keywords for a primary image (ffphps / ffcrim on HDU 0).

Source

pub fn image_extension(ty: ImageType, naxes: &[i64]) -> Result<Self>

Required keywords for an IMAGE extension (ffphpr when not HDU 0).

Source

pub fn ascii_table( nrows: i64, ttype: &[&str], tform: &[&str], tunit: &[Option<&str>], extname: Option<&str>, ) -> Result<Self>

Required keywords for an ASCII table extension (ffphtb).

TBCOL values and NAXIS1 are computed with one blank between columns (ffgabc with space = 1).

Source

pub fn ascii_table_info(&self) -> Result<AsciiTableInfo>

ASCII-table required keywords (fits_read_atblhdr / ffghtb).

Source

pub fn binary_table( nrows: i64, ttype: &[&str], tform: &[&str], tunit: &[Option<&str>], extname: Option<&str>, ) -> Result<Self>

Required keywords for a binary table extension (ffphbn).

Source

pub fn binary_table_info(&self) -> Result<BinaryTableInfo>

Binary-table required keywords (fits_read_btblhdr / ffghbn).

Source

pub fn update_long_keep_comment(&mut self, name: &str, value: i64) -> Result<()>

Replace a long keyword, keeping its existing comment (ffmkyj with "&").

Source

pub fn shift_table_col_keys( &mut self, colmin: i32, colmax: i32, incre: i32, ) -> Result<()>

Shift Txxxn keyword indices (ffkshf). Starts at the 9th card.

If incre <= 0, keywords with index colmin are deleted.

Source

pub fn card_by_name(&self, name: &str) -> Option<&Card>

First card whose 8-character name matches name (case-insensitive).

Source

pub fn get_i64(&self, name: &str) -> Result<i64>

Integer keyword value (fits_read_key_lng).

Source

pub fn get_f64(&self, name: &str) -> Result<f64>

Floating keyword value (fits_read_key_dbl).

Source

pub fn naxes(&self) -> Result<Vec<i64>>

NAXIS axis lengths.

Source

pub fn bitpix(&self) -> Result<i32>

Stored BITPIX.

Source

pub fn bscale(&self) -> f64

BSCALE, default 1.0.

Source

pub fn bzero(&self) -> f64

BZERO, default 0.0. ULONGLONG’s integer BZERO is returned as f64.

Source

pub fn blank(&self) -> Option<i64>

BLANK keyword if present.

Source

pub fn set_blank(&mut self, value: i64) -> Result<()>

Replace or append a BLANK keyword.

Source

pub fn upsert_long( &mut self, name: &str, value: i64, comm: Option<&str>, ) -> Result<()>

Replace the first card of this name, or append.

Source

pub fn write_float_exp( &mut self, name: &str, value: f64, decim: usize, comm: Option<&str>, ) -> Result<()>

fits_write_key_flt / ffpkye (exponential).

Source

pub fn write_null(&mut self, name: &str, comm: Option<&str>) -> Result<()>

fits_write_key_null / ffpkyu.

Source

pub fn write_comment(&mut self, comm: &str)

fits_write_comment / ffpcom.

Source

pub fn write_history(&mut self, hist: &str)

fits_write_history / ffphis.

Source

pub fn write_record(&mut self, card: &str)

fits_write_record / ffprec.

Source

pub fn write_complex_exp( &mut self, name: &str, real: f64, imag: f64, decim: usize, comm: Option<&str>, ) -> Result<()>

Complex exponential (ffpkyc / ffpkym).

Source

pub fn write_complex_fixed( &mut self, name: &str, real: f64, imag: f64, decim: usize, comm: Option<&str>, ) -> Result<()>

Complex fixed (ffpkfc / ffpkfm).

Source

pub fn write_ulong( &mut self, name: &str, value: u64, comm: Option<&str>, ) -> Result<()>

Unsigned 64-bit integer keyword.

Source

pub fn record(&self, n: usize) -> Result<Card>

1-based keyword record (fits_read_record). Does not include END.

Source

pub fn get_string(&self, name: &str) -> Result<(String, String)>

Unquoted string value (fits_read_key_str).

Source

pub fn get_logical(&self, name: &str) -> Result<(bool, String)>

Logical value (fits_read_key_log).

Source

pub fn raw_value_comment(&self, name: &str) -> Result<(String, String)>

Raw value + comment strings (fits_read_keyword).

Source

pub fn get_unit(&self, name: &str) -> Result<String>

Units from [...] in the comment (fits_read_key_unit).

Source

pub fn set_unit(&mut self, name: &str, unit: &str) -> Result<()>

Prepend [unit] to the comment (fits_write_key_unit).

Source

pub fn update_with( &mut self, name: &str, value: &str, comm: Option<&str>, ) -> Result<()>

Update: replace if present, otherwise append (fits_update_key).

Source

pub fn modify_with( &mut self, name: &str, value: &str, comm: Option<&str>, ) -> Result<()>

Modify an existing keyword; error if missing (fits_modify_key).

Source

pub fn insert_record_at(&mut self, pos: usize, card: Card) -> Result<()>

Insert card at 1-based pos (before that record). pos > nkeys appends.

Source

pub fn delete_key(&mut self, name: &str) -> Result<()>

Delete first keyword with this name (fits_delete_key).

Source

pub fn delete_record(&mut self, n: usize) -> Result<()>

Delete 1-based record (fits_delete_record).

Source

pub fn replace_name(&mut self, name: &str, card: Card) -> Result<()>

Replace first matching name.

Source

pub fn write_date_value(&mut self, datetime: &str) -> Result<()>

Write DATE with the given timestamp value (fits_write_date body).

Source

pub fn write_keys_long( &mut self, root: &str, start: i32, values: &[i64], comms: &[Option<&str>], ) -> Result<()>

fits_write_keys_lng: KEY1, KEY2, … from start.

Source

pub fn get_keys_long( &self, root: &str, start: i32, nmax: usize, ) -> (Vec<i64>, usize)

Read KEY{start}.. as integers. Returns how many were found.

Source

pub fn primary_info(&self) -> Result<PrimaryInfo>

Primary-array required keywords (fits_read_imghdr / ffghpr).

Source

pub fn image_type(&self) -> Result<ImageType>

Infer ImageType from BITPIX + BZERO.

Source

pub fn to_record_bytes(&self) -> Vec<u8> ⓘ

Serialize cards + END + space fill to a multiple of 2880 bytes.

Source

pub fn to_record_bytes_with_morekeys(&self, morekeys: i32) -> Vec<u8> ⓘ

Like Self::to_record_bytes, reserving morekeys extra 80-byte slots after END (fits_write_hdu_space / ffhdef).

Source

pub fn nmore_in(&self, header_len: u64) -> i32

Remaining keyword slots in an on-disk header of header_len bytes (ffghsp nmore, not counting END).

Source

pub fn primary_as_image_extension(&self) -> Result<Self>

Convert a primary-array header into an IMAGE extension (ffcphd).

Source

pub fn image_extension_as_primary(&self) -> Result<Self>

Convert an IMAGE extension header into a primary array (ffcphd).

Source

pub fn parse(bytes: &[u8]) -> Result<(Self, u64)>

Parse a header from the start of a FITS file image.

Reads 80-byte cards until END. Returns the header and the byte offset of the following data unit (a multiple of 2880).

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Header

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Header

Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.