Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

Little day/night chart

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: An Alternative Little day/night chart

Post by beteljuice »

An Alternative
The beteljuice has a great mistrust of (google) APIs and 'the cloud' etc. prefering to have some degree of control over what happens, and also reducing global internet traffic.

So here's a beteljuice plaything (not quite as neatly drawn) and with a different slant (or two) on display.

EDIT: V2.0 Incorporating drawing improvements / suggestions by Mark.
EDIT: V3.0 Incorporating logic fix by Mark Crossley.
EDIT: V3.1 hours markers option added

Image Midday (Civil) is 'North' and a 24 hour 'clock' hand shows 'now' time.
Image Midday (Civil) is 'North' and a 24 hour 'clock' hand shows 'now' time with hours markers.
Image 'Heavens' rotate East to West through North with a 'now' marker @ North.

As you can see Civil, Nautical and Astronomical twilights are shown.

Practically everything is configurable and most things can be 'posted' on-the-fly.

You MUST be running PHP 5+
If 'safe_mode' exists it should be "off". (Maybe unimportant following tweaks - unproven)
If you are unsure of the above, unzip and run the following file in your webspace:
fdebug.zip
If it suggests that safe_mode is enabled, check your web space control panel / settings and see if you can turn it "off", else contact your support.
If they say "Oh no can't do that its insecure", tell them its caused so much problems that it is depreciated in ver 5.3 and doesn't even exist in ver 5.4 ! - give them this link: http://uk.php.net/manual/en/features.safe-mode.php

GET / VIEW commented CODE

'Tis a beteljuice throwaway freebie ... enjoy or not as you wish :lol:

Edit: Forgot to mention. It's a stand-alone and no weather software is required :o

Edit: Basic usage ...

Using a txt editor such as Notepad++ change the timezone to YOUR location:

Code: Select all

$time_locale = "Europe/London";  // set your timezone - see: http://php.net/manual/en/timezones.php
If you are not using saratoga / carterlake template(s) you won't have a Settings.php so you need to change the lat / long, this is MY location ;)

Code: Select all

//----------------------------------------------------------------------------\\
// SETTINGS: only customise if you have no "Settings.php"                     \\
//----------------------------------------------------------------------------\\
if (!@(include_once "Settings.php")) {
   $SITE['latitude']      = 52.512; // N+, S-
   $SITE['longitude']      = -2.096; // W-, E+
}
   
To use it in an html page just call it like you would any other graphic.
Using your file name ....

Code: Select all

<img src="heavens.php" alt="day / night chart" title="day / night chart" />
EDIT:
If you really must have a bit of JavaScript to update the image on the page, please be aware that the 'resolution' of the graphic (regardless of size) is 1 degree (values rounded) which equates to 4 minutes.
So it would be pointless to have a refresh rate of less than 2 min. ;)
You do not have the required permissions to view the files attached to this post.
Last edited by beteljuice on Wed 11 Sep 2013 10:44 am, edited 10 times in total.
Image
......................Imagine, what you will KNOW tomorrow !
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Little day/night chart

Post by gemini06720 »

mcrossley wrote:I picked this up from WD forum, some people on there were using the old depreciated Google chart API's and PHP to generate a little day/night graphic.
And, I picked up from you (you code modified to PHP), combined it with the code found/posted in the Weather-Watch forums and came up with this: :mrgreen:
Last edited by gemini06720 on Sun 09 Jun 2013 9:16 am, edited 1 time in total.
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

gemini06720 wrote:And, I picked up from you (you code modified to PHP), combined it with the code found/posted in the Weather-Watch forums and came up with this: :mrgreen:
That's the way to do it, code sharing helps everyone. ;)
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Little day/night chart

Post by beteljuice »

Just a thought ...
What happens if daylight is all (today) or dawn > dusk is all (today) ?
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

beteljuice wrote:Just a thought ...
What happens if daylight is all (today)
You get a yellow disk?
beteljuice wrote:or dawn > dusk is all (today) ?
There is no night sector - your version with astronomical twilight will not have any night sector in the UK around mid-summer.

If I'm understanding you right.
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: An Alternative Little day/night chart

Post by mcrossley »

beteljuice wrote: The beteljuice has a great mistrust of (google) APIs and 'the cloud' etc. prefering to have some degree of control over what happens, and also reducing global internet traffic.
Hi betejuice, I ran into a problem with the script. I do not have a 'Settings.php' file and this fails:

Code: Select all

if ((include_once "Settings.php") == 0) {
   $SITE['latitude' ]      = 52.512; // N+, S-
   $SITE['longitude']      = -2.096; // W-, E+
}
I changed it to

Code: Select all

if (!@(include_once "Settings.php")) {
   $SITE['latitude' ]      = 52.512; // N+, S-
   $SITE['longitude']      = -2.096; // W-, E+
}
and the script now runs

Edit: and shouldn't the output header be

Code: Select all

header('Content-Type: image/png');
My implementation: http://weather.wilmslowastro.com/images/sun_graphic.php
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Little day/night chart

Post by beteljuice »

No 'Settings' works for me, could this be due to 'safe' mode or someother variation of your php install ?

Edit: In line with response below ... the beteljuice did say "Safe mode should be off"
Edit: and shouldn't the output header be
:oops: See what you mean, I mixed up the header and the output, but it works :lol:
My code now corrected !

Obviously you can output what format you want BUT the line underneath must follow the same regime !
Last edited by beteljuice on Thu 21 Feb 2013 11:17 pm, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

Yep, safe mode was on, I managed to switch it off but I'd changed the code by then.
User avatar
jdc
Posts: 142
Joined: Tue 19 Jun 2012 8:51 pm
Weather Station: Davis VP2 : Instromet
Operating System: Win 10
Location: Portsoy,.
Contact:

Re: An Alternative Little day/night chart

Post by jdc »

beteljuice wrote: 'Tis a beteljuice throwaway freebie ... enjoy or not as you wish :lol:
I'm currently enjoying this. Thank you very much for 'throwing' it!
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Little day/night chart

Post by beteljuice »

@ jdc - Thanks for the feedback.

Nicely laid out / informative site :D
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

One 'improvement' I have made the beteljuices excellent code is to add some anti-aliasing (or simulate it).

As the GD sector drawing functions do not support anti-aliasing (even when it is turned on globally for the target image), internally I draw the graphic at 4x the linear size, then at the end resample back down to the 1/4 size required. The resampling creates the anti-aliasing effect for you.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Little day/night chart

Post by beteljuice »

Creep ... :lol:

The beteljuice was going to republish incorporating your changes (with credits), then I found this:

include('imageSmoothArc.php');

Please elucidate ....
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

Ah, I was going to use that plugin, it draws smooth sectors and arcs, but then when I looked into it further the author had completely changed the parameter meanings from the equivalent GD calls :( So the drawing angle is ant-clockwise instead of clockwise, so you have fiddle with the from/to angles to get it correct, the colour param takes an array rather than a integer colour - though the array can have 4 elements to support transparency.

http://www.ulrichmierendorff.com/softwa ... _arcs.html

I gave up and took the easy way out in the end - forgot to remove the include though!
Last edited by mcrossley on Sun 24 Feb 2013 8:23 pm, edited 1 time in total.
User avatar
PaulMy
Posts: 4355
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Little day/night chart

Post by PaulMy »

I have added Mark's original chart and that has been working fine. Just thought I should try beteljuice's version as well but I could not get it to work.

First troubleshooting was to check on safe mode, and with the great help from GoDaddy I wrote my first 2 programs in PHP :) so now safe mode is off.

I copied the beteljuice's code in notepad++, in SETTINGS changed the location to American/Toronto and entered my lat and lon in $SITE[ ]

Saved the file as sunrise-set_chart.php and upload to http://www.komokaweather.com/weather

However http://www.komokaweather.com/weather/su ... _chart.php results in error

Are there other settings or changes I need to do?

Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

That is the same error I was getting Paul - not sure if it is due to safe mode still being on or not (I thought mine was off, it was 'globally' but 'locally' it was on).

I changed the include once statements to get round it.
https://cumulus.hosiene.co.uk/viewtopic.p ... 532#p77532
Post Reply