Skip to content

Commit

Permalink
Add data template number 42 to the list of supported templates (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbdreyer authored May 12, 2021
1 parent 9cec4d6 commit bdb8c63
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iris_grib/_load_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,7 @@ def data_representation_section(section):
template = section['dataRepresentationTemplateNumber']

# Supported templates for both grid point and spectral data:
grid_point_templates = (0, 1, 2, 3, 4, 40, 41, 61)
grid_point_templates = (0, 1, 2, 3, 4, 40, 41, 42, 61)
spectral_templates = (50, 51)
supported_templates = grid_point_templates + spectral_templates

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright iris-grib contributors
#
# This file is part of iris-grib and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Test function :func:`iris_grib._load_convert.data_representation_section.`
"""

# import iris_grib.tests first so that some things can be initialised
# before importing anything else.
import iris_grib.tests as tests

from iris.exceptions import TranslationError

from iris_grib._load_convert import data_representation_section
from iris_grib.tests.unit import _make_test_message


class Test(tests.IrisGribTest):
def test_supported_templates(self):
template_nums = [0, 1, 2, 3, 4, 40, 41, 42, 50, 51, 61]
for template_num in template_nums:
message = _make_test_message(
{5: {'dataRepresentationTemplateNumber': template_num}})
data_representation_section(message.sections[5])

def test_unsupported_template(self):
message = _make_test_message(
{5: {'dataRepresentationTemplateNumber': 5}})
err_msg = r'Template \[5\] is not supported'
with self.assertRaisesRegex(TranslationError, err_msg):
data_representation_section(message.sections[5])


if __name__ == '__main__':
tests.main()

0 comments on commit bdb8c63

Please sign in to comment.