I had a spare @Raspberry_Pi and sense HAT, left over from the glory days of firing two @astro_pi's to the space station on a big rocket, so I decided to make the "World's Smallest Real Time ISS Ground Track Map"*.
But how, I hear literally none of you say?
1/n
(*Needs citation)
You might have seen recently that I have been playing with @NASA's open notify API. With a few lines of code you can request their server to tell you the latitude and longitude of the ISS, in real time.
2/n https://twitter.com/JohnChinner/status/1272472768458698752?s=19
It wasn't too tricky to find some sample code and work out the distance from the ISS to my house.
Taking two samples 10 seconds apart, and using "if" statements in python, I could see if the ISS was approaching, receding or over the horizon, and therefore "visible".
3/n
It worked great. At a glance I could see what was happening, and know "roughly" where the ISS was.
I wanted more, and remembered something I had in my mind back in 2015 when @dave_spice first showed me the sense HAT and it's nifty 8x8 array of RGB led's. 4/n
Now, 8x8, or 64 individual pixels isn't very much to work with, but it might just be enough, if I use colours and split the globe in half, almost like I'm in space looking back.
Half the time the ISS would be behind the Earth.
Handily the UK lies on the prime meridian.
The ISS is in an orbit inclined 52 degrees to the equator, so it only ever gets to +52 and -52 degrees latitude. (Top and bottom of the orbit).
I assigned each horizontal line of pixels 15 degrees giving me 4 "up" and 4 down, so +60 and -60 degrees latitude. 6/n
I split the circumference of the earth into 16 chunks of 22.5 degrees longitude.
Combining the latitude values each segment now represents a unique place on the earth. There are 128 in total, 64 in "view" and 64 "behind" the earth. 7/n
Each segment needs a set of "if" statements in python which are compared to the latitude and longitude of the ISS returned from the API. With this I can identify the segment the ISS is flying over and illuminate the pixel. Green for in view, red for behind the earth. 8/n
Just lighting the LED's isn't helpful for knowing the location of the ISS, so I made a paper map overlay that fits on the LED matrix.
It took a few attempts before it was correct.
That's part of the fun though, right?
(Excess paper went into recycling 😁)
9/n
Surprisingly, the code ran first time. It isn't complicated, but there are 128 "if" statements to get right. Here is a comparison of my illuminated pixel and the ISS location. 10/n
Here the ISS is behind the Earth, so the pixel is illuminated red. 11/n
Interestingly, if I don't clear the LED matrix with each reading, you get a track.
Here the ISS came around from "behind" above Canada, passed over Europe, down through Africa, and then went "behind" again.
12/n
So, what do I think?
It was a fun little exercise, although the "granularity" of the ISS location isn't brilliant. I'm not a natural coder, so there are probably better ways to do this in python. I suppose my code is functional, but not elegant. A bit like me. 👍🚀 END.
You can follow @JohnChinner.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.