Author Topic: METAR with (cloud)///  (Read 1075 times)

0 Members and 1 Guest are viewing this topic.

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
METAR with (cloud)///
« on: September 20, 2017, 10:55:56 AM »
I had the following METAR report from Mt. Washington (Home of the World's Worst WeatherTM).

Code: [Select]
017/09/20 13:51 KMWN 201351Z 09023KT 100SM BCFG BKN/// FEW/// FEW000 FEW140 BKN180 BKN200 11/09 RMK BCFG FEW000 TPS LWR BKN045 TPS LWR BKN056 BCFG INTMT
What I'm seeing is that the Saratoga decoding code gets stuck at the "BKN///" and doesn't properly parse the remaining cloud details or the temp/dew point.

There is code at the beginning of mtr_conditions() that strips out any occurrences of "///":

Code: [Select]
$metar = preg_replace('|///|is',' ',$metar);      // remove strange standalone slashes

I've found at one reference that says "(cloud condition)///" means "height not measured".

   http://sto.iki.fi/metar/

In any case, this bit should at worst just be ignored, and this is what happens if I try one of the online METAR decoders.

The debug dump instead shows the code getting stuck on the standalone "BKN":

Code: [Select]
<!-- calling 'mtr_get_conditions' part='BCFG' ptr=6 grp=7 -->
<!-- conditions='' on entry -->
<!-- mtr_get_conditions part='BCFG' -->
<!-- calling 'mtr_get_conditions' part='BKN' ptr=7 grp=7 -->
<!-- conditions='Patches of Fog ' on entry -->
<!-- calling 'mtr_get_cloud_cover' part='BKN' ptr=7 grp=8 -->
<!-- get cloud cover 'BKN' -->
<!-- calling 'mtr_get_temperature' part='BKN' ptr=7 grp=9 -->
<!-- calling 'mtr_get_altimeter' part='BKN' ptr=7 grp=10 -->

In mtr_get_cloud_cover(), what happens is that if a numeric height isn't found immediately after the cloud condition code, it assumes it is no longer a cloud condition and bumps up the "group" pointer.  What needs to happen is to recognize that it is a cloud condition and either ignore it or add it to the cloud details as "height not reported" or something like that.

I'll mess around with a fix...

https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
Re: METAR with (cloud)///
« Reply #1 on: September 20, 2017, 01:21:06 PM »
Here is the fix I applied to my code. It is in this section of mtr_get_cloud_cover():

Code: [Select]
if (preg_match('/^([A-Z]{2,3})([0-9]{3})/',$part,$pieces)) {  // codes for CB and TCU are ignored
$mtrInfo['CLOUDS'] = $cloudCode[$pieces[1]];
$altitude = (integer) 100 * $pieces[2];  // units are feet
$altitudeM = round($altitude/3.28084);
if(!isset($mtrInfo['CLOUD-DETAILS'])) {$mtrInfo['CLOUD-DETAILS'] = '';}
if($doMetric) {
   $mtrInfo['CLOUD-DETAILS'] .= $cloudCode[$pieces[1]]." ${altitudeM} m\t";
} else {
   $mtrInfo['CLOUD-DETAILS'] .= $cloudCode[$pieces[1]]." ${altitude} ft\t";
}
if ($pieces[1] == 'VV') {
$mtrInfo['CLOUDS'] = "Overcast";
} else {

}
$metarPtr++;
}
else {
$group++;
}
}

I modified the bottom "else" to be:

Code: [Select]
    else {
      if (isset ($cloudCode[$part]) )
      {
//        $mtrInfo['CLOUD-DETAILS'] .= $cloudCode[$part] . "\t";
        $metarPtr++;
      }
      else
      {
        $group++;
      }
    }

Uncommenting the commented line includes that piece of info w/o any altitude info.

Ken (or anyone else) let me know if I tripped on a gotcha here.  Thanks!

https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

 

anything