Page 1 of 13

CloudBase script for Cumulus Ver CU1.5

Posted: Wed 07 Aug 2013 10:54 am
by BCJKiwi
18 November 2013
VERSION CU1.5 - see Edits below for update information

23rd Sep 2013
VERSION CU1.4d - see Edits below for update information
This is a completely new script for Cumulus and only Cumulus.
It requires Cumulus 1.9.3 (ver b1059) or later (changed in ver CU1.2).
It is adapted directly from the original Ver2.1 script by Rainer Finkeldeh (rainer@bashewa.com).
All changes and adaptations have been made without reference to any other cloud base script.
It does not, to the best of my knowledge, contain any code from any other cloud base script (apart, of course, from Rainer's original).
It retains all the original credits, copyrights and GNU licence etc.
It has been some 3 months in use with subsequent on-going refinements and testing.
It is offered for use, as is, without any commitment of support but I am open to constructive suggestions and will assist as and when I have the time and inclination.

It utilises a specific tag file for this script delivering only the required tags in the format to suit the script.
It will work with the Saratoga template system or any other website/page provided the server supports a recent version of PHP with GD2 graphics (i.e. pretty much any Apache based webserver).
If using the Saratoga template system, translation is handled as it is for other parts of your website. You will need to add the relevant translation blocks (from samples in cloudbaseCUlang.txt) to suit the languages your site supports.
If not using the Saratoga template system, you may want to check out the HowTo and the ...WinDir.txt and ...lang.txt files which provide for alternative translation methods.

Edit 1, 8th Aug 2013 - have updated the HowTo as I had left out the requirement for the folder ./cache/ in which the metar files are saved.
zip file updated.
(12 downloads)

Edit 2, 8th Aug 2013 - It seems I may not have been clear on the Saratoga translations.
"If using the Saratoga template system, translation is handled as it is for other parts of your website."
This does mean you will have to add the translation blocks for the languages you have set up in Saratoga from the attached cloudbaseCUlang.txt file. Please let me know of additional translations and any errors so this file may be properly maintained.
I have updated some of the translations in the zip package.
(6 downloads)

Edit 3, 9th Aug 2013 - added missing Humidity data! Now Ver CU1.1
If you have already installed Ver CU1.0, you need only replace the cloudbaseCUT.txt file in Cumulus\web, and, the cloudbaseCU.php file on your website.
(14 downloads)

Edit 4, 15th Aug 2013 Now Version CU1.2
NEW cloudbaseCU.php
NEW cloudbaseCUT.txt
Further general code refinements
Updated Timezone handling (only affected non-Saratoga users with server in different timezone from station).
Fixed Windsock (was not changing).
Reworked Latitude handling to provide for Cumulus ver 1.9.3 (b1059) and later.
Improved spacing of caption & Temp, Humidity & Baro text - Thanks Gluepack.
Added text color options - suggested by Beau.
(7 full and 5 update downloads)

Edit 5 25th Aug 2013 Now Version CU1.3
NEW cloudbaseCU.php
NEW cloudbaseCUT.txt
Further general code refinements including
Better layout, bug fix and instructions in the script to handle caption and Wind direction translations for users with $translate = false;
Change windir delivery by Cumulus from compass to degrees to provide for windir translation handling in script

There are now two attachments;
1. For new users:- cloudbaseCU13_Full.zip (updated default configuration 26 Aug 2013 - 6 downloads)
complete verCU1.3 package includes complete system with instructions, script, data file, images, and sample language files.
2. for users of ver 1.0, 1.1 or 1.2:- cloudbaseCU13_Upd.zip (updated default configuration 26 Aug 2013 - 5 downloads)
update package including all files except the images

Edit 6 27th Aug 2013 Now Version CU1.4
NEW cloudbaseCU.php
Updates to Metar decoding to cater for ICAO, and for strings which are not used but may contain substrings which are used for cloud and precipitation.
There are two attachments;
1. For new users:- cloudbaseCU14a_Full.zip (4 more downloads)
complete package includes complete system with instructions, script, data file, images, and sample language files.
2. for users of ver 1.0, 1.1, 1.2 or 1.3:- cloudbaseCU14a_Upd.zip (8 more downloads)
update package including all files except the images.

May I suggest , if you don't already use it or have a tool that does the same thing, that you consider downloading diffmerge as it makes updating existing files with changes from another file very easy.

Edit 7 31st August 2013 ver CU14a
Minor change to re-instate default English windir translations - only relevant when $translate = false; So, unless you are having trouble with the wrong language displaying for Wind direction and don't want to edit the script, no need to download 1.4a to replace 1.4
Also a bit more info in ?html=1
Minor revisions to HowTo file.

Edit 8 1st September 2013 ver CU14b
Minor change to correct line 353 - changes $mostlycloudyCap = 'Scattered'; to $mostlycloudyCap = 'Mostly Cloudy';
You may edit the script directly, or download Update 1.4b to apply this fix.
(4 downloads full, 1 download upd)

Edit 9 9th September 2013 Ver CU14c
Minor bugfix for wxrain test; < 0.1 should be < 0.01 @ line 436 - line numbers may vary with different versions!- only affects non-metric systems.
You may edit the 1.4b script directly, or download Update 1.4c to apply this fix.

Edit 10 23rd September 2013 Ver CU14d
Further bugfix for wxrain test - wrong version posted in ver CU14c - Thanks to Beau (n9mfk) for detailing this issue.
Download Update 1.4d to apply this fix to existing working ver CU1.4c systems.

Edit 11 - 18 November 2013 Ver CU 1.5
Numerous minor refinements
update from version 1.4c or d else download Full package.

Edit 12 - 19 Nov 2013
Added missing ...HowTo to both _Full and _Upd packages plus made available separately for those who are new to the script.

Edit 23 August 2015
NOTE:-
Info just come to light of a bug affecting cloudbaseCU v1.5 for some MX users of ver3.0.0 build 3008 and below;
The users affected are all those in the Northern Hemisphere and those in the Southern hemisphere who have a single digit latitude.
This has been around since this script was first developed and only just now been fully identified - thanks to gluepack and Steve.
The fix is discussed here https://cumulus.hosiene.co.uk/viewtopic.p ... 03#p110303 and in the few posts above along with the easiest solution - a replacement tag file. Steve has changed the code to address this in later builds of MX.

Edit 26 May 2016
If using the Metar option, $getmetar = true; then line 1126 in cloudbaseCU.php should be changed;
from $rawfile = 'http://weather.noaa.gov/pub/data/observ ... /stations/' . $icao . '.TXT';
to $rawfile = 'http://tgftp.nws.noaa.gov/data/observat ... /stations/' . $icao . '.TXT';


Enjoy ;)

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Wed 07 Aug 2013 7:26 pm
by n9mfk
hi BCJKiwi,
have you thought on inter-grading cutags.php for people that wet to use it with ken's template?
Beau

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Wed 07 Aug 2013 8:42 pm
by BCJKiwi
Beau
My personal preference is to create self-contained scripts when they may be used in multiple systems.
i.e. if the script will only work in Saratoga - I will use/extend the CUtags file but if able to be used in other places, then a simple very small file which is standard for all users is my preferred method.
Apart from anything else this means there is a single set of code to maintain.

As this script can be used almost anywhere (not just in a weather website!) it uses its own data file.

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Wed 07 Aug 2013 9:17 pm
by Werk_AG
Thanks for your work.

It's working fine on my saratoga template.

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Thu 08 Aug 2013 11:23 am
by gluepack
Yes, thanks for that, I think. That's what I said about the last one I used and it got dumped pretty quick.

It worked first time, although I was a bit disappointed that there was no cloud showing, despite the fact I could count a thousand out there, but making alwaysShowCloud true displayed some. Just hope it is valid.

Now, I just have to find somewhere to put it. And, it is a pity that these things are always so small, particularly the added data text.

Thanks again, I always appreciate someone doing the leg work.

oh, the humidity is showing (incorrectly) as 0% but then there doesn't appear to be a parameter for it in the txt file

edited to add:
I've added a bit of code to suit my own purposes, in as much as Cumulus reports height in ft and I would rather see in m.
It may not suit the picky but, if you want to use it, you're welcome or modify to your heart's content...

Have added

Code: Select all

$heightUnit         = false;          // true = use the file unit otherwise swap i.e. ft converted to m or m converted to ft
at the end of the variables and...

Code: Select all

if ($heightUnit) {
	} else {
	if ($uomAlt === "m") {
		$cldhgtCU = $cldhgtCU * 3.28084;
		$uomAlt = "ft";
	} else {
		$cldhgtCU = $cldhgtCU * 0.3048;
		$uomAlt = "m";
		}
	}
immediately following...

Code: Select all

// determine cloud height and temp
Lol, on reflection, did I miss a setting in Cumulus?

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Thu 08 Aug 2013 4:39 pm
by steve
gluepack wrote:Lol, on reflection, did I miss a setting in Cumulus?
If you mean a setting to display cloud base in metres, it's on the display settings screen.

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Thu 08 Aug 2013 6:33 pm
by gluepack
Of course, you're right. Oh well, it exercised the brain for a few seconds writing the code. A moot point I guess but I would have thought it would have been better with all the other imperial/metric settings in Station Settings. There is enough room there, if you reduced the space between the others.

Re: CloudBase script for Cumulus Ver CU1.0

Posted: Thu 08 Aug 2013 9:11 pm
by BCJKiwi
Gluepack
Thanks for noting the Humidity omission.
I don't usually run with all the variables showing so never noticed it was missing!
If you don't show all the caption data you will find the text size adjusts to fill the available space.
The reason I don't have a lot of variables displayed in the cloudbase graphic is that as I use the Saratoga template and most of the data is displayed elsewhere on the dashboard.
As to where to put it - I replaced the outlook panel with the cloudbase graphic as the outlook is covered by the WU forecast below.
Had to adjust that column width slightly.

Steve
Thanks for answering the Q re cloud height units.
The whole concept of this script is to fully utilise the rich flexibility of Cumulus tags to eliminate unnecessary code in the script.
As a result this script is significantly smaller than the original as using the data directly available from Cumulus means it does not need to do as much work as the original.

zip Package updated in first post.

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Thu 08 Aug 2013 10:07 pm
by gluepack
Thanks.

I ran up (well purloined components of) a quick dissertation on clouds and incorporated it into that...
http://jerbils.info/saratoga/wxcloudbase.php


btw...
you need only replace ..... the cloudbaseCU.php file on your website.
I think you are oversimplifying it, there are parameters to change, at least.

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Thu 08 Aug 2013 10:31 pm
by BCJKiwi
Gluepack,
Looks good, the graphic is not as sharp but does work better than I expected when enlarged - it looks bad if reduced.

Did you change the cloudbaseCUT.txt file? - your season is not correct as the latitude is N 43° 14' 15". The tag is <#latitude dp=0> which should deliver the number 43. It's only purpose is to determine N or S hemisphere. The script will not work properly with the format you have but I guess it could be changed to accommodate it if the different format is caused by something else.

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Thu 08 Aug 2013 10:38 pm
by gluepack
I haven't touched the ...CUT.txt file.

You can determine season from that image? lol

Content of server txt file...
19.2 17.5 0.0 2 1018.6 90 0.0 N 207 C mm hPa km/h m N&nbsp;43&deg;&nbsp;14'&nbsp;15" 1 0 0.0 0.0

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Thu 08 Aug 2013 11:15 pm
by BCJKiwi
No, but from cloudbaseCU.php?html=1
The data file should read
19.2 17.5 0.0 2 1018.6 90 0.0 N 207 C mm hPa km/h m 43 1 0 0.0 0.0
not
19.2 17.5 0.0 2 1018.6 90 0.0 N 207 C mm hPa km/h m N&nbsp;43&deg;&nbsp;14'&nbsp;15" 1 0 0.0 0.0
mine reads
15.8 11.8 0.0 8 1018.73 77 6 E 498 C mm hPa km/h m -37 1 1 1528 0.0 0.0
as we are in the southern hemisphere.
wiki says <#latitude dp=5> gives "59.24250", the tag in use is <#latitude dp=0>
This feature has been in effect since b1076 at least b1070 and we are now at b1082. However I see you are still running b1059 - maybe its time to update?

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Fri 09 Aug 2013 1:06 am
by PaulMy
I have it working http://www.komokaweather.com/weather/cl ... php?html=1 and all seems ok except that in the .php?html=1 view it displays:
"Date/Time : Thu, 08 Aug 2013 17:51:07 (day)
TZ : America/Phoenix (GMT-7 hours)"

where it should be:
Date/Time : Thu, 08 Aug 2013 20:51:07 (day)
TZ : America/Toronto (GMT-4 hours)

I have the settings in cloudbase.php as: "$tz = 'America/Toronto'; // change to suit your local time zone" which is the same as I have for the Saratoga templates Settings.

Thanks for your work and sharing the script,
Paul

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Fri 09 Aug 2013 2:12 am
by BCJKiwi
Where is the server?
The time appears to be taken from the server.

This is how it worked in the original, I may have to look at how to cater for that difference (assuming the server is in Phoenix!).

Re: CloudBase script for Cumulus Ver CU1.1

Posted: Fri 09 Aug 2013 3:32 am
by PaulMy
Yes you are right, I am with Godaddy and I think their server is in Arizona.

Thanks,
Paul