pythonencodingfits

FITS file is not getting encoded properly


I am trying to use scintools module (https://github.com/danielreardon/scintools).

I want to see a dynamic spectra using the 'Dynspec' feature, by reading a fits file.

It is giving me an error of

'charmap' codec can't decode byte 0x90 in position 2985: character maps to

when I type in

dyn=Dynspec(
    filename="B1133+16_bm4_pa_750_200_16_12mar2018.raw.2.dspec.fits", process=False
)

as instructed in the 'examples' section in the GitHub page. I am attaching a picture of the error that I am getting. Can someone help me out regarding this? There are other answers related to this but nothing seems to work...

I tried reading the file in binary mode, which is not working. I also tried to modify the source code by adding "encoding = 'utf-8'", which is showing me a different encoding error.


Solution

  • Looking at the code for this package I don't see any indication or documentation whatsoever to suggest that it can read a spectrum from a FITS file.

    It looks like it reads in some custom ad-hoc file format (I thought we'd done a better job lately convincing researchers not to do that where it isn't absolutely necessary...)

    It reads a plain text file that it's reading in text mode, so it crashes if you try to read in a binary FITS file containing non-UTF-8 bytes.