pub struct Header { /* private fields */ }Expand description
Ordered list of header cards, without the END card or fill.
Implementations§
Source§impl Header
impl Header
Sourcepub fn is_compressed_image(&self) -> bool
pub fn is_compressed_image(&self) -> bool
True when this HDU is a tiled compressed image (ZIMAGE = T).
Sourcepub fn zimage_info(&self, nrows: i64) -> Result<ZImageInfo>
pub fn zimage_info(&self, nrows: i64) -> Result<ZImageInfo>
Parse ZIMAGE keywords. nrows is NAXIS2 of the binary table.
Source§impl Header
impl Header
Sourcepub fn from_cards(cards: Vec<Card>) -> Self
pub fn from_cards(cards: Vec<Card>) -> Self
Header from an ordered list of cards (no END).
Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
True if this header is a primary array (SIMPLE present).
Sourcepub fn empty_primary() -> Result<Self>
pub fn empty_primary() -> Result<Self>
CFITSIO empty primary: SIMPLE/BITPIX=8/NAXIS=0/EXTEND plus COMMENTs.
Sourcepub fn replace_record_idx(&mut self, idx: usize, card: Card) -> Result<()>
pub fn replace_record_idx(&mut self, idx: usize, card: Card) -> Result<()>
Replace 0-based card idx.
Sourcepub fn write_logical(
&mut self,
name: &str,
value: bool,
comm: Option<&str>,
) -> Result<()>
pub fn write_logical( &mut self, name: &str, value: bool, comm: Option<&str>, ) -> Result<()>
fits_write_key_log / ffpkyl.
Sourcepub fn write_long(
&mut self,
name: &str,
value: i64,
comm: Option<&str>,
) -> Result<()>
pub fn write_long( &mut self, name: &str, value: i64, comm: Option<&str>, ) -> Result<()>
fits_write_key_lng / ffpkyj.
Sourcepub fn write_string(
&mut self,
name: &str,
value: &str,
comm: Option<&str>,
) -> Result<()>
pub fn write_string( &mut self, name: &str, value: &str, comm: Option<&str>, ) -> Result<()>
fits_write_key_str / ffpkys.
Sourcepub fn write_fixed_double(
&mut self,
name: &str,
value: f64,
decim: usize,
comm: Option<&str>,
) -> Result<()>
pub fn write_fixed_double( &mut self, name: &str, value: f64, decim: usize, comm: Option<&str>, ) -> Result<()>
fits_write_key_fixdbl / ffpkyg.
Sourcepub fn primary_image(ty: ImageType, naxes: &[i64]) -> Result<Self>
pub fn primary_image(ty: ImageType, naxes: &[i64]) -> Result<Self>
Required keywords for a primary image (ffphps / ffcrim on HDU 0).
Sourcepub fn image_extension(ty: ImageType, naxes: &[i64]) -> Result<Self>
pub fn image_extension(ty: ImageType, naxes: &[i64]) -> Result<Self>
Required keywords for an IMAGE extension (ffphpr when not HDU 0).
Sourcepub fn ascii_table(
nrows: i64,
ttype: &[&str],
tform: &[&str],
tunit: &[Option<&str>],
extname: Option<&str>,
) -> Result<Self>
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).
Sourcepub fn ascii_table_info(&self) -> Result<AsciiTableInfo>
pub fn ascii_table_info(&self) -> Result<AsciiTableInfo>
ASCII-table required keywords (fits_read_atblhdr / ffghtb).
Sourcepub fn binary_table(
nrows: i64,
ttype: &[&str],
tform: &[&str],
tunit: &[Option<&str>],
extname: Option<&str>,
) -> Result<Self>
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).
Sourcepub fn binary_table_info(&self) -> Result<BinaryTableInfo>
pub fn binary_table_info(&self) -> Result<BinaryTableInfo>
Binary-table required keywords (fits_read_btblhdr / ffghbn).
Sourcepub fn update_long_keep_comment(&mut self, name: &str, value: i64) -> Result<()>
pub fn update_long_keep_comment(&mut self, name: &str, value: i64) -> Result<()>
Replace a long keyword, keeping its existing comment (ffmkyj with "&").
Sourcepub fn shift_table_col_keys(
&mut self,
colmin: i32,
colmax: i32,
incre: i32,
) -> Result<()>
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.
Sourcepub fn card_by_name(&self, name: &str) -> Option<&Card>
pub fn card_by_name(&self, name: &str) -> Option<&Card>
First card whose 8-character name matches name (case-insensitive).
Sourcepub fn upsert_long(
&mut self,
name: &str,
value: i64,
comm: Option<&str>,
) -> Result<()>
pub fn upsert_long( &mut self, name: &str, value: i64, comm: Option<&str>, ) -> Result<()>
Replace the first card of this name, or append.
Sourcepub fn write_float_exp(
&mut self,
name: &str,
value: f64,
decim: usize,
comm: Option<&str>,
) -> Result<()>
pub fn write_float_exp( &mut self, name: &str, value: f64, decim: usize, comm: Option<&str>, ) -> Result<()>
fits_write_key_flt / ffpkye (exponential).
Sourcepub fn write_null(&mut self, name: &str, comm: Option<&str>) -> Result<()>
pub fn write_null(&mut self, name: &str, comm: Option<&str>) -> Result<()>
fits_write_key_null / ffpkyu.
Sourcepub fn write_comment(&mut self, comm: &str)
pub fn write_comment(&mut self, comm: &str)
fits_write_comment / ffpcom.
Sourcepub fn write_history(&mut self, hist: &str)
pub fn write_history(&mut self, hist: &str)
fits_write_history / ffphis.
Sourcepub fn write_record(&mut self, card: &str)
pub fn write_record(&mut self, card: &str)
fits_write_record / ffprec.
Sourcepub fn write_complex_exp(
&mut self,
name: &str,
real: f64,
imag: f64,
decim: usize,
comm: Option<&str>,
) -> Result<()>
pub fn write_complex_exp( &mut self, name: &str, real: f64, imag: f64, decim: usize, comm: Option<&str>, ) -> Result<()>
Complex exponential (ffpkyc / ffpkym).
Sourcepub fn write_complex_fixed(
&mut self,
name: &str,
real: f64,
imag: f64,
decim: usize,
comm: Option<&str>,
) -> Result<()>
pub fn write_complex_fixed( &mut self, name: &str, real: f64, imag: f64, decim: usize, comm: Option<&str>, ) -> Result<()>
Complex fixed (ffpkfc / ffpkfm).
Sourcepub fn write_ulong(
&mut self,
name: &str,
value: u64,
comm: Option<&str>,
) -> Result<()>
pub fn write_ulong( &mut self, name: &str, value: u64, comm: Option<&str>, ) -> Result<()>
Unsigned 64-bit integer keyword.
Sourcepub fn record(&self, n: usize) -> Result<Card>
pub fn record(&self, n: usize) -> Result<Card>
1-based keyword record (fits_read_record). Does not include END.
Sourcepub fn get_string(&self, name: &str) -> Result<(String, String)>
pub fn get_string(&self, name: &str) -> Result<(String, String)>
Unquoted string value (fits_read_key_str).
Sourcepub fn get_logical(&self, name: &str) -> Result<(bool, String)>
pub fn get_logical(&self, name: &str) -> Result<(bool, String)>
Logical value (fits_read_key_log).
Sourcepub fn raw_value_comment(&self, name: &str) -> Result<(String, String)>
pub fn raw_value_comment(&self, name: &str) -> Result<(String, String)>
Raw value + comment strings (fits_read_keyword).
Sourcepub fn get_unit(&self, name: &str) -> Result<String>
pub fn get_unit(&self, name: &str) -> Result<String>
Units from [...] in the comment (fits_read_key_unit).
Sourcepub fn set_unit(&mut self, name: &str, unit: &str) -> Result<()>
pub fn set_unit(&mut self, name: &str, unit: &str) -> Result<()>
Prepend [unit] to the comment (fits_write_key_unit).
Sourcepub fn update_with(
&mut self,
name: &str,
value: &str,
comm: Option<&str>,
) -> Result<()>
pub fn update_with( &mut self, name: &str, value: &str, comm: Option<&str>, ) -> Result<()>
Update: replace if present, otherwise append (fits_update_key).
Sourcepub fn modify_with(
&mut self,
name: &str,
value: &str,
comm: Option<&str>,
) -> Result<()>
pub fn modify_with( &mut self, name: &str, value: &str, comm: Option<&str>, ) -> Result<()>
Modify an existing keyword; error if missing (fits_modify_key).
Sourcepub fn insert_record_at(&mut self, pos: usize, card: Card) -> Result<()>
pub fn insert_record_at(&mut self, pos: usize, card: Card) -> Result<()>
Insert card at 1-based pos (before that record). pos > nkeys
appends.
Sourcepub fn delete_key(&mut self, name: &str) -> Result<()>
pub fn delete_key(&mut self, name: &str) -> Result<()>
Delete first keyword with this name (fits_delete_key).
Sourcepub fn delete_record(&mut self, n: usize) -> Result<()>
pub fn delete_record(&mut self, n: usize) -> Result<()>
Delete 1-based record (fits_delete_record).
Sourcepub fn replace_name(&mut self, name: &str, card: Card) -> Result<()>
pub fn replace_name(&mut self, name: &str, card: Card) -> Result<()>
Replace first matching name.
Sourcepub fn write_date_value(&mut self, datetime: &str) -> Result<()>
pub fn write_date_value(&mut self, datetime: &str) -> Result<()>
Write DATE with the given timestamp value (fits_write_date body).
Sourcepub fn write_keys_long(
&mut self,
root: &str,
start: i32,
values: &[i64],
comms: &[Option<&str>],
) -> Result<()>
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.
Sourcepub fn get_keys_long(
&self,
root: &str,
start: i32,
nmax: usize,
) -> (Vec<i64>, usize)
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.
Sourcepub fn primary_info(&self) -> Result<PrimaryInfo>
pub fn primary_info(&self) -> Result<PrimaryInfo>
Primary-array required keywords (fits_read_imghdr / ffghpr).
Sourcepub fn image_type(&self) -> Result<ImageType>
pub fn image_type(&self) -> Result<ImageType>
Infer ImageType from BITPIX + BZERO.
Sourcepub fn to_record_bytes(&self) -> Vec<u8> ⓘ
pub fn to_record_bytes(&self) -> Vec<u8> ⓘ
Serialize cards + END + space fill to a multiple of 2880 bytes.
Sourcepub fn to_record_bytes_with_morekeys(&self, morekeys: i32) -> Vec<u8> ⓘ
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).
Sourcepub fn nmore_in(&self, header_len: u64) -> i32
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).
Sourcepub fn primary_as_image_extension(&self) -> Result<Self>
pub fn primary_as_image_extension(&self) -> Result<Self>
Convert a primary-array header into an IMAGE extension (ffcphd).
Sourcepub fn image_extension_as_primary(&self) -> Result<Self>
pub fn image_extension_as_primary(&self) -> Result<Self>
Convert an IMAGE extension header into a primary array (ffcphd).