diff --git a/siphon/__init__.py b/siphon/__init__.py index 331d0bcf5..89439e640 100644 --- a/siphon/__init__.py +++ b/siphon/__init__.py @@ -7,5 +7,3 @@ from ._version import get_versions __version__ = get_versions()['version'] del get_versions - -__all__ = ['catalog', 'testing', 'http_util', 'upperair'] diff --git a/siphon/ncss_dataset.py b/siphon/ncss_dataset.py index 68ef326b5..b5a4476f9 100644 --- a/siphon/ncss_dataset.py +++ b/siphon/ncss_dataset.py @@ -6,6 +6,7 @@ from __future__ import print_function import logging +import re import numpy as np @@ -14,6 +15,13 @@ log.addHandler(logging.StreamHandler()) +def _without_namespace(tagname): + """Remove the xml namespace from a tag name.""" + if '}' in tagname: + return tagname.rsplit('}', 1)[-1] + return tagname + + class _Types(object): @staticmethod def handle_typed_values(val, type_name, value_type): @@ -69,16 +77,14 @@ def handle_typed_values(val, type_name, value_type): """ if value_type in ['byte', 'short', 'int', 'long']: try: - val = val.split() - val = list(map(int, val)) + val = [int(v) for v in re.split('[ ,]', val) if v] except ValueError: - log.warning('Cannot convert %s to int. Keeping type as str.', val) + log.warning('Cannot convert "%s" to int. Keeping type as str.', val) elif value_type in ['float', 'double']: try: - val = val.split() - val = list(map(float, val)) + val = [float(v) for v in re.split('[ ,]', val) if v] except ValueError: - log.warning('Cannot convert %s to float. Keeping type as str.', val) + log.warning('Cannot convert "%s" to float. Keeping type as str.', val) elif value_type == 'boolean': try: # special case for boolean type @@ -191,6 +197,14 @@ def handle_featureDataset(element): # noqa def handle_variable(self, element): return self.handle_grid(element) + def lookup(self, handler_name): + handler_name = 'handle_' + _without_namespace(handler_name) + if handler_name in dir(self): + return getattr(self, handler_name) + else: + msg = 'cannot find handler for element {}'.format(handler_name) + log.warning(msg) + class NCSSDataset(object): """Hold information contained in the dataset.xml NCSS document. @@ -245,7 +259,6 @@ def __init__(self, element): """ self._types = _Types() - self._types_methods = _Types.__dict__ self.gridsets = {} self.variables = {} @@ -279,12 +292,7 @@ def __init__(self, element): delattr(self, thing) def _get_handler(self, handler_name): - handler_name = 'handle_' + handler_name - if handler_name in self._types_methods: - return getattr(self._types, handler_name) - else: - msg = 'cannot find handler for element {}'.format(handler_name) - log.warning(msg) + return self._types.lookup(handler_name) def _parse_element(self, element): element_name = element.tag diff --git a/siphon/tests/fixtures/GFS_TDS5 b/siphon/tests/fixtures/GFS_TDS5 new file mode 100644 index 000000000..9a3462a86 --- /dev/null +++ b/siphon/tests/fixtures/GFS_TDS5 @@ -0,0 +1,2760 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + User-Agent: [Siphon (0.6.0+31.g7c3df4f.dirty)] + method: GET + uri: http://thredds-test.unidata.ucar.edu/thredds/ncss/grid/casestudies/irma/model/gfs/GFS_Global_0p5deg_20170903_1200.grib2/dataset.xml + response: + body: {string: "\r\n\r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1.5 3.0 7.5 9.0 + 13.5 15.0 19.5 21.0 25.5 27.0 31.5 33.0 37.5 39.0 43.5 45.0 49.5 51.0 55.5 + 57.0 61.5 63.0 67.5 69.0 73.5 75.0 79.5 81.0 85.5 87.0 91.5 93.0 97.5 99.0 + 103.5 105.0 109.5 111.0 115.5 117.0 121.5 123.0 127.5 129.0 133.5 135.0 139.5 + 141.0 145.5 147.0 151.5 153.0 157.5 159.0 163.5 165.0 169.5 171.0 175.5 177.0 + 181.5 183.0 187.5 189.0 193.5 195.0 199.5 201.0 205.5 207.0 211.5 213.0 217.5 + 219.0 223.5 225.0 229.5 231.0 235.5 237.0 246.0 258.0 270.0 282.0 294.0 306.0 + 318.0 330.0 342.0 354.0 366.0 378.0\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1500.0\r\n + \ \r\n \r\n \r\n \r\n 12750.0\r\n + \ \r\n \r\n \r\n \r\n 10.0 80.0 100.0\r\n + \ \r\n \r\n \r\n \r\n 0.05000000074505806 + 0.2500000037252903 0.7000000029802322 1.5\r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n 3.0 6.0 9.0 12.0 15.0 18.0 21.0 24.0 27.0 + 30.0 33.0 36.0 39.0 42.0 45.0 48.0 51.0 54.0 57.0 60.0 63.0 66.0 69.0 72.0 + 75.0 78.0 81.0 84.0 87.0 90.0 93.0 96.0 99.0 102.0 105.0 108.0 111.0 114.0 + 117.0 120.0 123.0 126.0 129.0 132.0 135.0 138.0 141.0 144.0 147.0 150.0 153.0 + 156.0 159.0 162.0 165.0 168.0 171.0 174.0 177.0 180.0 183.0 186.0 189.0 192.0 + 195.0 198.0 201.0 204.0 207.0 210.0 213.0 216.0 219.0 222.0 225.0 228.0 231.0 + 234.0 237.0 240.0 252.0 264.0 276.0 288.0 300.0 312.0 324.0 336.0 348.0 360.0 + 372.0 384.0\r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n 10000.0 + 15000.0 20000.0 25000.0 30000.0 35000.0 40000.0 45000.0 50000.0 55000.0 60000.0 + 65000.0 70000.0 75000.0 80000.0 85000.0 90000.0 92500.0 95000.0 97500.0 100000.0\r\n + \ \r\n \r\n \r\n \r\n 1500.0\r\n + \ \r\n \r\n + \ \r\n \r\n 100.0 200.0 + 300.0 500.0 700.0 1000.0 2000.0 3000.0 5000.0 7000.0 10000.0 15000.0 20000.0 + 25000.0 30000.0 35000.0 40000.0\r\n \r\n \r\n \r\n \r\n 100.0 200.0 + 300.0 500.0 700.0 1000.0 2000.0 3000.0 5000.0 7000.0 10000.0 15000.0 20000.0 + 25000.0 30000.0 35000.0 40000.0 45000.0 50000.0 55000.0 60000.0 65000.0 70000.0 + 75000.0 80000.0 85000.0 90000.0 92500.0 95000.0 97500.0 100000.0\r\n + \ \r\n \r\n + \ \r\n \r\n 0.5800000131130219 + 0.6650000065565109 0.7199999988079071 0.8300000131130219\r\n \r\n + \ \r\n + \ \r\n \r\n 3000.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n 1829.0 2743.0 + 3658.0\r\n \r\n \r\n \r\n \r\n 2.0 80.0 100.0\r\n + \ \r\n \r\n + \ \r\n \r\n 1000.0 + 2000.0 3000.0 5000.0 7000.0 10000.0 15000.0 20000.0 25000.0 30000.0 35000.0 + 40000.0 45000.0 50000.0 55000.0 60000.0 65000.0 70000.0 75000.0 80000.0 85000.0 + 90000.0 92500.0 95000.0 97500.0 100000.0\r\n \r\n \r\n + \ \r\n \r\n 9000.0 12750.0\r\n + \ \r\n \r\n + \ \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n 0.0 3.0 6.0 9.0 12.0 15.0 18.0 21.0 24.0 + 27.0 30.0 33.0 36.0 39.0 42.0 45.0 48.0 51.0 54.0 57.0 60.0 63.0 66.0 69.0 + 72.0 75.0 78.0 81.0 84.0 87.0 90.0 93.0 96.0 99.0 102.0 105.0 108.0 111.0 + 114.0 117.0 120.0 123.0 126.0 129.0 132.0 135.0 138.0 141.0 144.0 147.0 150.0 + 153.0 156.0 159.0 162.0 165.0 168.0 171.0 174.0 177.0 180.0 183.0 186.0 189.0 + 192.0 195.0 198.0 201.0 204.0 207.0 210.0 213.0 216.0 219.0 222.0 225.0 228.0 + 231.0 234.0 237.0 240.0 252.0 264.0 276.0 288.0 300.0 312.0 324.0 336.0 348.0 + 360.0 372.0 384.0\r\n \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ -0.25\r\n 359.75\r\n -90.0\r\n + \ 90.0\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ -0.25\r\n 359.75\r\n -90.0\r\n + \ 90.0\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n -0.25\r\n + \ 359.75\r\n -90.0\r\n 90.0\r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n + \ \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n + \ \r\n -0.25\r\n 359.75\r\n + \ -90.0\r\n 90.0\r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n \r\n \r\n \r\n \r\n + \ \r\n \r\n -0.2500\r\n 359.7500\r\n + \ -90.0000\r\n 90.0000\r\n \r\n + \ \r\n 2017-09-03T12:00:00Z\r\n 2017-09-19T12:00:00Z\r\n + \ \r\n \r\n netcdf3\r\n + \ netcdf4-classic\r\n \r\n\r\n"} + headers: + Access-Control-Allow-Origin: ['*'] + Connection: [Keep-Alive] + Content-Language: [en-US] + Content-Type: [application/xml;charset=UTF-8] + Date: ['Fri, 03 Nov 2017 04:17:41 GMT'] + Keep-Alive: ['timeout=5, max=100'] + Server: [Apache/2.4.27 (Unix) OpenSSL/1.0.1e-fips mod_jk/1.2.42] + X-Frame-Options: [SAMEORIGIN] + status: {code: 200, message: '200'} +version: 1 diff --git a/siphon/tests/test_ncss_dataset.py b/siphon/tests/test_ncss_dataset.py index 83e0ecdf0..53c3860a1 100644 --- a/siphon/tests/test_ncss_dataset.py +++ b/siphon/tests/test_ncss_dataset.py @@ -61,7 +61,7 @@ def test_attribute_invalid_byte(self, caplog): element = ET.fromstring(xml) expected = {'missing_value': ['a']} actual = self.types.handle_attribute(element) - assert 'Cannot convert [\'a\'] to int. Keeping type as str.' in caplog.text + assert 'Cannot convert "a" to int. Keeping type as str.' in caplog.text assert expected == actual def test_attribute_short(self): @@ -78,7 +78,7 @@ def test_attribute_invalid_short(self, caplog): element = ET.fromstring(xml) expected = {'missing_value': ['a']} actual = self.types.handle_attribute(element) - assert 'Cannot convert [\'a\'] to int. Keeping type as str.' in caplog.text + assert 'Cannot convert "a" to int. Keeping type as str.' in caplog.text assert expected == actual def test_attribute_int(self): @@ -95,7 +95,7 @@ def test_attribute_invalid_int(self, caplog): element = ET.fromstring(xml) expected = {'missing_value': ['a']} actual = self.types.handle_attribute(element) - assert 'Cannot convert [\'a\'] to int. Keeping type as str.' in caplog.text + assert 'Cannot convert "a" to int. Keeping type as str.' in caplog.text assert expected == actual def test_attribute_long(self): @@ -112,7 +112,7 @@ def test_attribute_invalid_long(self, caplog): element = ET.fromstring(xml) expected = {'missing_value': ['a']} actual = self.types.handle_attribute(element) - assert 'Cannot convert [\'a\'] to int. Keeping type as str.' in caplog.text + assert 'Cannot convert "a" to int. Keeping type as str.' in caplog.text assert expected == actual def test_attribute_float(self): @@ -129,7 +129,7 @@ def test_attribute_invalid_float(self, caplog): element = ET.fromstring(xml) expected = {'missing_value': ['a']} actual = self.types.handle_attribute(element) - assert 'Cannot convert [\'a\'] to float. Keeping type as str.' in caplog.text + assert 'Cannot convert "a" to float. Keeping type as str.' in caplog.text assert expected == actual def test_attribute_float_nan(self): @@ -157,7 +157,7 @@ def test_attribute_invalid_double(self, caplog): element = ET.fromstring(xml) expected = {'missing_value': ['a']} actual = self.types.handle_attribute(element) - assert 'Cannot convert [\'a\'] to float. Keeping type as str.' in caplog.text + assert 'Cannot convert "a" to float. Keeping type as str.' in caplog.text assert expected == actual def test_attribute_double_nan(self): @@ -573,3 +573,13 @@ def test_dataset_elements_full_ncss_grid(): element = ET.fromstring(urlopen(url).read()) parsed = NCSSDataset(element) assert parsed + + +@recorder.use_cassette('GFS_TDS5') +def test_dataset_parsing_tds5(recwarn): + """Test parsing the dataset from TDS 5.""" + url = ('http://thredds-test.unidata.ucar.edu/thredds/ncss/grid/casestudies/irma/model/' + 'gfs/GFS_Global_0p5deg_20170903_1200.grib2/dataset.xml') + element = ET.fromstring(urlopen(url).read()) + NCSSDataset(element) + assert len(recwarn) == 0