utils.wmowwConversion

utils.wmowwConversion

class utils.wmowwConversion(file)[source]

Helper class to convert observed weather types into the classes 0/4/5/6/7/8/9 as used by Wetterturnier.de. Reads the wmo ww config file using ConfigParser.ConfigParser. The file contains the conversion rules from received observations to one of the main weather types (0,4,5,6,7,8,9). Can be used for present weather (ww) and past weather (w1/w2).

Parameters:file (str) – String, file name containing the specifications.
convert(section, code)[source]

Convert an observed weather code into the new one. “section” defines the conversion table. If set to “past” (or “w1” or “w2”; not case sensitive) the [past weather] conversion table will be used. If set to “present” (or “ww”) the [present weather] will be used. Returns the value in which the observed “code” is converted. If no specificiation is available a “None” is returned.

Parameters:
  • section (str) – One of past/w1/w2 or present/ww. Not case sensitive.
  • code (int) – Integer with the observed code. If None is given, None will be returned. Same yields if “code” is no integer (None returned).
Returns:

Returns an integer or None, depending on the settings.

Return type:

int/None

show()[source]

Development method: prints content of the object to stdout.

WMO FM 94 Conversion Table

Note

The following config file is implemented.

# -------------------------------------------------------------------
# - NAME:        wmo_ww.conf
# - AUTHOR:      Reto Stauffer
# - DATE:        2018-01-24
# -------------------------------------------------------------------
# - DESCRIPTION: Conversion table for repored weather types, from
#                WMO 94 BUFR CODE TABLE. Extracted from
#                BUFRCREX_29_0_0_CodeFlag_en.txt (downloaded Jan 2018
#                from http://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI2/LatestVERSION/LatestVERSION.html)
#
#                FORMAT: the left hand side of the setting can
#                be whatever you like, except that on "=" can be
#                in the description. The right hand side has to be
#                of the format "<integer> gets <integer>" or 
#                "<integer> gets <None>". Everything else will be
#                ignored.
#                The right hand side means nothing else than:
#                If BUFR message is "10" it gets a "0" in synop
#                weather type representation. Or whatever you define.
#
#                PLEASE NOTE: if a flag is defined more than once
#                only the last will be used which might get confusing.
#                Take care to make unique definitions!
# -------------------------------------------------------------------
# - EDITORIAL:   2018-01-24, RS: Created file on thinkreto.
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2018-01-24 10:33 on marvin
# -------------------------------------------------------------------

# BUFR FM 94 Code table 0 02 004/0 02 005
[past weather]

(0) Cloud covering 1/2 or less of the sky thro ... =   0 gets  0
(1) Cloud covering more than 1/2 of the sky du ... =   1 gets  0
(2) Cloud covering more than 1/2 of the sky th ... =   2 gets  0
(3) Sandstorm, duststorm or blowing snow           =   3 gets  3
(4) Fog or ice fog or thick haze                   =   4 gets  4
(5) Drizzle                                        =   5 gets  5
(6) Rain                                           =   6 gets  6
(7) Snow, or rain and snow mixed                   =   7 gets  7
(8) Shower(s)                                      =   8 gets  8
(9) Thunderstorm(s) with or without precipitation  =   9 gets  9
(10) No significant weather observed               =  10 gets  0
(11) VISIBILITY REDUCED (see Note)                 =  11 gets  0
(12) Blowing phenomena, visibility reduced         =  12 gets  0
(13) FOG (see Note)                                =  13 gets  4
(14) PRECIPITATION (see Note)                      =  14 gets  6
(15) Drizzle                                       =  15 gets  5
(16) Rain                                          =  16 gets  6
(17) Snow or ice pellets                           =  17 gets  7
(18) Showers or intermittent precipitation         =  18 gets  8
(19) Thunderstorm                                  =  19 gets  9
(31) Missing value                                 =  31 gets None

# BUFR FM 94 Code Table 0 02 003
[present weather]

(00) Cloud development not observed or not obs ... =   0 gets   0 
(01) Clouds generally dissolving or becoming l ... =   1 gets   0 
(02) State of sky on the whole unchanged           =   2 gets   0 
(03) Clouds generally forming or developing        =   3 gets   0 
(04) Visibility reduced by smoke, e.g. veldt o ... =   4 gets   0 
(05) Haze                                          =   5 gets   0 
(06) Widespread dust in suspension in the air, ... =   6 gets   0 
(07) Dust or sand raised by wind at or near th ... =   7 gets   0 
(08) Well-developed dust whirl(s) or sand whir ... =   8 gets   0 
(09) Duststorm or sandstorm within sight at th ... =   9 gets   0 
(10) Mist                                          =  10 gets   0 
(11) Patches                                       =  11 gets   0 
(12) More or less continuous                       =  12 gets   0 
(13) Lightning visible, no thunder heard           =  13 gets   0 
(14) Precipitation within sight, not reaching  ... =  14 gets   0 
(15) Precipitation within sight, reaching the  ... =  15 gets   0 
(16) Precipitation within sight, reaching the  ... =  16 gets   0 
(17) Thunderstorm, but no precipitation at the ... =  17 gets   9
(18) Squalls                                       =  18 gets   0 
(19) Funnel cloud(s)                               =  19 gets   0 
(20) Drizzle (not freezing) or snow grains         =  20 gets   5 
(21) Rain (not freezing)                           =  21 gets   6 
(22) Snow                                          =  22 gets   7 
(23) Rain and snow or ice pellets                  =  23 gets   7 
(24) Freezing drizzle or freezing rain             =  24 gets None 
(25) Shower(s) of rain                             =  25 gets   8 
(26) Shower(s) of snow, or of rain and snow        =  26 gets   8 
(27) Shower(s) of hail*, or of rain and hail*      =  27 gets   8 
(28) Fog or ice fog                                =  28 gets   4 
(29) Thunderstorm (with or without precipitation)  =  29 gets   9 
(30) Slight or moderate duststorm or sandstorm     =  30 gets   3 
(31) Slight or moderate duststorm or sandstorm     =  31 gets   3 
(32) Slight or moderate duststorm or sandstorm     =  32 gets   3 
(33) Severe duststorm or sandstorm                 =  33 gets   3 
(34) Severe duststorm or sandstorm                 =  34 gets   3 
(35) Severe duststorm or sandstorm                 =  35 gets   3 
(36) Slight or moderate drifting snow              =  36 gets   3 
(37) Heavy drifting snow                           =  37 gets   3 
(38) Slight or moderate blowing snow               =  38 gets   3 
(39) Heavy blowing snow                            =  39 gets   3 
(40) Fog or ice fog at a distance at the time  ... =  40 gets   0 
(41) Fog or ice fog in patches                     =  41 gets   4 
(42) Fog or ice fog, sky visible                   =  42 gets   4 
(43) Fog or ice fog, sky invisible                 =  43 gets   4 
(44) Fog or ice fog, sky visible                   =  44 gets   4 
(45) Fog or ice fog, sky invisible                 =  45 gets   4 
(46) Fog or ice fog, sky visible                   =  46 gets   4 
(47) Fog or ice fog, sky invisible                 =  47 gets   4 
(48) Fog, depositing rime, sky visible             =  48 gets   4 
(49) Fog, depositing rime, sky invisible           =  49 gets   4 
(50) Drizzle, not freezing, intermittent           =  50 gets   5 
(51) Drizzle, not freezing, continuous             =  51 gets   5 
(52) Drizzle, not freezing, intermittent           =  52 gets   5 
(53) Drizzle, not freezing, continuous             =  53 gets   5 
(54) Drizzle, not freezing, intermittent           =  54 gets   5 
(55) Drizzle, not freezing, continuous             =  55 gets   5 
(56) Drizzle, freezing, slight                     =  56 gets   5 
(57) Drizzle, freezing, moderate or heavy (dense)  =  57 gets   5 
(58) Drizzle and rain, slight                      =  58 gets   6
(59) Drizzle and rain, moderate or heavy           =  59 gets   6
(60) Rain, not freezing, intermittent              =  60 gets   6 
(61) Rain, not freezing, continuous                =  61 gets   6 
(62) Rain, not freezing, intermittent              =  62 gets   6 
(63) Rain, not freezing, continuous                =  63 gets   6 
(64) Rain, not freezing, intermittent              =  64 gets   6 
(65) Rain, not freezing, continuous                =  65 gets   6 
(66) Rain, freezing, slight                        =  66 gets   6 
(67) Rain, freezing, moderate or heavy             =  67 gets   6 
(68) Rain or drizzle and snow, slight              =  68 gets   7 
(69) Rain or drizzle and snow, moderate or heavy   =  69 gets   7 
(70) Intermittent fall of snowflakes               =  70 gets   7 
(71) Continuous fall of snowflakes                 =  71 gets   7 
(72) Intermittent fall of snowflakes               =  72 gets   7 
(73) Continuous fall of snowflakes                 =  73 gets   7 
(74) Intermittent fall of snowflakes               =  74 gets   7 
(75) Continuous fall of snowflakes                 =  75 gets   7 
(76) Diamond dust (with or without fog)            =  76 gets   0
(77) Snow grains (with or without fog)             =  77 gets   7 
(78) Isolated star-like snow crystals (with or ... =  78 gets   7 
(79) Ice pellets                                   =  79 gets   7 
(80) Rain shower(s), slight                        =  80 gets   8 
(81) Rain shower(s), moderate or heavy             =  81 gets   8 
(82) Rain shower(s), violent                       =  82 gets   8 
(83) Shower(s) of rain and snow mixed, slight      =  83 gets   8 
(84) Shower(s) of rain and snow mixed, moderat ... =  84 gets   8 
(85) Snow shower(s), slight                        =  85 gets   8 
(86) Snow shower(s), moderate or heavy             =  86 gets   8 
(87) Shower(s) of snow pellets or small hail,  ... =  87 gets   8 
(88) Shower(s) of snow pellets or small hail,  ... =  88 gets   8 
(89) Shower(s) of hail, with or without rain o ... =  89 gets   8 
(90) Shower(s) of hail, with or without rain o ... =  90 gets   8
(91) Slight rain at time of observation            =  91 gets   9 
(92) Moderate or heavy rain at time of observation =  92 gets   9 
(93) Slight snow, or rain and snow mixed or ha ... =  93 gets   9 
(94) Moderate or heavy snow, or rain and snow  ... =  94 gets   9 
(95) Thunderstorm, slight or moderate, without ... =  95 gets   9 
(96) Thunderstorm, slight or moderate, with ha ... =  96 gets   9 
(97) Thunderstorm, heavy, without hail*, but w ... =  97 gets   9 
(98) Thunderstorm combined with duststorm or s ... =  98 gets   9 
(99) Thunderstorm, heavy, with hail* at time o ... =  99 gets   9 
(100) No significant weather observed              = 100 gets   0
(101) Clouds generally dissolving or becoming  ... = 101 gets None
(102) State of sky on the whole unchanged duri ... = 102 gets None
(103) Clouds generally forming or developing d ... = 103 gets None
(104) Haze or smoke, or dust in suspension in  ... = 104 gets None
(105) Haze or smoke, or dust in suspension in  ... = 105 gets None
(110) Mist                                         = 110 gets   0
(111) Diamond dust                                 = 111 gets   0
(112) Distant lightning                            = 112 gets   9
(118) Squalls                                      = 118 gets None
(119) Reserved                                     = 119 gets None
(120) Fog                                          = 120 gets   4
(121) PRECIPITATION                                = 121 gets   6
(122) Drizzle (not freezing) or snow grains        = 122 gets   5
(123) Rain (not freezing)                          = 123 gets   6
(124) Snow                                         = 124 gets   7
(125) Freezing drizzle or freezing rain            = 125 gets   5
(126) Thunderstorm (with or without precipitation) = 126 gets   9
(127) BLOWING OR DRIFTING SNOW OR SAND             = 127 gets None
(128) Blowing or drifting snow or sand, visibi ... = 128 gets None
(129) Blowing or drifting snow or sand, visibi ... = 129 gets None
(130) FOG                                          = 130 gets None
(131) Fog or ice fog in patches                    = 131 gets   4
(132) Fog or ice fog, has become thinner durin ... = 132 gets   4
(133) Fog or ice fog, no appreciable change du ... = 133 gets   4
(134) Fog or ice fog, has begun or become thic ... = 134 gets   4
(135) Fog, depositing rime                         = 135 gets   4
(140) PRECIPITATION                                = 140 gets   6 
(141) Precipitation, slight or moderate            = 141 gets   6 
(142) Precipitation, heavy                         = 142 gets   6 
(143) Liquid precipitation, slight or moderate     = 143 gets   6 
(144) Liquid precipitation, heavy                  = 144 gets   6 
(145) Solid precipitation, slight or moderate      = 145 gets   7
(146) Solid precipitation, heavy                   = 146 gets   6 
(147) Freezing precipitation, slight or moderate   = 147 gets   6 
(148) Freezing precipitation, heavy                = 148 gets   6 
(149) Reserved                                     = 149 gets   5
(150) DRIZZLE                                      = 150 gets   5
(151) Drizzle, not freezing, slight                = 151 gets   5
(152) Drizzle, not freezing, moderate              = 152 gets   5
(153) Drizzle, not freezing, heavy                 = 153 gets   5
(154) Drizzle, freezing, slight                    = 154 gets   5
(155) Drizzle, freezing, moderate                  = 155 gets   5
(156) Drizzle, freezing, heavy                     = 156 gets   5
(157) Drizzle and rain, slight                     = 157 gets   5
(158) Drizzle and rain, moderate or heavy          = 158 gets   5
(159) Reserved                                     = 159 gets None
(160) RAIN                                         = 160 gets   6
(161) Rain, not freezing, slight                   = 161 gets   6
(162) Rain, not freezing, moderate                 = 162 gets   6
(163) Rain, not freezing, heavy                    = 163 gets   6
(164) Rain, freezing, slight                       = 164 gets   6
(165) Rain, freezing, moderate                     = 165 gets   6
(166) Rain, freezing, heavy                        = 166 gets   6
(167) Rain (or drizzle) and snow, slight           = 167 gets   6
(168) Rain (or drizzle) and snow, moderate or  ... = 168 gets   6
(169) Reserved                                     = 169 gets None
(170) SNOW                                         = 170 gets   7 
(171) Snow, slight                                 = 171 gets   7 
(172) Snow, moderate                               = 172 gets   7 
(173) Snow, heavy                                  = 173 gets   7 
(174) Ice pellets, slight                          = 174 gets   7 
(175) Ice pellets, moderate                        = 175 gets   7 
(176) Ice pellets, heavy                           = 176 gets   7 
(177) Snow grains                                  = 177 gets   7 
(178) Ice crystals                                 = 178 gets   7 
(179) Reserved                                     = 179 gets None
(180) SHOWER(S) OR INTERMITTENT PRECIPITATION      = 180 gets   8 
(181) Rain shower(s) or intermittent rain, slight  = 181 gets   8 
(182) Rain shower(s) or intermittent rain, mod ... = 182 gets   8 
(183) Rain shower(s) or intermittent rain, heavy   = 183 gets   8 
(184) Rain shower(s) or intermittent rain, violent = 184 gets   8 
(185) Snow shower(s) or intermittent snow, slight  = 185 gets   8 
(186) Snow shower(s) or intermittent snow, mod ... = 186 gets   8 
(187) Snow shower(s) or intermittent snow, heavy   = 187 gets   8 
(188) Reserved                                     = 188 gets None
(189) Hail                                         = 189 gets   9 
(190) THUNDERSTORM                                 = 190 gets   9 
(191) Thunderstorm, slight or moderate, with n ... = 191 gets   9 
(192) Thunderstorm, slight or moderate, with r ... = 192 gets   9 
(193) Thunderstorm, slight or moderate, with hail  = 193 gets   9 
(194) Thunderstorm, heavy, with no precipitation   = 194 gets   9 
(195) Thunderstorm, heavy, with rain showers a ... = 195 gets   9 
(196) Thunderstorm, heavy, with hail               = 196 gets   9 
(199) Tornado                                      = 199 gets None
(204) Volcanic ash suspended in the air aloft      = 204 gets None
(205) Not used                                     = 205 gets None
(206) Thick dust haze, visibility less than 1 km   = 206 gets None
(207) Blowing spray at the station                 = 207 gets None
(208) Drifting dust (sand)                         = 208 gets None
(209) Wall of dust or sand in distance (like h ... = 209 gets None
(210) Snow haze                                    = 210 gets None
(211) Whiteout                                     = 211 gets None
(212) Not used                                     = 212 gets None
(213) Lightning, cloud to surface                  = 213 gets   9
(217) Dry thunderstorm                             = 217 gets   9
(218) Not used                                     = 218 gets None
(219) Tornado cloud (destructive) at or within ... = 219 gets None
(220) Deposition of volcanic ash                   = 220 gets None
(221) Deposition of dust or sand                   = 221 gets None
(222) Deposition of dew                            = 222 gets None
(223) Deposition of wet snow                       = 223 gets None
(224) Deposition of soft rime                      = 224 gets None
(225) Deposition of hard rime                      = 225 gets None
(226) Deposition of hoar frost                     = 226 gets None
(227) Deposition of glaze                          = 227 gets None
(228) Deposition of ice crust (ice slick)          = 228 gets None
(229) Not used                                     = 229 gets None
(230) Duststorm or sandstorm with temperature  ... = 230 gets None
(239) Blowing snow, impossible to determine wh ... = 239 gets None
(240) Not used                                     = 240 gets None
(241) Fog on sea                                   = 241 gets None
(242) Fog in valleys                               = 242 gets None
(243) Arctic or Antarctic sea smoke                = 243 gets None
(244) Steam fog (sea, lake or river)               = 244 gets None
(245) Steam log (land)                             = 245 gets None
(246) Fog over ice or snow cover                   = 246 gets None
(247) Dense fog, visibility 60-90 m                = 247 gets   4 
(248) Dense fog, visibility 30-60 m                = 248 gets   4 
(249) Dense fog, visibility less than 30 m         = 249 gets   4 
(250) Drizzle, rate of fall - less than 0.10 m ... = 250 gets   5 
(251) Drizzle, rate of fall - 0.10-0.19 mm h-1     = 251 gets   5 
(252) Drizzle, rate of fall - 0.20-0.39 mm h-1     = 252 gets   5 
(253) Drizzle, rate of fall - 0.40-0.79 mm h-1     = 253 gets   5 
(254) Drizzle, rate of fall - 0.80-1.59 mm h-1     = 254 gets   5 
(255) Drizzle, rate of fall - 1.60-3.19 mm h-1     = 255 gets   5 
(256) Drizzle, rate of fall - 3.20-6.39 mm h-1     = 256 gets   5 
(257) Drizzle, rate of fall - 6.4 mm h-1 or more   = 257 gets   5 
(258) Not used                                     = 258 gets None
(259) Drizzle and snow                             = 259 gets   7
(260) Rain, rate of fall - less than 1.0 mm h-1    = 260 gets   6 
(261) Rain, rate of fall - 1.0-1.9 mm h-1          = 261 gets   6 
(262) Rain, rate of fall - 2.0-3.9 mm h-1          = 262 gets   6 
(263) Rain, rate of fall - 4.0-7.9 mm h-1          = 263 gets   6 
(264) Rain, rate of fall - 8.0-15.9 mm h-1         = 264 gets   6 
(265) Rain, rate of fall - 16.0-31.9 mm h-1        = 265 gets   6 
(266) Rain, rate of fall - 32.0-63.9 mm h-1        = 266 gets   6 
(267) Rain, rate of fall - 64.0 mm h-1 or more     = 267 gets   6 
(270) Snow, rate of fall - less than 1.0 cm h-1    = 270 gets   7 
(271) Snow, rate of fall - 1.0-1.9 cm h-1          = 271 gets   7 
(272) Snow, rate of fall - 2.0-3.9 cm h-1          = 272 gets   7 
(273) Snow, rate of fall - 4.0-7.9 cm h-1          = 273 gets   7 
(274) Snow, rate of fall - 8.0-15.9 cm h-1         = 274 gets   7 
(275) Snow, rate of fall - 16.0-31.9 cm h-1        = 275 gets   7 
(276) Snow, rate of fall - 32.0-63.9 cm h-1        = 276 gets   7 
(277) Snow, rate of fall - 64.0 cm h-1 or more     = 277 gets   7 
(278) Snow or ice crystal precipitation from a ... = 278 gets   7
(279) Wet snow, freezing on contact                = 279 gets   7
(280) Precipitation of rain                        = 280 gets   6 
(281) Precipitation of rain, freezing              = 281 gets   6 
(282) Precipitation of rain and snow mixed         = 282 gets   7 
(283) Precipitation of snow                        = 283 gets   7 
(284) Precipitation of snow pellets or small hall  = 284 gets   7 
(285) Precipitation of snow pellets or small h ... = 285 gets   7 
(286) Precipitation of snow pellets or small h ... = 286 gets   7 
(287) Precipitation of snow pellets or small h ... = 287 gets   7 
(288) Precipitation of hail                        = 288 gets   7
(289) Precipitation of hail, with rain             = 289 gets   7
(290) Precipitation of hall, with rain and sno ... = 290 gets   7 
(291) Precipitation of hail, with snow             = 291 gets   7 
(292) Shower(s) or thunderstorm over sea           = 292 gets   8
(293) Shower(s) or thunderstorm over mountains     = 293 gets   8
(508) No significant phenomenon to report, pre ... = 508 gets   0
(509) No observation, data not available, pres ... = 509 gets None
(510) Present and past weather missing, but ex ... = 510 gets None
(511) Missing value                                = 511 gets None