Skip to content

Commit bdb8c63

Browse files
authored
Add data template number 42 to the list of supported templates (#264)
1 parent 9cec4d6 commit bdb8c63

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

iris_grib/_load_convert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ def data_representation_section(section):
25152515
template = section['dataRepresentationTemplateNumber']
25162516

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright iris-grib contributors
2+
#
3+
# This file is part of iris-grib and is released under the LGPL license.
4+
# See COPYING and COPYING.LESSER in the root of the repository for full
5+
# licensing details.
6+
"""
7+
Test function :func:`iris_grib._load_convert.data_representation_section.`
8+
9+
"""
10+
11+
# import iris_grib.tests first so that some things can be initialised
12+
# before importing anything else.
13+
import iris_grib.tests as tests
14+
15+
from iris.exceptions import TranslationError
16+
17+
from iris_grib._load_convert import data_representation_section
18+
from iris_grib.tests.unit import _make_test_message
19+
20+
21+
class Test(tests.IrisGribTest):
22+
def test_supported_templates(self):
23+
template_nums = [0, 1, 2, 3, 4, 40, 41, 42, 50, 51, 61]
24+
for template_num in template_nums:
25+
message = _make_test_message(
26+
{5: {'dataRepresentationTemplateNumber': template_num}})
27+
data_representation_section(message.sections[5])
28+
29+
def test_unsupported_template(self):
30+
message = _make_test_message(
31+
{5: {'dataRepresentationTemplateNumber': 5}})
32+
err_msg = r'Template \[5\] is not supported'
33+
with self.assertRaisesRegex(TranslationError, err_msg):
34+
data_representation_section(message.sections[5])
35+
36+
37+
if __name__ == '__main__':
38+
tests.main()

0 commit comments

Comments
 (0)