Welcome to the Cumulus Support forum.

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

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.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

Conditions seem wrong!

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
Phlerb
Posts: 36
Joined: Sun 20 Jan 2013 2:21 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 8.1
Location: Jericho, VT USA
Contact:

Conditions seem wrong!

Post by Phlerb »

So, the index page shows "Moderate Drizzle, Partly Cloudy" but the WU APi says clear, the forecast is for Clear, and the sky is clear...

So why does the conditions on the page have something completely off?
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Conditions seem wrong!

Post by saratogaWX »

With the Cumulus plugin, this code in CU-defs.php

Code: Select all

if(substr($WX['LastRainTipISO'],0,4) <> '0000') { // got a last rain valid date
#  $WX['LastRainTipISO'] = '2012-06-05 03:58';
 $cuDF = ($SITE['WDdateMDY'])?'m/d/y':'d/m/y';
 list($dateoflastrainalways,$timeoflastrainalways) =
     explode(' ',date("$cuDF H:i",strtotime($WX['LastRainTipISO'])));
 $dayswithnorain = intval((strtotime(date('Y-m-d'))-strtotime(substr($WX['LastRainTipISO'],0,10)))/86400);
}

if(isset($SITE['conditionsMETAR'])) { // override with METAR conditions for text and icon if requested.
	include_once("get-metar-conditions-inc.php");
	list($Currentsolardescription,$iconnumber,$icongraphic,$icontext,$mtrstuff) = mtr_conditions($SITE['conditionsMETAR'], $time, $sunrise, $sunset,true);
    if(isset($currentrainratehr) and 
      (!isset($SITE['overrideRain']) or (isset($SITE['overrideRain']) and $SITE['overrideRain'])) ) {
	  list($Currentsolardescription,$iconnumber) = 
	  CU_RainRateIcon($Currentsolardescription,$iconnumber,$currentrainratehr,$uomrain,$time,$sunrise,$sunset,$WX['LastRainTipISO']);
    }
}
will set the conditions from the $SITE['conditionsMETAR'] METAR with an override by your local rain rate. You had two bucket tips today, and for a short time, your rain rate was > 0.00/hr, so the rate determined the display of 'Moderate drizzle' using code

Code: Select all

function CU_RainRateIcon($inText,$inIcon,$inRate,$inUOM,$time,$sunrise,$sunset,$lastRain='0000-00-00T00:00:00') {
   global $Debug;
   
/*
Rainfall intensity is classified according to the rate of precipitation:

    Light rain — rate is < 2.5 mm (0.098 in) per hour
    Moderate rain — rate is between 2.5 mm (0.098 in) - 7.6 mm (0.30 in) or 10 mm (0.39 in) per hour
    Heavy rain — rate is > 7.6 mm (0.30 in) per hour, or between 10 mm (0.39 in) and 50 mm (2.0 in) per hour
    Violent rain — rate is > 50 mm (2.0 in) per hour
*/	
   $Debug .= "<!-- CU_RainRateIcon in='$inText' icon='$inIcon' rate='$inRate' uom='$inUOM' -->\n";
   $newText = '';  // assume no changes
   $newIcon = $inIcon;
   
   $rate = $inRate;
   if(preg_match('|in|i',$inUOM)) { // convert to mm/hr rate
     $rate = $inRate * 25.4;
   }
   
   if(substr($lastRain,0,4) <> '0000') {
	  if($rate < 0.001 and time()-strtotime($lastRain) < 30*60) {
		 $newText = 'Moderate Drizzle';
	  }
   }

   if ($rate > 0.0 and $rate < 2.5) { $newText = 'Light Rain'; }
   if ($rate >=2.5 and $rate < 7.6) { $newText = 'Moderate Rain'; }
   if ($rate >=7.6 and $rate < 50.0) { $newText = 'Heavy Rain'; }
   if ($rate >= 50.0)         { $newText = 'Violent Rain'; }
   
   if($newText <> '' or $rate == 0.0) {
	   if ($newText <> '' and $inText <> '') {$newText .= ', ';}
	   $newText .= 
	      preg_replace('/(Light|Moderate|Heavy|Violent|Extreme){0,1}\s*(Rain|Mist|Drizzle), /i','',$inText);
	   $newIcon = mtr_get_iconnumber ($time,$newText,$sunrise,$sunset); 
   } else {
	   $newText = $inText;
   }
   $Debug .= "<!-- CU_RainRateIcon out='$newText' icon='$newIcon' rate='$rate' mm/hr -->\n";
   return(array($newText,$newIcon));
}
Best regards,
Ken
User avatar
Phlerb
Posts: 36
Joined: Sun 20 Jan 2013 2:21 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 8.1
Location: Jericho, VT USA
Contact:

Re: Conditions seem wrong!

Post by Phlerb »

Thanks Ken. I wonder how I got bucket tips when the temperature was -15° F this morning? I see that Today is 0.02 inches. Must have been ice/snow that melted now that the sun came out....
Post Reply