×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Python and INDI: from BLOBS to numpy.array

  • Posts: 7
  • Thank you received: 0
Hi everyone,
I'm developing a Python program based on INDI for EAA (Electronically Assisted Astronomy). The interface with INDI is based on this tutorial : indilib.org/develop/tutorials/151-time-l...ith-indi-python.html
My problem is that I don't know how to convert the BLOB bytes I get to numpy.array to allow further processing. Can anybody help me?

<code>
# get image data
img = bp.getblobdata()
# write image data to BytesIO buffer
import io
blobfile = io.BytesIO(img)
# open a file and save buffer to disk
with open("frame.fit", "wb") as f:
f.write(blobfile.getvalue())
</code>
4 years 5 months ago #45594

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

  • Posts: 105
  • Thank you received: 30
This is a quick and dirty example that should work.

import astropy.io.fits as pyfits
blob = blobEvent
fits=blob.getblobdata()
blobfile = BytesIO(fits)
hdulist = pyfits.open(blobfile)
image_data =hdulist[0].data

image_data will now be a 2D numpy array with the first index being 'Y' and the second 'X' in the traditional sense of indexing images.

You can do:

image_data = numpy.transpose(image_data)

to flip it around to X first then Y.

This example assumes the data is in the primary HDU header which I think is always the case for INDI generated FITS representations of an image in memory.

You can read more starting here:

docs.astropy.org/en/stable/io/fits/usage/headers.html
4 years 5 months ago #45603

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

  • Posts: 7
  • Thank you received: 0
It works like a charm, thank you!
4 years 5 months ago #45608

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

  • Posts: 105
  • Thank you received: 30
Great - I've written a large amount of code for INDI using Python so let me know if I can be any help.
4 years 5 months ago #45611

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

  • Posts: 145
  • Thank you received: 15
This project sounds great! How's your progress? I'd love to see some EAA feature in Ekos...

Cheers,
Bernd
4 years 2 months ago #48814

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

  • Posts: 7
  • Thank you received: 0
Hi,
I wrote the software and tested it with the simulated camera and it seems working. Unfortunately, I've been too lazy to bring my setup back to life for a real test on the field so far...
4 years 2 months ago #48815

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

  • Posts: 145
  • Thank you received: 15
Live stacking in Ekos should be thrilling and motivating, shouldn't it? ;) :cheer:
4 years 2 months ago #48823

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

  • Posts: 7
  • Thank you received: 0
That was the idea! But questionable weather, the hassle to start again after five years and small children around work against me :lol:
By the way, here (GitHub) anyone with more energy than me can find my first experiment to further develop. It has just the basic functions, I have more fancy algorithms in mind once this first proof of concept seems to work properly
4 years 2 months ago #49356

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

Time to create page: 0.511 seconds