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

Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)

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

Moderator: daj

Post Reply
User avatar
saratogaWX
Posts: 1238
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)

Post by saratogaWX »

I've added some code to the CU-defs.php, and a new setting in Settings-weather.php ($SITE['overrideRain']) to control display of current conditions when using a METAR as the source ($SITE['conditionsMETAR']).

The overrideRain setting allows your local station rain to override the METAR rain indication (if any) with icon/text as follows:

"Moderate Drizzle" when rain rate is = 0.0 per hour and <#LastRainTipISO> is < 30 minutes ago.
"Light Rain" when rain rate is > 0.0 and < 2.5 mm (0.098 in) per hour
"Moderate Rain" when rain rate is >= 2.5 mm (0.098 in) and < 7.6 mm (0.30 in) per hour
"Heavy Rain" when rain rate is >= 7.6 mm (0.30 in) per hour and < 50 mm (2.0 in) per hour
"Violent Rain" when rain rate is >= 50 mm (2.0 in) per hour

If $SITE['overrideRain'] setting is ommitted from Settings-weather.php, the default will be assumed as 'true' to enable the function.

If enabled, the rain words from the METAR will be removed, and the above words used based on the current rain rate.

We finally had enough rain around here to test out the additions :)

Use the updates page (24-Mar-2012) to get the changed *-defs files (and also support for WeatherCat software that was released today).

Best regards,
Ken
User avatar
MickinMoulden
Posts: 499
Joined: Mon 20 Dec 2010 12:12 pm
Weather Station: WS-1081 with rain gauge mod
Operating System: Windows 7 & 1.9.3 b1059
Location: Palmerston, NT, Australia
Contact:

Re: Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)

Post by MickinMoulden »

Well done :). I guess it's easy enough to chance to your local conditions, as 40% of my rain would be heavy, and 50% violent ;) . Had thought about doing a gauge for rain rate, as for most people that are not into it like we are, would not understand how heavy it's raining if the rainrate was 70+mm/hr calculated over 5 mins. They would be like " :? ????". You need a big sign saying "Raining Cat's and Dogs Man!".
Michael, Palmerston, NT Australia www.Palmerston-WeatherImageNo image? I'm offline!
ImageImage
User avatar
GraemeT
Posts: 312
Joined: Wed 21 Oct 2009 11:19 am
Weather Station: La Crosse WS-2355 & WS-2306
Operating System: Windoze 7, 10, 11
Location: Bayswater, Australia
Contact:

Re: Saratoga AJAX/PHP Cumulus template updated (CU-defs.php)

Post by GraemeT »

Mick,
I use this php function to show a "local lingo" description of rain rate. It can easily be extended for your bucket-sized rain-drops...

Code: Select all

/**
 * showLastRain()
 * Returns the date & time of last rain.
 */
function showLastRain($lastrain, $rrate) {
	$raindate=substr($lastrain,8,2)."/".substr($lastrain,5,2)."/".substr($lastrain,0,4);
	$raintime=substr($lastrain,11,5);
	$lastraindays=dateDiff($lastrain, date("y-m-d h:m"));

	switch ($lastraindays)
	{
	case 0:
		if ($rrate>15) $lastmsg='The ark plans are drawn up, now to start building...';
		elseif ($rrate>10) $lastmsg='It is time to think about building an ark!';
		elseif ($rrate>7.6) $lastmsg='It is raining cats and dogs here!';
		elseif ($rrate>2.5) $lastmsg='It is raining moderately';
		elseif ($rrate>0) $lastmsg='It is raining lightly';
		else $lastmsg='Last Recorded Rain - '.$raintime.' today';
		break;
	case 1:
		$lastmsg='Last Recorded Rain - '.$raintime.' yesterday';
		break;
	default:
		if ($raindate>"00/00/0000")
			$lastmsg='No rain detected for '.$lastraindays.' days ('.$raindate.' '.$raintime.')';
		else $lastmsg='No rain detected since new install';
	}
	return ($lastmsg);
}	// end of showLastRain()

/**
 * dateDiff()
 * Find the difference in days between two calendar dates.
 * Source:  http://php.net/manual/en/function.date.php
 *
 * @param Date $startDate
 * @param Date $endDate
 * @return Int
 */
function dateDiff($startDate, $endDate) {
// Parse dates for conversion
    $startArry=date_parse($startDate);
    $endArry=date_parse($endDate);

    // Convert dates to Julian Days
    $start_date=gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]);
    $end_date=gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]);

    // Return difference
    return round(($end_date - $start_date), 0);
}	// end of dateDiff()

Cheers,
Graeme.
Post Reply