Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions iris_grib/tests/integration/iris_integration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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.
"""
Integration tests confirming that iris functionality is working with GRIB
files.

"""

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


import iris
import iris.coords


class TestCallbacks(tests.IrisGribTest):
def test_grib_callback(self):
def grib_thing_getter(cube, field, filename):
if hasattr(field, "sections"):
# New-style loader callback : 'field' is a GribMessage, which
# has 'sections'.
cube.add_aux_coord(
iris.coords.AuxCoord(
field.sections[1]["year"],
long_name="extra_year_number_coord",
units="no_unit",
)
)
else:
# Old-style loader provides 'GribWrapper' type field.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is completely redundant, as we don't use this thing anywhere else and we aren't doing callback testing on GRIB1. So, we don't even need the hasattr(field, "sections").

cube.add_aux_coord(
iris.coords.AuxCoord(
field.extra_keys["_periodStartDateTime"],
long_name="random element",
units="no_unit",
)
)

fname = tests.get_data_path(("GRIB", "global_t", "global.grib2"))
cube = iris.load_cube(fname, callback=grib_thing_getter)
self.assertCML(cube)


if __name__ == "__main__":
tests.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" ?>
<cubes xmlns="urn:x-iris:cubeml-0.2">
<cube dtype="float64" standard_name="air_temperature" units="K">
<attributes>
<attribute name="GRIB_PARAM" value="GRIB2:d000c000n000"/>
</attributes>
<coords>
<coord>
<dimCoord id="507906da" long_name="extra_year_number_coord" points="[1998]" shape="(1,)" units="Unit('no_unit')" value_type="int64"/>
</coord>
<coord>
<dimCoord bounds="[[-28587.0, 6477.0]]" id="1d45e087" points="[-11055.0]" shape="(1,)" standard_name="forecast_period" units="Unit('hours')" value_type="float64"/>
</coord>
<coord>
<dimCoord id="9c8bdf81" points="[246987.0]" shape="(1,)" standard_name="forecast_reference_time" units="Unit('hours since 1970-01-01 00:00:00', calendar='gregorian')" value_type="float64"/>
</coord>
<coord datadims="[0]">
<dimCoord id="98bcd589" points="[89.999983, 87.499984, 84.999985, 82.499986,
79.999987, 77.499988, 74.999989, 72.49999,
69.999991, 67.499992, 64.999993, 62.499994,
59.999995, 57.499996, 54.999997, 52.499998,
49.999999, 47.5, 45.000001, 42.500002,
40.000003, 37.500004, 35.000005, 32.500006,
30.000007, 27.500008, 25.000009, 22.50001,
20.000011, 17.500012, 15.000013, 12.500014,
10.000015, 7.500016, 5.000017, 2.500018,
1.90000000089e-05, -2.49998, -4.999979,
-7.499978, -9.999977, -12.499976, -14.999975,
-17.499974, -19.999973, -22.499972, -24.999971,
-27.49997, -29.999969, -32.499968, -34.999967,
-37.499966, -39.999965, -42.499964, -44.999963,
-47.499962, -49.999961, -52.49996, -54.999959,
-57.499958, -59.999957, -62.499956, -64.999955,
-67.499954, -69.999953, -72.499952, -74.999951,
-77.49995, -79.999949, -82.499948, -84.999947,
-87.499946, -89.999945]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64">
<geogCS earth_radius="6367470.0"/>
</dimCoord>
</coord>
<coord datadims="[1]">
<dimCoord circular="True" id="160a738f" points="[0.0, 3.749998, 7.499996, ..., 348.749814,
352.499812, 356.24981]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float64">
<geogCS earth_radius="6367470.0"/>
</dimCoord>
</coord>
<coord>
<dimCoord id="302bf438" long_name="pressure" points="[100000.0]" shape="(1,)" units="Unit('Pa')" value_type="float64"/>
</coord>
<coord>
<dimCoord bounds="[[218400.0, 253464.0]]" id="cb784457" points="[235932.0]" shape="(1,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='gregorian')" value_type="float64"/>
</coord>
</coords>
<cellMethods>
<cellMethod method="mean">
<coord name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0x857e5378" dtype="float64" shape="(73, 96)"/>
</cube>
</cubes>