Macro mwalib::get_optional_fits_key
source · [−]macro_rules! get_optional_fits_key {
($fptr:expr, $hdu:expr, $keyword:expr) => { ... };
}
Expand description
Given a FITS file pointer, a HDU that belongs to it, and a keyword that may or may not exist, pull out the value of the keyword, parsing it into the desired type.
Arguments
-
fits_fptr
- A reference to theFITSFile
object. -
hdu
- A reference to the HDU you want to findkeyword
in the header of. -
keyword
- String containing the keyword to read.
Returns
- A Result containing an Option containing the value read or None if the key did not exist, or an error.
Examples
let metafits = "test_files/1101503312_1_timestep/1101503312.metafits";
let mut fptr = fits_open!(&metafits)?;
let hdu = fits_open_hdu!(&mut fptr, 0)?;
let freq_centre: Option<f64> = get_optional_fits_key!(&mut fptr, &hdu, "FREQCENT")?;
assert_eq!(freq_centre, Some(154.24));
let not_real: Option<f64> = get_optional_fits_key!(&mut fptr, &hdu, "NOTREAL")?;
assert_eq!(not_real, None);