LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Blogs > peonuser
User Name
Password

Notices

Rate this Entry

Radar maps gone retro.

Posted 04-24-2012 at 05:26 PM by peonuser

Once in a while I sort of come up with a neat idea. At least it is to me. Just because you have an old system, does not mean you can not teach it new tricks. Done a lot of page scraping to get weather details, but it would be nice to use radar screens from the command line. So details in this case are not so necessary. The overall view of the weather to see what kinds of weather fronts are approching is.

Here we go. We need to collect some historical data (i.e. radar screens). You can get these from the radar.weather.gov using the 3 letter designation for the area you are interested in. For example, I beleive the Dallas Fort Worth area is supposed to be FWS. You do not have to collect data just for your area. Collect data for several areas and get an overview of the weather all around.

You need to collect data. Cron is the perfect tool for the job. We need to create a batch file that will collect the pictures using cron. You will need to find the three letter designation of your area. You can get that from the national weather service. Note we put d.sh in the bin directory because it is in the executable directory path.

d.sh:
Code:
DAY=$(date +"%m%d%y%H%M%S")
# picfn="pic$DAY.png"
# echo $picfn
wget http://radar.weather.gov/ridge/Thumbs/FWS.png -O fws$DAY.png
*/1 * * * * /home/eddie/bin/d.sh

We will set it to grab a picture once a minute. AT most once a hour is fine unless you know you have inclement weather coming. Set the collection at 1 per minute for our example. That will fill up a hard drive quickly so be careful.

$ chmod +x d.sh

$ crontab -e to add d.sh to your cronfile.

You should be collecting radar images once you have that set up. We are beginning to collect a few pictures. Now we need to convert the picture(s) to a text file.

Convert.sh:
Code:
for g  in fws*.png
do
echo $g
img2txt -W 80 -f utf8 img2txt -W  80 -H 25 utf8 $g > $g.txt
done
Note: We used img2txt -W 80 -f utf8 img2txt -W 160 -H 60 utf8 $g > $g.txt

$ chmod +x convert.sh

$ ./convert.sh

You see the file names to be converted on the screen as they are processed. Then you should be able to to list the generated text.files.

$ ls fws*.txt

We could examine each txt file to see what the weather was at the moment, but that is time consuming. Better to have sort of a page flipping to see how the weather was over time. So far so good. Now we need to create a batch file to show the animation. This is also a good start to a text based slide show.

show.sh:
Code:
for g  in fws*.txt
do
tput cup 0 0
 cat $g
done
$ chmod +x show.sh

$ ./show.sh

Watch the show. If there is not much weather change or you have only collected a few frames, you not see the whiz boom you might want to. Definitely try it when a storm is coming your way (if it is safe to do so!!)

Posted in Uncategorized
Views 336 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 08:26 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration