-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl fitsio::tables::ReadsCol for OSString #246
Comments
Hi @d3v-null, thanks for raising this issue. I think you're right - the string handling needs to be better in |
I don't suppose you have (or can you generate) a test file I can use for my testing? |
@d3v-null do you have an example file that you can share with me? I'd like to investigate further the use of non-unicode characters in table values. |
Hey @simonrw , sorry it took me so long to respond. I deleted my copy of the corrupt file and had to figure out how to get you a copy of the broken hdu without sending you the entire 9GB file. Here's a file with a copy of the AIPS AN table in question.
the ANNAME column should just say The original file is from here if you're curious The other files are corrupt in different ways, but the root problem is the non-utf8 characters. Cheers! |
Hi, sorry I am confused here. If I read the data from that file using a I'm happy to also add reading as |
@d3v-null have you had a chance to reflect on my last comment? |
Hey Simon, Otherwise, you could be right about use std::error::Error;
use std::path::PathBuf;
use fitsio::FitsFile;
fn run() -> Result<(), Box<dyn Error>> {
let mut fitsfile = FitsFile::edit(PathBuf::from("test.fits"))?;
fitsfile.pretty_print().expect("printing fits file");
let ant_hdu = fitsfile.hdu("AIPS AN")?;
for name in ant_hdu.read_col::<String>(&mut fitsfile, "ANNAME")? {
println!("{:?}", name);
}
Ok(())
}
fn main() {
run().unwrap();
} cargo run --example dev file: "test.fits"
mode: READWRITE
extnum hdutype hduname details
0 IMAGE_HDU dimensions: [], type: UnsignedByte
1 BINARY_TBL AIPS AN num_cols: 13, num_rows: 512
"s000002"
"s000102"
"s000202"
"s000302"
"s000402"
"s000502"
"s000602" compared to astropy fits, which gives me python -c "from astropy.io import fits; names=fits.open('test.fits')['AIPS AN'].data['ANNAME']; print('\n'.join(map(repr, names)))" 's0000\x0002'
's0001\x0002'
's0002\x0002'
's0003\x0002'
's0004\x0002'
's0005\x0002'
's0006\x0002'
's0007\x0002'
's0008\x0002' |
Hello,
I've had the misfortune of encountering a fits file in which random non-utf8 junk bytes are present after a null byte in a string column.
Because fitsio impls ReadsCol for String, but not OSString, this means that it can't read these columns at all.
Here's what the data looks like in Python:
The first
ANNAME
should just bes0000
. If there were an impl OSString, I could trim these junk bytes before converting to string and read the column correctly.Thanks
The text was updated successfully, but these errors were encountered: