Trixology
WeatherCat => WeatherCat Web Templates => Topic started by: mcrossley on August 20, 2016, 04:12:43 PM
-
I thought I'd start a new thread for the Sun Plot script as it was clogging up the Gauges thread....
You chaps may be interested in another little PHP script for your web pages I knocked up last week - Sun Plot.
You can see it in use on my home page (not much sun today :( ), and the download is here
(http://weather.wilmslowastro.com/downloads/sunplot.png)
It doesn't matter if you don't have a database that stores the sunshine data, you can use the plot just to show the Suns position as the day progresses and the relative day/night length and changes in Suns elevation. It's self contained, no other libraries etc. required.
You should be able to embed it in a HTML page just like a PHP page (so long as the server is running PHP obviously). Just using a standard <img> tag, like...
<img src="sunplot.php" alt="Sun Plot" width="X" height="Y">
Where X and Y are the width height you also specify in the php.
-
I almost did not dare to ask, but:
What about adding a time-line from 0 to 24 to the png?
:-X
A bit like this?
-
Ohh Yesss, Sir!
[tup]
-
Me too. I just downloaded version 1.1 but the timeline is not included. :-\
-
Just for reference to others:
Script is located at Marks Homepage:
http://weather.wilmslowastro.com/scripts.php
Examples:
http://weather.wilmslowastro.com/index.php
http://timberlakesutah.com/weather/
http://wetter.unterwurzacher.at/wetterwerte.html#sonne
Update on 24th of August:
http://www.eastdallasweather.com/wxastronomy.php
-
Me too. I just downloaded version 1.1 but the timeline is not included. :-\
It will be in version 1.2 I want to do some more testing before releasing it.
-
::)
Time Line color and font customizable.
:-*
:) :) :)
-
::)
Time Line color and font customizable.
:-*
:) :) :)
Well, they are if you edit the script ;)
It is black in the supplied script for both the ticks and numbers - but just change the RGB values of "$colHours". It doesn't draw a axis line, just tick marks down from the horizon.
It also uses a True Type font (arial.ttf by default), so you will need that font file on your web server somewhere - and don't forget to set the path/filename in the script. If it can't find the font you will get the tick marks but no numbers.
Version 1.2 now uploaded - go get it!
-
Time Line color and font customizable.
I think he just did that with an image editor. ;) But he can probably add it easily in the script. After all, coding is really just typing! [computer] [lol] Right now I don't see any 'echoing' in the script, but I'm sure he could 'write' the numbers in most any font, color, and size you'd like. I'd suggest that colors might need to be different depending on the background color. Colors don't show well on like-colored backgrounds. DOH!
I think "$colHours" must be in a later version? Don't see it in 1.0. Well, of course, flyboy! You need to type faster! Maybe using more than two fingers? [banghead]
But you proved my point about "coding"! [lol]
-
Version 1.2 now uploaded - go get it!
You are ... great.
;D
-
Done the trick with the font (using DINAlternateBold.otf as that is the font I use mainly in my website).
I really would like to donate some bucks to you - anywhere possible?
-
I saw you had used a custom font, it looks good.
I have a link for SteelSeries dontations (https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R3Y5CFQPA9J5W), you could use that if you like. Don't feel obliged, I do this stuff for my own entertainment as much as anything...
-
Thanks a lot for all your work! Stay tuned and share your scripts!
-
Reinhard's site is too beautiful not to visit at least once a week! Here's his <page (http://wetter.unterwurzacher.at/wetterwerte.html)> with the Sunplot (just below half way down the page depending on how big a window you may have). He has cleverly labeled the spot "Sonne"! ;)
-
:-[
:)
-
xair:
I forgot to say: Thank you for the flowers.
(http://images.clipartpanda.com/flowers-clipart-animated-happy-flower-clipart-1.jpg)
-
How do I point the script to where the fonts are installed on my Mac?
This is what I thought should work because the font is located in library/fonts (not my user library, and not the system library but the "local" library where Apple recommends any use can add or modify fonts.
$fontFile = $_SERVER['DOCUMENT_ROOT'] . '/Library/Fonts/arial.ttf';
-
Here is how I did it:
Uploaded the desired font file into my webspace in exact the same directory where the sunplot.php is doing its job. Then pointed to this file.
$fontFile = $_SERVER['DOCUMENT_ROOT'] . 'DINAlternateBold.otf';Be sure to type the font file name exactly into the script and avoid spaces in this name.
Hope this helps,
-
How do I point the script to where the fonts are installed on my Mac?
This is what I thought should work because the font is located in library/fonts (not my user library, and not the system library but the "local" library where Apple recommends any use can add or modify fonts.
$fontFile = $_SERVER['DOCUMENT_ROOT'] . '/Library/Fonts/arial.ttf';
Blic, the "$_SERVER['DOCUMENT_ROOT']" bit starts the path in your web server root folder (typically). If you want to use a file elsewhere on the system then try...
$fontFile = '/Library/Fonts/arial.ttf';[/quote]
-
Still no joy for me.
First, tried pointing at the font where it is on my Mac. That didn't work.
Next I uploaded the font to the same directory where sunplot.php resides on my site and used the following line in the script:
$fontFile = $_SERVER['DOCUMENT_ROOT'] . 'Arial.ttf';
I tried this as well:
$fontFile = $_SERVER['DOCUMENT_ROOT'] . 'arial.ttf';
Still not working.
I have verified the font is there and spelled correctly.
Any ideas about what I am missing?
-
John,
use a .otf font - just for trying and just a shot in the blue. I first uploaded a .woff font and it didn't work, either. You may use this one as test:
-
Thanks, but still nothing for me.
$fontFile = $_SERVER['DOCUMENT_ROOT'] . 'DINAlternateBold.otf';
The font and the script are in the same directory. This should work.
-
Another idea: Maybe this dierctory is NOT your web server root folder? In my case it is. Try duplicating the font file and put it to your root folder as well.
Or alternatively point to this in your case:
$fontFile = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/uploads/Weather/DINAlternateBold.otf';
-
Reinhard, you are genius. [cheer]
I am one of the few WeatherCatters using a WordPress site. In WordPress, all uploads go into a folder called uploads. On my site, I created a folder in uploads called Weather. All of my FTP for WeatherCat goes into the Weather folder. This is where sunplot.php and the font reside. I just needed to specify the full path name (Duh!!):
$fontFile = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/uploads/Weather/DINAlternateBold.otf';
Thank you for patiently prompting me along on this.
Danke!
-
[bounce]
-
Glad you got it sorted. The alternative is to drop the "$_SERVER['DOCUMENT_ROOT'] . " bit and just specify the full path to the file from the system drive root folder.
use a .otf font - just for trying and just a shot in the blue. I first uploaded a .woff font and it didn't work, either. You may use this one as test:
Yep, PHP GD will not work with .woff files, it requires a True Type format, either .ttf or .otf. Browsers understand .woff format bit not PHP.
-
Thanks for this script. I've been playing around with it and added it to my site just for grins:
http://www.eastdallasweather.com/wxastronomy.php
Alan
-
Hi Alan, you may want to play around with the colours a bit to get a better match with the rest of the page. Turning off the 'ground' may look better as well?
Anywho, nice to see it working for other people.
Now, can WeatherCat supply the sunshine data....?
-
Hi Alan, you may want to play around with the colours a bit to get a better match with the rest of the page. Turning off the 'ground' may look better as well?
Anywho, nice to see it working for other people.
Now, can WeatherCat supply the sunshine data....?
Thanks for the suggestion. Turning off ground looks better.
WC certainly has the data. I'd have to see what the Cumulus database looks like to do the insert, retrieval, etc.
Cheers,
Alan
-
Basically the plot just uses a 'realtime' table with a row inserted per minute (I keep a rolling 10 days of data in my realtime table), with a column 'IsSunny' which is set to 0 or 1 (no sun / sun). If you have something like that then the script should be easy to adapt to WC.
I also have as yet an unreleased version that reads a Blake-Larson sun detector log file. That has a line per sunshine 'event', with the start/end time of when the sun was shining.
-
Alan: I like it on your site.
Mark: WeatherCat tracks total sunshine hours so I know it's in the database somewhere.
-
Mark,
we are able to indicate sun shining now in SteelGauges, so the data for taht must be somewhere, or it is computed by the script somehow:
showSunshineLed : true, //Show 'sun shining now' LED on solar gauge
-
Reinhard, I believe the LED to display sun shining now on the SteelSereies Gauges is a calculation done by the Gauges software. There are two lines in the gauges.js where you can experiment with the parameters so you can tweak that LED to be more accurate depending on your specific location. But I assume that some kind of similar calculation exists in WeatherCat in order for the 'Cat to calculate total sunshine hours.
-
The script does do the calculation as not all the weather programs provide the "IsShining" data, so as the calculation is simple I do it on the fly.
-
The WeatherCat data should be more accurate as it is based on readings from the Solar Radiation sensor.
-
Well, the script uses the data supplied by WC too ;) The key is the percentage threshold, and any absolute cutoff value (the WMO uses 120 W/m2 as the minimum threshold required for sunshine - I think to maintain consistency in readings with the Campbell-Stokes recorders which need a minimum level to burn the card)
-
...so as the calculation is simple I do it on the fly...
:) [tup]
-
I have my threshold set much lower because the light wasn't turning on when it should have been in the late afternoon, so I just stared playing around until I got it to where I felt it was reasonable accurate compared to what I saw looking out the window.
-
compared to what I saw looking out the window.
HERETIC! BLASPHEMER!! I hope the Admins here take note of your lower moral behavior! [rockon] [rolleyes2]
-
Mark or Reinhard:
I noticed starting this morning, the sunplot.php display has gone missing from my website. I haven't changed anything in the file and have verified it is in the same directory where it has resided since 2016. The font is sitting in the same directory. It was all working fine yesterday. I'm out of ideas. Would you mind taking a look and see if you can see something?
Thanks.
Here is the code from the main section, and as I said, I have not touched this for years.
######################## User Editable Variable Section ############################
// Set your station time zone (valid PHP/MySQL TZ string)
$tz = 'America/Denver';
// We need the decimal latitude and longitude of the station to calc sun position
$LAT = 40.1; // +ve North
$LON = -111.2; // +ve East
// Realtime database table name
$realtimeTableName = 'realtime';
// Path to TTF font - only required for Hour markers
// $fontFile = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/uploads/Weather/PTSans.ttc';
$fontFile = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/uploads/Weather/Arial_Bold.ttf';
// plot options - note these can be overridden by posted parameters
$sizeH = 425; // Horizontal image size
$sizeV = 150; // Vertical image size
$showGround = false; // Show the ground as shaded
$showSunshine = false; // Plot sunshine from your MySQL database
$transparent = true; // Make the image background transparent
$showTwilight = false; // Plot civil/nautical/astro twilight
$showHours = true; // Plot the hours 0-24 along the horizon axis
###################### END: User Editable Variable Section #########################
-
I guess it's moot since the line is simply a comment... Is the suffix "ttc" correct for the "PTSans" font? Perhaps a typo in your post? [blush]
Other WAGS:
I assume the PHP files are still in the correct directories at your web space and locally.
Do you know what version of PHP the scripts used? Did your host recently change the default versions?
-
When I load your page, I'm getting an error 404 (file not found) for https://timberlakesutah.com/wp-content/uploads/Weather/sunplot.php
-
Thanks for checking Mark. I can't figure it out. That file is definitely in that directory, with Permissions 644. I can see it in CPanel and in my FTP client. I deleted it, downloaded from your website again, edited the script, uploaded it to that directory, and I still get a 404 error. That is the only PHP file in that directory. All the other files are jpg, png, or html, and each of them will open up, but when I try to open the sunplot in a browser tab it can't find it. I even got desperate and tried clearing cache and rebooting. Hahaha. It's got something to do with looking for a PHP file that's somehow different that everything else it can find. I'll keep thinking, but I'm just about out of ideas.
-
Hi Blick - very strange, indeed. I just compared your posted "User Editable Variable Section" and it looks exact as mine (except Time Zone and Lat Lon). My script is running on my main site (wetter.unterwurzacher.at) with this code:
<span style="text-align:center;">
<h2>Aktuelle Sonnenposition<br><?php echo date($dateFormat,time())?></h2>
<br>
</span>
<img src="https://wetter.unterwurzacher.at/meteo/scripts/sunplot.php" width="95%" alt="Sonnenplot" title="Aktuelle Sonnenposition">
<br>
<span style="text-align:center;">Script von <a href="http://weather.wilmslowastro.com/scripts.php">Mark Crossley</a></span>
The directory where I am hosting the script has permission 775, the script itself 640, maybe it is worth trying these permissions. Sorry, but this is all I can say to this mystery. Hope you can solve the puzzle...
-
Thanks Reinhard, still no joy. :(
Oh well, it was great whilst it lasted.
-
To come back to xair's mention: Has anything changed with the ISP you are using? Maybe the host is not executing PHP's any more? ???
-
Reinhard:
You are a genius! Mystery solved. Your question triggered a moment of illumination in my mind.
I tried out some firewall software and I didn't like it because it was blocking legitimate users from my site. I deleted it. I did not know that before I deleted it, it added an .htaccess file to my uploads directory, blocking all php files from executing. Deleting that file restored the sunplot to it's original function.
Once again you have saved the day.
I love this little script Mark wrote and am glad I can still use it.
Thank you, mate!
-
Blick: Glad the amazing script is back online on your site! [tup]
Cheers,
-
Thank you! I just sent an hour clicking on every link your site. You have great taste in color and graphic design. Have a great day.
Gruß, Blick
-
Thanks alot visiting my site - and thanks for your honorable words, Sir.
[cheers1]