Created
April 15, 2014 23:15
-
-
Save alexclifford/10787687 to your computer and use it in GitHub Desktop.
Parse Nowcast FTP data to create a coordinates plotted Google Map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# cat out all the files' contents to a single file | |
for DIR in `ls /home/nowcast/FTP_root/au/`; do zcat /home/nowcast/FTP_root/au/$DIR/* >> file.txt; done; | |
# keep only uniq entries | |
sort file.txt | uniq >> final_file.txt | |
# print out the lat/long/timestamp in the required javascript syntax for the Google Maps HTML file | |
# cloud to ground | |
awk '$3 <= -38 && $3 >= -39 && $4 >= 146.5 && $4 <= 147.5 && $6 == 1 { print "add_markers(1," $3 "," $4 ",\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27/lightning-icon-Sparse-1.png\x27)"}' final_file.txt >> markers_cloud_to_ground.txt | |
# cloud to cloud | |
awk '$3 <= -38 && $3 >= -39 && $4 >= 146.5 && $4 <= 147.5 && $6 == 2 { print "add_markers(2," $3 "," $4 ",\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27/lightning-icon-Sparse-1.png\x27)"}' final_file.txt >> markers_cloud_to_cloud.txt | |
# unknown | |
awk '$3 <= -38 && $3 >= -39 && $4 >= 146.5 && $4 <= 147.5 && $6 == 0 { print "add_markers(3," $3 "," $4 ",\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27" $1 " " $2 " - " $3 " " $4 "\x27,\x27/lightning-icon-Sparse-1.png\x27)"}' final_file.txt >> markers_unknown.txt | |
# Create the Google Maps HTML file from all the processed output | |
sed -e 's/CLOUDTOGROUND/'$(wc -l markers_cloud_to_ground.txt | cut -d" " -f 1)/ -e 's/CLOUDTOCLOUD/'$(wc -l markers_cloud_to_cloud.txt | cut -d" " -f 1)/ -e 's/CLOUDUNKNOWN/'$(wc -l markers_unknown.txt | cut -d" " -f 1)/ html_header.txt > lightning_strikes2.html | |
cat markers_cloud_to_ground.txt >> lightning_strikes2.html | |
cat markers_cloud_to_cloud.txt >> lightning_strikes2.html | |
cat markers_unknown.txt >> lightning_strikes2.html | |
cat html_footer.txt >> lightning_strikes2.html | |
# clean up the left over files | |
rm -f file.txt | |
rm -f final_file.txt | |
rm -f markers* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment