-
Notifications
You must be signed in to change notification settings - Fork 44
Port tests from iris/tests/test_uri_ccallback.py #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
| 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() | ||
60 changes: 60 additions & 0 deletions
60
..._grib/tests/results/integration/iris_integration/__init__/TestCallbacks/grib_callback.cml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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").