Author Topic: PHP for WASP2 lightning/RADAR animation  (Read 12557 times)

0 Members and 1 Guest are viewing this topic.

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
PHP for WASP2 lightning/RADAR animation
« on: January 28, 2008, 03:30:43 PM »
Running NexStorm, SynCom, and WASP2?

Want this?



Got PHP? Can you run cron jobs?

Get this:
WASP2Animator.zip

This is the first release of this script. Consider it an alpha release. It makes a 10 frame animation.

The zip should contain everything you need, including the script, GIFEncoder.class.php, 10 starter images, and a starter animation.

It renames the last 9 images and gathers one WASP2 image every time the script is run, and then crops, labels and saves the new image. Then it combines them into one animated GIF. Delay between frames is programmable in the script, currently running 0.25 sec.

Have fun. If you run the script, please post your links here so I can see how it looks.

Thanks,

Chris
« Last Edit: September 03, 2009, 06:24:39 PM by saratogaWX »

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #1 on: January 28, 2008, 05:04:24 PM »
Hell yeah I want this!!! Great script Chris. I'm letting my images populate at 10 minute intervals with my cron but here is the loop. I'm just running the test for now but it seems to working so far. Freakin sweet.


« Last Edit: January 29, 2008, 11:20:23 PM by capeweather »

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #2 on: January 28, 2008, 06:15:05 PM »
I'm glad that you like it. It's pretty cool when there are lightning strikes on it. They fade out as they age.

At 3:06 PST, your loop has one black frame in it. I saw this once this morning in my test loop. I believe that it's caused by the WASP2 upload occurring at the same time as the script is running. I'm not quite sure how to handle this, except to make sure the computer times are synced, and the upload time is offset from the crontab time.

Also, I'll be uploading a slightly revised script later this evening, to correct a couple of things it.

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #3 on: January 28, 2008, 06:24:28 PM »
It may have been the cron interval. I had it set to five minutes and forgot that the overlay is updated about every five minutes causing duplicate images on the loop. I backed it off to 10 so after a few hours it should be a smooth transition with different image sets. I wouldn't recommend setting the cron job to less than 10 minutes.

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #4 on: January 28, 2008, 06:42:06 PM »
OK, I fixed the code and uploaded a new zip file, same location.

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #5 on: January 28, 2008, 06:54:49 PM »
I updated

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #6 on: January 28, 2008, 07:05:14 PM »
Yeah, I see what you mean Chris. Now I have two black screens in the loop. It must be trying to pull the image while it's updating resulting in no output.

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #7 on: January 28, 2008, 08:14:04 PM »
Maybe what you could tell the script to do is only grab an image if it's larger than a certain file size. I just looked at all of my file sizes of the 'good' images and they are all approx 10k. The one image with the black background was around 1k. Something to maybe try.

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #8 on: January 28, 2008, 08:22:49 PM »
I think it's more a problem with the script somehow timing out on the file access, and proceeding with running in the absence of a new image.

I've had a similar problem with a script that grabs my webcam images and labels them. If the camera is off-line the image is black.

Hmm...

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #9 on: January 28, 2008, 08:25:11 PM »
Well so far so good. The black image has sequenced to the #9 slot so I almost have a full loop.

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #10 on: January 28, 2008, 08:29:13 PM »
Imagecreatefrompng "returns an empty string on failure." I'll have to see how to incorporate that as some sort of error checking.

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #11 on: January 28, 2008, 08:48:54 PM »
Heres the error log I received for the two times the script tried to grab a blank image.

Code: [Select]
[28-Jan-2008 17:05:01] PHP Warning:  imagecreatefrompng(http://www.capeweather.com/images/lightning/wasp2.png) [<a href='function.imagecreatefrompng'>function.imagecreatefrompng</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 73
[28-Jan-2008 17:05:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 76
[28-Jan-2008 17:05:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 79
[28-Jan-2008 17:05:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 82
[28-Jan-2008 17:05:01] PHP Warning:  imagedestroy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 93
[28-Jan-2008 18:00:01] PHP Warning:  imagecreatefrompng(http://www.capeweather.com/images/lightning/wasp2.png) [<a href='function.imagecreatefrompng'>function.imagecreatefrompng</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 73
[28-Jan-2008 18:00:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 76
[28-Jan-2008 18:00:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 79
[28-Jan-2008 18:00:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 82
[28-Jan-2008 18:00:01] PHP Warning:  imagedestroy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 93

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP for WASP2 lightning/RADAR animation
« Reply #12 on: January 28, 2008, 10:09:49 PM »
Looks good Bob. Are you getting any images that are overlapping with the short cron increments? I had to back mine off to 10 minutes.

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline racenet

  • Forecaster
  • *****
  • Posts: 1306
    • NH Weather Data
Re: PHP for WASP2 lightning/RADAR animation
« Reply #13 on: January 28, 2008, 10:40:44 PM »
No, not that I noticed. Of course, haven't been watching it all the time either.  ;)

www.theamericanflagstore.com - The American Flag Store



www.nhweatherdata.com - NH Weather Data

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9277
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP for WASP2 lightning/RADAR animation
« Reply #14 on: January 28, 2008, 11:27:14 PM »
Heres the error log I received for the two times the script tried to grab a blank image.

Code: [Select]
[28-Jan-2008 17:05:01] PHP Warning:  imagecreatefrompng(http://www.capeweather.com/images/lightning/wasp2.png) [<a href='function.imagecreatefrompng'>function.imagecreatefrompng</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 73
[28-Jan-2008 17:05:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 76
[28-Jan-2008 17:05:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 79
[28-Jan-2008 17:05:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 82
[28-Jan-2008 17:05:01] PHP Warning:  imagedestroy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 93
[28-Jan-2008 18:00:01] PHP Warning:  imagecreatefrompng(http://www.capeweather.com/images/lightning/wasp2.png) [<a href='function.imagecreatefrompng'>function.imagecreatefrompng</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 73
[28-Jan-2008 18:00:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 76
[28-Jan-2008 18:00:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 79
[28-Jan-2008 18:00:01] PHP Warning:  imagecopy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 82
[28-Jan-2008 18:00:01] PHP Warning:  imagedestroy(): supplied argument is not a valid Image resource in /home/capeweat/public_html/testdirectory/wasp2/Wasp2Animator.php on line 93

Chris,
You may have to put (in a php.ini file in your document root) the following:

allow_url_fopen = on
allow_url_include = on

Or.. you may have to use a relative path to the actual wasp2.png file instead of the http: access.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Curly

  • Forecaster
  • *****
  • Posts: 724
    • Michiana Weather
Re: PHP for WASP2 lightning/RADAR animation
« Reply #15 on: February 03, 2008, 06:37:37 AM »
snip...
Got PHP? Can you run cron jobs?

PHP - yes
Cron Jobs - limited

I'm looking for a way to do this.
My hoster allows one cron job to be run once a day. Cpanel and Crontabs are not available.
Without cpanel and cron tabs, is there a way to create a script to get the image every 10 minutes?

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #16 on: February 03, 2008, 10:30:24 AM »
Mchalllis has a way to run it, posted in the same thread over on weather-watch.com:

http://www.weather-watch.com/smf/index.php/topic,29408.msg234373.html#msg234373

Quote from: MCHALLIS
Schedule automatic timed updates: There are a few ways to do this, I use method 2
Method 1: If you already have weather-display software click on Control Panel | FTP & Connections | HTTP Download tab Click on #1,#2 or #3 setup button | switch on the button for "downloads on | enter your whateveryounamedthephpfile.php url in the box called "URL of file to be downloaded" | click "add to list" | check the tick that says "Tick if text file" | whateveryounamedthephpfile.txt in the box that says "Local filename to be downloaded" | click "add to list" | click "download every 5 minutes" | click "save now" | click OK

Method 2: Schedule a server cron job to run this php file every 5 minutes.
Example using crontab -e: (first change /path/to/ to your server path)
*/5 * * * * php /path/to/whateveryounamedthephpfile.php 2>&1 > /dev/null
Simple guide to crontab usage at www.crontabrocks.org

Method 3: Use System scheduler to ping the URL http://www.yourwebsite.com/whateveryounamedthephpfile.php every 5 minutes
http://www.splinterware.com/products/wincron.htm

jwyman

  • Guest
Re: PHP for WASP2 lightning/RADAR animation
« Reply #17 on: June 30, 2008, 05:05:41 PM »
Hey SLO,
   I just downloaded the script and have it running on my ISP server. One thing, the lowest interval I can go is 15 minutes. what recommendation do you have for WASP upload times?

Jim

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #18 on: June 30, 2008, 06:47:27 PM »
Hey SLO,
   I just downloaded the script and have it running on my ISP server. One thing, the lowest interval I can go is 15 minutes. what recommendation do you have for WASP upload times?

Jim

My script is not made to sense that the image is in the middle of an upload so sometimes you might get black frames. (I think there's an enhanced version out there that fixes that.)

So, make your upload an even divisor of the 15 minutes, and then offset the upload and cron times by about half that.

jwyman

  • Guest
Re: PHP for WASP2 lightning/RADAR animation
« Reply #19 on: June 30, 2008, 07:10:30 PM »
Sry for the confustion. The lowest cron interval they will allow is 15 mins so everything is dependant on that...

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #20 on: June 30, 2008, 08:45:40 PM »
Sry for the confustion. The lowest cron interval they will allow is 15 mins so everything is dependant on that...

I understood that. I was trying to optimize your regular WASP2 page uploads to keep them timely, while accommodating your cron job limitation. WASP2 is going to get strike data almost as it happens. 5 minute uploads would keep your static page fairly current, while every third upload (5 minutes x 3 times = 15 minutes), you'll get a frame for the animation. 

jwyman

  • Guest
Re: PHP for WASP2 lightning/RADAR animation
« Reply #21 on: July 01, 2008, 08:17:44 AM »
Thank SLO!

My cron job is set up for 15 minutes but it doens't appear to be running on it's own. If I go to my server Control Panel and manually run the job, it works. Strange.... ](*,) ](*,) ](*,) It says it's there (the cron job) and that the location is ok.... But I have to manuaklly run it from the CP to make it work

Jim


Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP for WASP2 lightning/RADAR animation
« Reply #22 on: July 01, 2008, 12:29:54 PM »
Thank SLO!

You're welcome!

Quote
But I have to manually run it from the CP to make it work


Kinda defeats the purpose of Cron, eh?

You could run Windows Scheduler locally and have it hit the script on your server as often as you want. :)

jwyman

  • Guest
Re: PHP for WASP2 lightning/RADAR animation
« Reply #23 on: July 01, 2008, 02:53:41 PM »
Ah!!!! I found the problem... It turned out that the location for the image was NOT FOUND. I changed it to a relative path versus the absolute path. The cron job likes that much better! Still doing the 15 minute interval. Here's the resultant image...



Yeah baby Yeah!  \:D/ \:D/ \:D/

Jim

jwyman

  • Guest
Re: PHP for WASP2 lightning/RADAR animation
« Reply #24 on: July 03, 2008, 07:09:21 PM »
All,
  modified the script to include distance and bearing to the storm.... You can check it out at www.espwxctr.com/nexstorm.php. Let me know if this is something you want SLO.....

Jim

 

anything