For a given day, I may have 6 million+ ads-b messages. Salem is located under the routes that jets from Portland and Seattle take to points south, so most of the traffic over Salem is caused by jets flying at altitudes over 30,000. I'm not really interested in those flights. My interests are in the flights that are close to my neighborhood. So what I did was determine a rectangular area within Google earth by placing two placemarks (yellow thumbtacks): one at the northeast corner and one at the southwest corner. I just picked areas which I felt would have aircraft flying at low altitudes over houses.
The two placemarks I selected have these coordinates:
Name | Longitude (decimal degrees) |
Latitude (decimal degrees) |
Picture |
---|---|---|---|
Northeast | 44.959274° | -122.959463° | |
Southwest | 44.877369° | -123.070046° |
If any aircraft has been flying, then there will be MSG,3 packets. Using the Linux shell script "awk", I created a little program that looks at every packet and determines if the latitude and longitude packet is within my defined area and under an altitude of 1500 feet. Then the results are "piped" [directed] to temporary memory after which I determine what are the unique values therein. I do not need 100,000s of thousands of the same aircraft, just one.
Here is the awk script I use that gives me a list of all aircraft which transmitted at least one packet that qualifies for the three tests: longitude, latitude, and altitude. (Note that I have the results contain a copy of the script at the top of the file that created the results file because I'm working and fast and loose and want to preserve just what the recipe was at the time I generated the file.) The script below identifed (61 - 8 comment lines= ) 53 aircraft.
ryzdesk /home/jlpoole # date; cat -n /adsbwork/logs/2024/04/24/24/salem_uniq_adsb.txt |
---|
Here's how much computer time it takes (the time sink is in the reading of the file, not processor calculations): 5 seconds. I have modified the end of the processing chain to show only the count ("wc -l" = count the lines of the output) of the aircraft rather than list them out since we already have that information above.
ryzdesk /home/jlpoole # # # How long does this script take to process 2,197,302 packets? # date; time cat /adsbwork/logs/2024/04/24/24/2024_04_24_1090.log.valid.MSG3 \ | awk -F, '{hex=$5;alt=$12;lat=$15;lon=$16; \ if (lat >= 44.877369 && lat <= 44.959274 \ && lon >= -123.070046 && lon <= -122.959463 \ && alt <= 1500) \ print hex;}'|sort|uniq|wc -l Sun Jun 2 04:01:52 PM PDT 2024 53 real 0m5.025s user 0m4.896s sys 0m0.308s ryzdesk /home/jlpoole # |
---|
So, in file salem_uniq_adsb.txt I have a punch list of aircraft which I have defined by two placemarks and an altitude. These are the aircraft of interest. What is nifty about this approach is that if I change my mind, or want an alternative scenario, it's just a simple matter of redefining the paraemters in the awk script, e.g. altitude of 2,400' instead of 1,500', and re-running the scripts and isolating the output.