Author Topic: Customized CU-defs.php for Davis VP2  (Read 190 times)

0 Members and 1 Guest are viewing this topic.

Offline ValentineWeather

  • Forecaster
  • *****
  • Posts: 5150
Customized CU-defs.php for Davis VP2
« on: May 03, 2018, 03:11:50 PM »

I've decided  to include winter snowfall next year instead of relying on METAR visibility and made my own custom rates based on average 15:1 moisture content.

My question is does anyone know how to incorporate the change over to snow automatically based on less than 0c or 32f? I can do it manually but thats no fun.. :sad:   





Also changed wording to meet FAA standard on what's light, moderate, heavy, extreme so matched there definition.


Here is the FAA wording: New in 2007

 “LIGHT”         Rainfall rate of .01 – .10 inches per hour
“MODERATE”   Rainfall rate of .175 – .50 inches per hour
“HEAVY”          Rainfall rate of .5 – 2.0 inches per hour
“EXTREME”      Rainfall rate of 2.0 – 16+ inches per hour

This is what it looks like currently non winter season.

Code: [Select]
$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 = 'Drizzle/Light rain';//change wording to 'Light Snow' winter <0C°
  }
   }
 //if ($rate > 0.0 and $rate < 1.6) { $newText = 'Light Snow'; }
 //if ($rate > 1.7 and $rate < 2.8) { $newText = 'Moderate Snow'; }
 //if ($rate > 2.9 and $rate < 50.0) { $newText = 'Heavy Snow'; }
   if ($rate > 0.0 and $rate < 4.4) { $newText = 'Light Rain'; }
   if ($rate >=4.4 and $rate < 12.7) { $newText = 'Moderate Rain'; }
   if ($rate >=12.7 and $rate < 50.0) { $newText = 'Heavy Rain'; }
   if ($rate >= 50.0)         { $newText = 'Extreme 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));
}


Randy

 

anything