×

INDI Library v1.9.8 Released (29 Sep 2022)

Bi-monthly INDI Library released with new drivers and bug fixes.

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?
2 years 6 months ago #53827

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

  • Posts: 917
  • Thank you received: 429
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.
AP1100 & Orion Atlas Pro, WO/ZS105 w/Moonlight V2 focus, GSO RC10 w/RSF focus
ZWO ASI1600, Astronomik Filters, ST80, QHY 5L-IIm.
KStars/Ekos/Indi on NUC10 & RPi4 w/SSD -- Ubuntu
Projects: Greedy Scheduler, Terrain, Polar Align, Analyze, Linear Focuser, SEP MultiStar & GPG Guide, FITS autostretch.
2 years 6 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.
2 years 6 months ago #53831

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

  • Posts: 917
  • Thank you received: 429
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.
AP1100 & Orion Atlas Pro, WO/ZS105 w/Moonlight V2 focus, GSO RC10 w/RSF focus
ZWO ASI1600, Astronomik Filters, ST80, QHY 5L-IIm.
KStars/Ekos/Indi on NUC10 & RPi4 w/SSD -- Ubuntu
Projects: Greedy Scheduler, Terrain, Polar Align, Analyze, Linear Focuser, SEP MultiStar & GPG Guide, FITS autostretch.
2 years 6 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()
2 years 6 months ago #53853

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

Time to create page: 0.379 seconds