PAINANI-1 Images

About a year ago I wrote a small script that tries to find downlinked chunks of images in JPEG2000 format from a satellite called PAINANI-1. In August 2020 the first images were downloaded and also forwarded by a lot of contributors into SatNOGS-DB. A hint from a contributor of the original team around the satellite gave some hints on how images are downloaded from the satellite. If the satellite was commanded to make an image, the image itself and a, much lower in resolution, thumbnail is stored. The team then tries to download the thumbnail first to see if the shot went well or, at least, is promising.

First time I ran the script there were a few images found in SatNOGS-DB, showing some clouds and nice view of the earth. Additionally there were some super blurred images I couldn’t make a guess of what it is. A bunch of time passed…

A few days ago I decided to check SatNOGS-DB for new images taken by PAINANI-1 - and guess what? There are a few more. Again some clouds and really nice images of the earth, including one blurred image probably showing some mountains (see images below). Also the blurred images turn out to be images from a PCB component inside the cubesat, looking nearly like an X-ray scan of a BGA or a PCB with a BGA footprint. Maybe someone around the cubesat team is reading these lines and could throw some light…

Thumbnails found in DB:


image_1201493.j2c


image_1201493.j2c


image_1135957.j2c


image_1332565.j2c


image_1349270.j2c


image_1398101.j2c


image_1414806.j2c


image_1463637.j2c


image_1529173.j2c


image_1660245.j2c


image_1791317.j2c


image_1856853.j2c


image_1987925.j2c


image_2004630.j2c


image_2053461.j2c


image_2118997.j2c


image_2184533.j2c


image_2250069.j2c


image_2839893


image_2839893


image_2905429.j2c


image_3560789.j2c


image_3626325.j2c


image_3691861.j2c


image_3757397.j2c


image_4085077.j2c


image_4150613.j2c


image_4172373.j2c


The images looking similar to “aurora” are the ones where I think this is a component of the camera PCB.

Images found in DB:







There seem to be more but actually they appear to be all black. Probably there are a bunch of chunks missing or they are somehow corrupted. If someone wants to give it a try himself you may want to follow the instructions below:

  • register in our SatNOGS ecosystem (generate an account and login)
  • visit the data tab of PAINANi-1
  • in the “Data Export (frames)” panel click on “Everything”
  • edit the following script to match your paths and run it
  • view the generated files with a JPEG2000 capable viewer

The Script:

#%%
#
# PAINANI-1 image extractor
# Extracts the images taken by the satellite PAINANI-1 (NORAD-ID: 44365)
# stored in the SatNOGS-DB. Log in to the DB, select PAINANI-1, switch to the
# data tab and select "Everything" from the "Data Export (frames)" pane. Then
# download the file once you got the announcement email and run the following
# code at the proper location.
# August 2020, with the kind help of fredy and deckbsd, DL4PD
#

import glob
import binascii

# DB dumps in hexlified ASCII
files = glob.glob("../sampledata/painani-1/WBJA-*.csv")
mode = 'r'

images = {}
chunks = []
image_chunks = {}
for file in files:
    with open(file, mode) as f:
        # DB dump
        lines = f.readlines()
        for line in lines:
            payload = bytearray(binascii.unhexlify(line[20:-1]))
            magic = bytearray([0x03, 0xf0, 0xcc, 0xcc])
            magic_id = payload[14:18]
            offset = 37
            if magic_id == magic:
                image_id = int.from_bytes(payload[25:28], 'big')
                if image_id not in images.keys():
                    images[image_id] = {}
                chunk_id = int.from_bytes(payload[28:30], 'big')
                chunk_size = payload[36]
                chunk = payload[offset:offset + chunk_size]
                if len(chunk) == chunk_size:
                    images[image_id][chunk_id] = chunk

for image_key, chunk in sorted(images.items()):
        image_name = "../sampledata/painani-1/images/aug2021/image_" + str(image_key) + ".j2c"
        print("writing image:", image_name)
        img_sz = 0
        chunks = 0
        f = open(image_name, 'w+b')
        for ch_key, ch_value in sorted(chunk.items()):
            chunks += 1
            binary_data = []
            binary_data = bytearray(ch_value)
            f.write(binary_data)
            img_sz += len(binary_data)
        print("Image", image_key, "size:", chunks, "chunks,", img_sz, "bytes")
        f.close()

# %%

If you find anything just answer to this post :wink:

8 Likes

Amazing images Patrick. Inspiring stuff. Now when are we going to get some data from the Mir-Sat-1 camera?

Chris
G0KLA / AC2CZ

2 Likes

But how to open j2c images? Which program supports it…?

Thanks to the OP for an inspiring post! I used the steps and the script to produce the j2c’s and am now using some of the earth images as wallpaper. Just the motivation I needed to take my next steps with Satnogs.

To open the j2c images on Ubuntu I did the following:

sudo apt install libopenjp2-tools
opj_decompress -i image_4150613.j2c -OutFor TIF -o /tmp/my.tif

I did this for all the images. Then used standard tools to open the TIF version.

Troy

2 Likes