python-siphon

850hPa temp Advection Example Not Working


I am new to plotting and examining wx data using python. I started with this example 850 hPa temp advection and its failing at this statement.

ncss = NCSS('{}{dt:%Y%m}/{dt:%Y%m%d}/gfsanl_4_{dt:%Y%m%d}_'
            '{dt:%H}00_000.grb2'.format(base_url, dt=dt))

which gives me the following errors in a jupyter notebook. Seems to be related to XML. Perhaps the data structure of the file being used has changed since this example was created. Any help would be appreciated.

Traceback (most recent call last):

  File "C:\users\martbar\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-18-1457913792bc>", line 7, in <module>
    '{dt:%H}00_000.grb2'.format(base_url, dt=dt))

  File "C:\users\martbar\anaconda3\lib\site-packages\siphon\http_util.py", line 379, in __init__
    self._get_metadata()

  File "C:\users\martbar\anaconda3\lib\site-packages\siphon\ncss.py", line 58, in _get_metadata
    root = ET.fromstring(meta_xml)

  File "C:\users\martbar\anaconda3\lib\xml\etree\ElementTree.py", line 1316, in XML
    return parser.close()

  File "<string>", line unknown
ParseError: no element found: line 1, column 0

Solution

  • This is happening because that URL is out-of-date. NCEI has updated their TDS URLs for model output from https://www.ncei.noaa.gov/thredds/ncss/grid/<product>/ to .../thredds/ncss/model-<product>/ and in the case of historical datasets, .../model-<product>-old/. So in this case, your correct base_url would be https://www.ncei.noaa.gov/thredds/ncss/model-gfs-g4-anl-files-old/

    Important follow-up note, that python-gallery example collection has been retired and so is out of date. The more up-to-date gallery is available at the Unidata Python Training website, though the NCEI TDS URLs throughout that site are currently out-of-date as well. Hopefully for not much longer!