This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
On Fri, 4 Feb 2005, Chris Peters wrote: > > Actually this is not as much of a bug as it might first appear, due to > perhaps a > quirk of perl. > > David when I first read your email, your theory looked correct and it made me > run to check the code (we have ldm running here at TWC and use the metar > decoder.) However, I was unable to confirm the bug with a suite of tests I > wrote. The tests take some canned metar examples and run them through the > decoder, checking for known values. A metar rep with 14/00 in the T/Td group > correctly decoded the dewpoint as 0. Chris, you are correct. i greped some raw metar data files and all the 0 TD's where coded as /M00 none coded as /M0. so the present code works correctly but i did the fix incase of future metar coding changes. thanks, robb... > > It turns out that perl doesn't consider the string "00" to be false. You can > confirm this by running the following perl code on your system: > > #!/usr/bin/perl -w > use strict; > > print "OK - 1" if ("00"); > print "OK - 2" if ("0"); > print "OK - 3" if (0); > print "OK - 4" if (00); > > > It will only print out the first line (OK -1). For some reason, probably > involving perl's type system and the way it converts strings to numbers, the > string "00" does NOT evaluate to false. Fortunately, 99% of the time I > believe > a metar reports a dewpoint/temp of zero as "00" or "M00". So due to > coincidence, this bug probably never reared its' head. > > You might argue that to be safe, one should go ahead and use the defined test > anyways, as to not do so is to rely on a coincidence that might change in a > future version of perl. > > Chris > ======================================================= > Christopher Peters > Senior Wx Systems Developer - The Weather Channel > address@hidden > Phone: 770-226-2039 > > > > > Robb Kambic > <address@hidden To: David Larson > <address@hidden> > r.edu> cc: address@hidden, > decoders > Sent by: <address@hidden> > owner-decoders@unida Subject: Re: Latest > Decoders package 3.0.7+ > ta.ucar.edu > > > 02/04/2005 01:59 PM > > > > > > > On Fri, 4 Feb 2005, David Larson wrote: > > > Robb, > > > > There seems to be a problem with the dewpoint processing in the decoders > > package (since the dawn of time, perhaps) ... The metar2nc script leaves > > the TD variable as undefined, and therefore it is processed as "missing" > > when the dewpoint is "00". > > > > # get temperature and dew point > > if( s#^(M)?(\d{2})/(M)?(\d{2})?\s+## ) { > > $T = $2 ; > > $T *= -1 if( $1 ) ; > > $TD = $4 if( $4 ) ; > > $TD *= -1 if( $3 ) ; > > } > David, > > you are correct, TD of value 0 fails to get set with the current code. > your fix seems reasonable, i'll fix it and make another release. > > thanks, > robb... > > > > > > The solution is to change the code to use if( defined($4) ) because > > otherwise a zero value is not considered true and therefore the > > assignment to TD does not occur. > > > > Let me know if you have a better way to handle this. > > Dave > > > > =============================================================================== > Robb Kambic Unidata Program > Center > Software Engineer III Univ. Corp for > Atmospheric Research > address@hidden WWW: > http://www.unidata.ucar.edu/ > =============================================================================== > > > > > =============================================================================== Robb Kambic Unidata Program Center Software Engineer III Univ. Corp for Atmospheric Research address@hidden WWW: http://www.unidata.ucar.edu/ ===============================================================================