×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Saving CCD blob to FITS file

  • Posts: 10
  • Thank you received: 1
I'm using PyIndi to make a client that connects to an indiserver for an SX_CCD. This particular CCD is the SX CCD SXVR-H694.

When I receive the blob from the CCD, the type is FITS but it's a 1D bytearray object, not 2D.

How do I go about converting this into the necessary format to save to a FITS file for viewing?
3 years 10 months ago #53827

Please Log in or Create an account to join the conversation.

  • Posts: 1208
  • Thank you received: 559
Here's a pointer to the method in fitsvewer that does that.
git.launchpad.net/kstars-bleeding/tree/k...di/indiccd.cpp#n1532
Please follow up if you have any questions.
3 years 10 months ago #53828

Please Log in or Create an account to join the conversation.

  • Posts: 10
  • Thank you received: 1
Thank you for the link, but I'm still a little confused.
I'm new to using Indi, and I'm using the PyIndi wrapper, so I'm not quite sure how to use the CCD::processBLOB. The code I started with is from the example here: www.indilib.org/develop/indi-python-bindings.html.

The relevant part at the end, where I receive the blob's data:

for blob in ccd_ccd1:
print("name: ", blob.name," size: ", blob.size," format: ", blob.format)
fits=blob.getblobdata()
print("fits data type: ", type(fits))
# here you may use astropy.io.fits to access the fits data
i+=1

The format of "blob" returns a bytearray object, and the size is 12104640.
Using astropy.io.fits I can create the fits file but the data is 1D. Can I make a call to CCD::processBLOB somehow to convert this into a 2D byte array that FITS viewers like?

Thank you again for the help.
3 years 10 months ago #53831

Please Log in or Create an account to join the conversation.

  • Posts: 1208
  • Thank you received: 559
Sorry, I'm not familiar with the PyIndi wrapper, and I wasn't suggesting that you try and call that C++ method.
I was just pointing you there in case you could read the code and see what kind of format the blob had.
If my memory serves me right, the blob data is in the fits file format as is (if it's of type FITS), but you should check.
3 years 10 months ago #53832

Please Log in or Create an account to join the conversation.

  • Posts: 10
  • Thank you received: 1
Ah wow, I figured it out. Very simple haha.
The 1D byte array that blob.getblobdata() returns IS the contents of the FITS file, in its entirety. All I had to do was open a new binary file and write this array to it:
fits = blob.getblobdata()
f = open('/dir/image.fits', 'wb')
f.write(fits)
f.close()
3 years 10 months ago #53853

Please Log in or Create an account to join the conversation.

Time to create page: 0.497 seconds