You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found that the library cannot parse a file with a binary table extension header, when a field type has no repeat count.
Reproducer
#[cfg(test)]
mod test{
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use fitsrs::fits::Fits;
#[test]
fn parse() -> Result<(), Box<dyn Error>> {
let file = File::open(".../mastar-combspec-v3_1_1-v1_7_7-lsfpercent60.0.fits")?;
let mut reader = BufReader::new(file);
let Fits { hdu } = Fits::from_reader(&mut reader)?;
let mut primary_hdu = hdu;
let mut hdu = primary_hdu.next();
println!("Iterate over HDUs");
while let Some(mut ext_hdu) = hdu?.take() {
println!("Got HDU");
hdu = ext_hdu.next();
}
Ok(())
}
}
Output:
Iterate over HDUs
Error: StaticError("Ascii Table TFORM not recognized")
I think the issue is caused by a typo in a BinTable::update_with_parsed_header:
src/hdu/header/extension/bintable.rs
let (field_type_char, repeat_count) =
if let Ok((remaining_bytes, Value::Integer(repeat_count))) =
parse_integer(card_value.as_bytes())
{
(remaining_bytes[0].as_char(), repeat_count)
} else {
(owned_kw[0].as_char(), 1) // <<<< the problem expression (line 80)
};
let repeat_count = repeat_count as u64;
The problem expression attempts to read field type from owned_kw instead of card_value.
When I change line 80 to
(card_value.as_bytes()[0].as_char(), 1)
A file is parsed without an error.
The text was updated successfully, but these errors were encountered:
Thanks for the bug report. For the moment, only image extension is parseable by fitsrs. Although I have begun the bintable support it is not fully done. I will soon give some of my time continuing this work.
I have found that the library cannot parse a file with a binary table extension header, when a field type has no repeat count.
Reproducer
Output:
The file I used in my test
https://data.sdss.org/sas/dr17/manga/spectro/mastar/v3_1_1/v1_7_7/mastar-goodspec-v3_1_1-v1_7_7-lsfpercent60.0.fits.gz
Fix
I think the issue is caused by a typo in a
BinTable::update_with_parsed_header
:The problem expression attempts to read field type from
owned_kw
instead ofcard_value
.When I change line 80 to
A file is parsed without an error.
The text was updated successfully, but these errors were encountered: