Menu

Sign ignored for temp/dewpoint SYNOP xml

Help
2009-11-26
2013-05-20
  • Nobody/Anonymous

    Hi,

    I am sending this message to the parser (v 1.37):

    AAXX 20064 71435 16/// /2902 10008 21006 39562 40155 58003 60001 333 10058 21056 70000

    using the command line and I get the following xml:

    &lt;?xml version="1.0" encoding="UTF-8"?><br />
    &lt;reports query_start="Thu Nov 26 20:43:44 2009" version="1.37"><br />
    &lt;synop s="AAXX 20064 71435 16/// /2902 10008 21006 39562 40155 58003 60001 333 10058 21056 70000"><br />
      &lt;obsStationType s="AAXX"><br />
       &lt;stationType v="AAXX"/><br />
      &lt;/obsStationType><br />
      &lt;obsTime s="2006"><br />
       &lt;timeAt><br />
        &lt;day v="20"/><br />
        &lt;hour v="06"/><br />
       &lt;/timeAt><br />
      &lt;/obsTime><br />
      &lt;reportModifier s="AUTO"><br />
       &lt;modifierType v="AUTO"/><br />
      &lt;/reportModifier><br />
      &lt;windIndicator s="4"><br />
       &lt;windUnit v="KT"/><br />
      &lt;/windIndicator><br />
      &lt;obsStationId s="71435"><br />
       &lt;id v="71435"/><br />
       &lt;region v="IV"/><br />
      &lt;/obsStationId><br />
      &lt;precipInd s="1"><br />
       &lt;precipIndVal v="1"/><br />
      &lt;/precipInd><br />
      &lt;wxInd s="6"><br />
       &lt;wxIndVal v="6"/><br />
      &lt;/wxInd><br />
      &lt;baseLowestCloud s="/"><br />
       &lt;notAvailable/><br />
      &lt;/baseLowestCloud><br />
      &lt;visPrev s="//"><br />
       &lt;notAvailable/><br />
      &lt;/visPrev><br />
      &lt;totalCloudCover s="/"><br />
       &lt;oktasNotAvailable/><br />
      &lt;/totalCloudCover><br />
      &lt;sfcWind s="2902"><br />
       &lt;wind><br />
        &lt;dir v="290" rp="4" rn="5"/><br />
        &lt;speed v="2" u="KT"/><br />
       &lt;/wind><br />
      &lt;/sfcWind><br />
      &lt;temperature s="10008 21006"><br />
       &lt;air><br />
        &lt;temp v="0.8" u="C"/><br />
       &lt;/air><br />
       &lt;dewpoint><br />
        &lt;temp v="0.6" u="C"/><br />
       &lt;/dewpoint><br />
       &lt;relHumid1 v="98.57"/><br />
       &lt;relHumid2 v="98.59"/><br />
       &lt;relHumid3 v="98.57"/><br />
       &lt;relHumid4 v="98.57"/><br />
      &lt;/temperature><br />
      &lt;stationPressure s="39562"><br />
       &lt;hPa v="956.2"/><br />
      &lt;/stationPressure><br />
      &lt;SLPhPa s="40155"><br />
       &lt;hPa v="1015.5"/><br />
      &lt;/SLPhPa><br />
      &lt;pressureChange s="58003"><br />
       &lt;period v="3" u="H"/><br />
       &lt;pressureChangeVal v="-0.3" u="hPa"/><br />
       &lt;pressureTendency v="8"/><br />
      &lt;/pressureChange><br />
      &lt;precipHourly s="60001"><br />
       &lt;period v="6" u="H"/><br />
       &lt;precipAmount v="0" u="MM"/><br />
      &lt;/precipHourly><br />
      &lt;section3 s="333"><br />
       &lt;tempMaxPeriod s="10058"><br />
        &lt;period v="24" u="H"/><br />
        &lt;temp v="5.8" u="C"/><br />
       &lt;/tempMaxPeriod><br />
       &lt;tempMinPeriod s="21056"><br />
        &lt;period v="24" u="H"/><br />
        &lt;temp v="-5.6" u="C"/><br />
       &lt;/tempMinPeriod><br />
       &lt;precipHourly s="70000"><br />
        &lt;period v="24" u="H"/><br />
        &lt;precipAmount v="0" u="MM"/><br />
       &lt;/precipHourly><br />
      &lt;/section3><br />
    &lt;/synop><br />
    &lt;/reports><br />

    I was expecting the following for temperature and dewpoint:<br />
      &lt;temperature s="10008 21006"><br />
       &lt;air><br />
        &lt;temp v="0.8" u="C"/><br />
       &lt;/air><br />
       &lt;dewpoint><br />
        &lt;temp v="**-0.6**" u="C"/><br />
       &lt;/dewpoint><br />

    Using the online demo version (http://metaf2xml.sourceforge.net/cgi-bin/metaf.pl) produces the right value for dewpoint.

    Is there something different with the way the scripts work?

    Thanks,
    Vincent

     
  • metaf2xml

    metaf2xml - 2009-11-28

    Hi Vincent,

    you are right to expect -0.6, of course. I was able to reproduce this -
    with a version of perl that I do not use very often, v5.8.8, built for
    a non-Linux OS, but others might be affected, too.

    What intrigued me was that the value for section3/tempMinPeriod/temp/@v
    is correct in the XML you attached: -5.6. So the code worked for this
    case, and it is the same code that produces the value for the dewpoint.

    The problem is the intermediate result for the full degrees in the
    function metaf2xml::parser::_parseTemp. The current code expects that
    ($2 * -1) is -0 if $2 is 0; this is true for many perl versions I have
    tried, but bad programming style nonetheless.

    To fix this issue, please change the code in line 816 in parser.pm from:

        return { v => (($1 eq '1' ? -1 : 1) * $2) . ($3 eq '/' ? '' : ".$3"),

    to:

        return { v => ($1 eq '1' ? '-' : '') . ($2 + 0) . ($3 eq '/' ? '' : ".$3"),
       
    Instead of using multiplication, the sign is simply prepended, the
    leading 0 is now removed by adding 0 to $2.

    This change will also be in the next release, of course.

    Thanks for reporting this!

    Kind regards,
    Thomas

     
  • Nobody/Anonymous

    Danke schön!

    Indeed, I should have mentioned the OS, which is Windows running ActivePerl v5.8.8… I have another box running v5.10.0 that exhibits this as well. The fix solved the error.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.