Author Topic: PHP Space Weather Script  (Read 14121 times)

0 Members and 1 Guest are viewing this topic.

Offline tshattuck

  • Forecaster
  • *****
  • Posts: 337
    • Your Local Weather - Clay, NY
PHP Space Weather Script
« on: April 14, 2013, 08:08:49 PM »
Hello:
My space weather page http://www.yourlocalweather-clay-ny.com/wxspace.php is not displaying the 3-day Solar-Geophysical Forecast. I have checked the file permissions they appear to be okay. What do I need to correct to get this working?
Thanks
Tom
« Last Edit: April 14, 2013, 08:10:22 PM by tshattuck »

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP Space Weather Script
« Reply #1 on: April 14, 2013, 09:46:02 PM »
I'd posted this on Weather-Watch.com forum in Nov, 2012 -- should work for you:

Beginning code:
Code: [Select]
$Version        = 'V 1.2 24-Nov-2012';
$cacheName      = 'spaceweather-current.txt';  // used to cache the file
$refetchSeconds = 1800; // # 1800 = 1/2 hour - refetch every nnnn seconds (600=5 minutes)
$SPACE_URL      = 'http://www.swpc.noaa.gov/forecast.html';

// end of settings -------------------------------------------------

$Status = "<!-- space weather - $Version -->\n";
if(isset($_REQUEST['cache'])) {
$refetchSeconds = 1;
$Status .= "<!-- reloading cache -->\n";
}
  and replace the main_code() function with
Code: [Select]
function main_code() {

  global $cacheName,$Status;

   if (!$data = file_get_contents("$cacheName") ) {
      $string = gracefulerror('Error reading spaceweather current update data.');
      return $string;
   }
   
   preg_match('|<pre class="fcst">(.*)</pre>|Uis',$data,$matches);
   if(isset($matches[1])) {
   $rawfcst = trim($matches[1]);
   } else {
   $string = gracefulerror('Unable to find activity/forecast text');
   return $string;
   }
   
   $fcstparts = preg_split("|\n{2}|is",$rawfcst);  // split into parts
   
   $Status .= "<!-- fcstparts\n".print_r($fcstparts,true)." -->\n";
   
   preg_match('|Issued at (.*)|is',$fcstparts[0],$matches);
   
   $issued = "issued at ". trim($matches[1]);
   
   $solarfcst = preg_replace('|^\S+\s+(.*): |Uis',"<b>\\1</b><br/>",trim($fcstparts[2]));
   $geofcst = preg_replace('|^\S+\s+(.*): |Uis',"<b>\\1</b><br/>",trim($fcstparts[4]));
   
   $string = "$issued</h3><p>$solarfcst<br/><br/>$geofcst</p>";

   if ($string == '' || preg_match("|You don't have permission to access|i",$data)) {
     $string = '</h3><br />forecast not available';
   }

   // security feature
//   $string = strip_tags($string, '<p><h3><b><br>');

   return $string;

}

Hope this helps...

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 cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: PHP Space Weather Script
« Reply #2 on: April 14, 2013, 09:53:39 PM »
I use a different script......  http://hayskansasweather.com/wxspacewx.php

Here is my star page.... http://hayskansasweather.com/wxastro5.php
« Last Edit: April 14, 2013, 09:55:10 PM by hayskswx »




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline tshattuck

  • Forecaster
  • *****
  • Posts: 337
    • Your Local Weather - Clay, NY
Re: PHP Space Weather Script
« Reply #3 on: April 15, 2013, 06:10:43 PM »
Ken:
I copied your code into my web page http://www.yourlocalweather-clay-ny.com/wxspace.php but I am getting an error message can't find the text file. The file is on my website with permissions granted. Not sure why this is not working. I am also getting 14 HTML errors. Please take a look at and let me know what I need to correct.
Thanks

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP Space Weather Script
« Reply #4 on: April 15, 2013, 08:07:33 PM »
Hi Tom,
Copy your wxspace.php page to wxspace.txt and post it here.. I'll take a look.

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 tshattuck

  • Forecaster
  • *****
  • Posts: 337
    • Your Local Weather - Clay, NY
Re: PHP Space Weather Script
« Reply #5 on: April 15, 2013, 08:43:11 PM »
Ken:
I have saved the file as a .txt and have attached as you requested. Hopefully you can spot what is wrong.
Thanks for the quick reply.

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP Space Weather Script
« Reply #6 on: April 15, 2013, 08:58:53 PM »
I think you'd only updated the function.. the wrong URL was still being used.

Try the attached, then run wxspace.php?cache to refresh the cache file.

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 tshattuck

  • Forecaster
  • *****
  • Posts: 337
    • Your Local Weather - Clay, NY
Re: PHP Space Weather Script
« Reply #7 on: April 15, 2013, 09:19:34 PM »
Ken:
I missed the URL.
The web page is working!  :grin:
I need to get a book on PHP programming, is there one you recommend?
Thanks again for all your support, it is much appreciated.

Offline tshattuck

  • Forecaster
  • *****
  • Posts: 337
    • Your Local Weather - Clay, NY
Re: PHP Space Weather Script
« Reply #8 on: April 15, 2013, 09:24:09 PM »
Ryan:
Nice web page. I may consider using in the future.
Thanks for the info.

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: PHP Space Weather Script
« Reply #9 on: April 15, 2013, 10:54:29 PM »
Ryan:
Nice web page. I may consider using in the future.
Thanks for the info.

Just let me know and I will share it. :grin:




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline kc2kzz

  • Member
  • *
  • Posts: 39
    • Solitude Village Weather
Re: PHP Space Weather Script
« Reply #10 on: April 16, 2013, 08:31:31 AM »
Please do, I would like to add that to my page as well.    \:D/

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: PHP Space Weather Script
« Reply #11 on: April 16, 2013, 12:53:01 PM »
Attached is the Space and Star pages. If you have any images that are not appearing just name them and I will post it. You will have to get your city star chart.There is a link to go to a site to get it.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 558
    • Up Country Maui Weather
Re: PHP Space Weather Script
« Reply #12 on: April 16, 2013, 03:51:39 PM »
Hi Ryan,

Your script for this page looks really good.  I took a look at the script and noticed that I need to have sunspots30g.php included.  Where do I find this part?

Will try to get both of your scripts working at my site as time permits.

I have a 10" Newtonian that I need to set up and get it up to do some viewing of the night skies again.

Looking for the star chart that is listed on the site for a chart.  Hawaii is not listed nor the long/lat works.  Can I use this chart from this site http://www.ifa.hawaii.edu/publications/starcharts/ or is there another site that might work?

Thank you for sharing them.

--Stan Y.
   Maui, Hawaii
« Last Edit: April 16, 2013, 04:29:50 PM by Silversword »
Stan Y. - KH6HHG - Maui, Hawaii
 --- Blitzortung ID: 993
 --- FlightRadar24 ID: F-PHOG1

WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
Webcam: Axis 211

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: PHP Space Weather Script
« Reply #13 on: April 16, 2013, 04:31:22 PM »
Is this it? Not sure if that chart will work. I will look around.
« Last Edit: April 16, 2013, 04:48:02 PM by hayskswx »




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 558
    • Up Country Maui Weather
Re: PHP Space Weather Script
« Reply #14 on: April 16, 2013, 05:26:11 PM »
Hi Ryan,

Thanks for the reply.

It should be the file that would work with the script.

Okay on the chart.  Guess that we are too far removed to included with the rest of the mainland.

Thanks for all and hope that a chart can be found that is usable for the Star page.

--Stan Y.
  Maui, Hawaii
Stan Y. - KH6HHG - Maui, Hawaii
 --- Blitzortung ID: 993
 --- FlightRadar24 ID: F-PHOG1

WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
Webcam: Axis 211

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: PHP Space Weather Script
« Reply #15 on: April 17, 2013, 03:46:25 PM »
I got my star chart from here http://cleardarksky.com/csk/  .  I see that you can email someone and he will make one for you. Thats an option.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 558
    • Up Country Maui Weather
Re: PHP Space Weather Script
« Reply #16 on: April 18, 2013, 01:34:11 AM »
Hi Ryan,

Thanks for the info and have written for a chart request for my location.  Will let you know the out come.

--Stan Y.
  Maui, Hawaii
Stan Y. - KH6HHG - Maui, Hawaii
 --- Blitzortung ID: 993
 --- FlightRadar24 ID: F-PHOG1

WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
Webcam: Axis 211

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 558
    • Up Country Maui Weather
Re: PHP Space Weather Script
« Reply #17 on: April 18, 2013, 12:27:43 PM »
Hi Ryan,

Got a response from Attilla Danko:

"I'd like to create clear sky charts for Hawaii, but I'm sorry to say that I can not.

I can only get the astronomy specific forecast data for north america."

-ad

So looks like I will need to find another source for a chart that can work with this script.

Thanks for any suggestions.

--Stan Y.
   Maui, Hawaii
Stan Y. - KH6HHG - Maui, Hawaii
 --- Blitzortung ID: 993
 --- FlightRadar24 ID: F-PHOG1

WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
Webcam: Axis 211

Offline Taistealaiche

  • Member
  • *
  • Posts: 15
Re: PHP Space Weather Script
« Reply #18 on: April 27, 2014, 03:25:41 PM »
I think you'd only updated the function.. the wrong URL was still being used.

Try the attached, then run wxspace.php?cache to refresh the cache file.

Best regards,
Ken
Ken, this is what I get after having updated the code as you've posted:

3-day Solar-Geophysical Forecast Space Weather Forecast Unavailable
Error reading spaceweather current update data.

Update: Solved by changing file permissions.
« Last Edit: April 27, 2014, 07:27:31 PM by Taistealaiche »

Offline kered

  • Senior Member
  • **
  • Posts: 64
    • Laracha-Meteo Multilingual Website with PHP & AJAX
Re: PHP Space Weather Script
« Reply #19 on: December 15, 2014, 03:05:52 AM »
I see the wxspace.php has stopped working due to revamp of the http://www.swpc.noaa.gov/pmap/index.html site where the images come from.

regards
Derek
.     Updated every 15 minutes                                            Updated every 5 seconds


If its not broke don't try to fix it.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: PHP Space Weather Script
« Reply #20 on: December 15, 2014, 04:36:27 AM »
I see the wxspace.php has stopped working due to revamp of the http://www.swpc.noaa.gov/pmap/index.html site where the images come from.

regards
Derek
Using the scripts Stand-alone or in Saratoga-template, go to http://www.weather-watch.com/smf/index.php/topic,42356.msg497088.html#msg497088 were you can find the updated scripts.

Using the Leuven-template get your update at: http://leuven-template.eu/problems.php?lang=en were you can find the latest updates.

Wim
« Last Edit: December 15, 2014, 04:45:09 AM by wvdkuil »

Offline kered

  • Senior Member
  • **
  • Posts: 64
    • Laracha-Meteo Multilingual Website with PHP & AJAX
Re: PHP Space Weather Script
« Reply #21 on: December 15, 2014, 03:34:54 PM »
Thanks for that, was just on my way out when i noticed it was not working and didn't have time to look for a fix, i'm just in so we'll get on it

thanks again
Regards
Derek
.     Updated every 15 minutes                                            Updated every 5 seconds


If its not broke don't try to fix it.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: PHP Space Weather Script
« Reply #22 on: April 08, 2017, 03:14:00 PM »
Just a reminder that the 'kiosk' movies that 'wxspacewx.php' uses are being phased out this month by the SDO.  The movies are displaying this message:
The kiosk product will be discontinued on April 20, 2017. We are launching a new product called SDO Dashboard located here: https://sdo.gsfc.nasa.gov/data/dashboard

I've located what are now 3 new mv4 movies that are in production and replaced the kiosk movies with them.  I've added modal text copied from the SDO that explains the derivation and significance of the movies.  The movie is selectable via a setting, and the modal text can be turned off, or on.

This script uses Ken True's switch '$useHTML5 = true;' to display the HTML5 movies, and the script currently doesn't validate.  It just throws this error.

I've made some other modifications to the script over the years that may or may not be to your liking, but they're not too major.  You can download the script here.  You can see the script without the modal text here.

The recurring jpgraph error is annoying, but I'm not sure how to fix it...may have to do with 'sunspots30G.php'?
 
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline smokie

  • Senior Member
  • **
  • Posts: 51
    • Newquay Cornwall. UK
Re: PHP Space Weather Script
« Reply #23 on: April 09, 2017, 02:18:17 PM »
Just a reminder that the 'kiosk' movies that 'wxspacewx.php' uses are being phased out this month by the SDO.  The movies are displaying this message:
The kiosk product will be discontinued on April 20, 2017. We are launching a new product called SDO Dashboard located here: https://sdo.gsfc.nasa.gov/data/dashboard

........

The recurring jpgraph error is annoying, but I'm not sure how to fix it...may have to do with 'sunspots30G.php'?

gwwilk

I updated the sunspot 30 day graph script, you have an old copy as it displays garbage text on axis not dates, download here http://www.newquayweather.com/downloads.php this should fix the graph, make sure the script is in you wxgraphs dir and you have jpgraphs installed. Change paths to match your site

I have to check the other scripts still work as they may need updating to.

phil
Newquay, Cornwall.UK  > WS2300 Operational since May 2007. New home from 6/4/08 www.newquayweather.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: PHP Space Weather Script
« Reply #24 on: April 09, 2017, 06:23:12 PM »

gwwilk

I updated the sunspot 30 day graph script, you have an old copy as it displays garbage text on axis not dates, download here http://www.newquayweather.com/downloads.php this should fix the graph, make sure the script is in you wxgraphs dir and you have jpgraphs installed. Change paths to match your site

I have to check the other scripts still work as they may need updating to.

phil

I appreciate the prompt reply, Phil, as well as the fine script.  It took quite a lot of fiddling, but I finally got the graph working after hard coding most of the paths.

  The problem that confused me after that was that I was still getting a 'JPGraph Error: Headers Already Sent'.  I finally ended up writing the graph to a file with
Code: [Select]
$graph->Stroke("sunspots30day.jpg"); in sunspots30day.php. This is the image referenced above, and this eliminated the error and thus allowed the script, wxspacewx.php to run. Once the cache has expired, an hour, it takes a number of seconds for my server to create the graph, but create it does!

Thanks again, Phil, for the good work! =D&gt;
Regards, Jerry Wilkins
gwwilk@gmail.com