Skip to content
Open
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
16 changes: 15 additions & 1 deletion lib/iris/fileformats/pp_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@

from iris.aux_factory import HybridHeightFactory, HybridPressureFactory
from iris.coords import AuxCoord, CellMethod, DimCoord
import iris.coord_systems
from iris.fileformats.rules import (ConversionMetadata, Factory, Reference,
ReferenceTarget)
from iris.fileformats.um_cf_map import (LBFC_TO_CF, STASH_TO_CF,
STASHCODE_IMPLIED_HEIGHTS)
STASHCODE_IMPLIED_HEIGHTS,
STASH_GRID_EN_ALIGN_TO_CF,
STASH_GRID_EN_DIVERGE_TO_CF)

import iris.fileformats.pp


Expand Down Expand Up @@ -1047,6 +1051,16 @@ def _all_other_rules(f):
standard_name = STASH_TO_CF[str(f.stash)].standard_name
units = STASH_TO_CF[str(f.stash)].units
long_name = STASH_TO_CF[str(f.stash)].long_name
elif(hasattr(f, 'coord_system') and
isinstance(f.coord_system(), iris.coord_systems.GeogCS) and
str(f.stash) in STASH_GRID_EN_ALIGN_TO_CF):
standard_name = STASH_GRID_EN_ALIGN_TO_CF[str(f.stash)].standard_name
units = STASH_GRID_EN_ALIGN_TO_CF[str(f.stash)].units
long_name = STASH_GRID_EN_ALIGN_TO_CF[str(f.stash)].long_name
elif str(f.stash) in STASH_GRID_EN_DIVERGE_TO_CF:
standard_name = STASH_GRID_EN_DIVERGE_TO_CF[str(f.stash)].standard_name
units = STASH_GRID_EN_DIVERGE_TO_CF[str(f.stash)].units
long_name = STASH_GRID_EN_DIVERGE_TO_CF[str(f.stash)].long_name

if (not f.stash.is_valid and f.lbfc in LBFC_TO_CF):
standard_name = LBFC_TO_CF[f.lbfc].standard_name
Expand Down
267 changes: 180 additions & 87 deletions lib/iris/fileformats/um_cf_map.py

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions lib/iris/tests/integration/fast_load/test_fast_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def arglen(arg):
# Those could in principle be looked up, but it's a bit awkward.
phenomenon_values = [
('air_temperature', 'K', 'm01s01i004'),
('x_wind', 'm s-1', 'm01s00i002'),
('y_wind', 'm s-1', 'm01s00i003'),
('eastward_wind', 'm s-1', 'm01s00i002'),
('northward_wind', 'm s-1', 'm01s00i003'),
('specific_humidity', 'kg kg-1', 'm01s00i010'),
]

Expand Down Expand Up @@ -587,6 +587,11 @@ def test_FAIL_phenomena_nostash(self):
standard_name='time', units=co_t_fake.units)
one_cube.add_aux_coord(co_t_new, 0)
expected = [one_cube]
# LBFC interpretation always delivers x_wind, but STASH and LBCODE
# will deliver eastward, so patch around this subtlety.
for acube in expected:
if acube.name() == 'eastward_wind':
acube.rename('x_wind')
self.assertEqual(results, expected)

def test_FAIL_pseudo_levels(self):
Expand Down
38 changes: 19 additions & 19 deletions lib/iris/tests/results/constrained_load/all_10_load_match.cml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
</cellMethods>
<data checksum="0x45a44f1a" dtype="float32" shape="(145, 192)"/>
</cube>
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="specific_humidity" units="kg kg-1">
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="eastward_wind" units="m s-1">
<attributes>
<attribute name="STASH" value="m01s00i010"/>
<attribute name="STASH" value="m01s00i002"/>
<attribute name="source" value="Data from Met Office Unified Model"/>
<attribute name="um_version" value="6.6"/>
</attributes>
Expand All @@ -70,14 +70,15 @@
</dimCoord>
</coord>
<coord>
<dimCoord bounds="[[1810.0, 2210.0]]" id="fb105c19" long_name="level_height" points="[2000.0]" shape="(1,)" units="Unit('m')" value_type="float32">
<dimCoord bounds="[[1620.0, 2000.0]]" id="fb105c19" long_name="level_height" points="[1810.0]" shape="(1,)" units="Unit('m')" value_type="float32">
<attributes>
<attribute name="positive" value="up"/>
</attributes>
</dimCoord>
</coord>
<coord datadims="[1]">
<dimCoord circular="True" id="f913a8b3" points="[0.0, 1.875, 3.75, ..., 354.375, 356.25, 358.125]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<dimCoord circular="True" id="f913a8b3" points="[0.9375, 2.8125, 4.6875, ..., 355.312, 357.188,
359.062]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
Expand All @@ -89,7 +90,7 @@
</dimCoord>
</coord>
<coord>
<auxCoord bounds="[[0.803914, 0.763465]]" id="a5c170db" long_name="sigma" points="[0.784571]" shape="(1,)" units="Unit('1')" value_type="float32"/>
<auxCoord bounds="[[0.823493, 0.784571]]" id="a5c170db" long_name="sigma" points="[0.803914]" shape="(1,)" units="Unit('1')" value_type="float32"/>
</coord>
<coord>
<dimCoord bounds="[[332352.0, 333096.0]]" id="cb784457" points="[332724.0]" shape="(1,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='gregorian')" value_type="float64"/>
Expand All @@ -100,11 +101,11 @@
<coord interval="1 hour" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0x0f9c7d63" dtype="float32" shape="(145, 192)"/>
<data checksum="0xd841777e" dtype="float32" shape="(145, 192)"/>
</cube>
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="x_wind" units="m s-1">
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="northward_wind" units="m s-1">
<attributes>
<attribute name="STASH" value="m01s00i002"/>
<attribute name="STASH" value="m01s00i003"/>
<attribute name="source" value="Data from Met Office Unified Model"/>
<attribute name="um_version" value="6.6"/>
</attributes>
Expand All @@ -116,7 +117,8 @@
<dimCoord id="9c8bdf81" points="[306816.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="77a50eb5" points="[-90.0, -88.75, -87.5, ..., 87.5, 88.75, 90.0]" shape="(145,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<dimCoord id="77a50eb5" points="[-89.375, -88.125, -86.875, ..., 86.875, 88.125,
89.375]" shape="(144,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
Expand All @@ -128,8 +130,7 @@
</dimCoord>
</coord>
<coord datadims="[1]">
<dimCoord circular="True" id="f913a8b3" points="[0.9375, 2.8125, 4.6875, ..., 355.312, 357.188,
359.062]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<dimCoord circular="True" id="f913a8b3" points="[0.0, 1.875, 3.75, ..., 354.375, 356.25, 358.125]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
Expand All @@ -152,11 +153,11 @@
<coord interval="1 hour" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0xd841777e" dtype="float32" shape="(145, 192)"/>
<data checksum="0x31d04486" dtype="float32" shape="(144, 192)"/>
</cube>
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="y_wind" units="m s-1">
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="specific_humidity" units="kg kg-1">
<attributes>
<attribute name="STASH" value="m01s00i003"/>
<attribute name="STASH" value="m01s00i010"/>
<attribute name="source" value="Data from Met Office Unified Model"/>
<attribute name="um_version" value="6.6"/>
</attributes>
Expand All @@ -168,13 +169,12 @@
<dimCoord id="9c8bdf81" points="[306816.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="77a50eb5" points="[-89.375, -88.125, -86.875, ..., 86.875, 88.125,
89.375]" shape="(144,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<dimCoord id="77a50eb5" points="[-90.0, -88.75, -87.5, ..., 87.5, 88.75, 90.0]" shape="(145,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
<coord>
<dimCoord bounds="[[1620.0, 2000.0]]" id="fb105c19" long_name="level_height" points="[1810.0]" shape="(1,)" units="Unit('m')" value_type="float32">
<dimCoord bounds="[[1810.0, 2210.0]]" id="fb105c19" long_name="level_height" points="[2000.0]" shape="(1,)" units="Unit('m')" value_type="float32">
<attributes>
<attribute name="positive" value="up"/>
</attributes>
Expand All @@ -193,7 +193,7 @@
</dimCoord>
</coord>
<coord>
<auxCoord bounds="[[0.823493, 0.784571]]" id="a5c170db" long_name="sigma" points="[0.803914]" shape="(1,)" units="Unit('1')" value_type="float32"/>
<auxCoord bounds="[[0.803914, 0.763465]]" id="a5c170db" long_name="sigma" points="[0.784571]" shape="(1,)" units="Unit('1')" value_type="float32"/>
</coord>
<coord>
<dimCoord bounds="[[332352.0, 333096.0]]" id="cb784457" points="[332724.0]" shape="(1,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='gregorian')" value_type="float64"/>
Expand All @@ -204,6 +204,6 @@
<coord interval="1 hour" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0x31d04486" dtype="float32" shape="(144, 192)"/>
<data checksum="0x0f9c7d63" dtype="float32" shape="(145, 192)"/>
</cube>
</cubes>
46 changes: 23 additions & 23 deletions lib/iris/tests/results/constrained_load/all_ml_10_22_load_match.cml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
</cellMethods>
<data checksum="0x152ab762" dtype="float32" shape="(2, 145, 192)"/>
</cube>
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="specific_humidity" units="kg kg-1">
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="eastward_wind" units="m s-1">
<attributes>
<attribute name="STASH" value="m01s00i010"/>
<attribute name="STASH" value="m01s00i002"/>
<attribute name="source" value="Data from Met Office Unified Model"/>
<attribute name="um_version" value="6.6"/>
</attributes>
Expand All @@ -72,15 +72,16 @@
</dimCoord>
</coord>
<coord datadims="[0]">
<dimCoord bounds="[[1810.0, 2210.0],
[9250.0, 10130.0]]" id="fb105c19" long_name="level_height" points="[2000.0, 9680.0]" shape="(2,)" units="Unit('m')" value_type="float32">
<dimCoord bounds="[[1620.0, 2000.0],
[8820.0, 9680.0]]" id="fb105c19" long_name="level_height" points="[1810.0, 9250.0]" shape="(2,)" units="Unit('m')" value_type="float32">
<attributes>
<attribute name="positive" value="up"/>
</attributes>
</dimCoord>
</coord>
<coord datadims="[2]">
<dimCoord circular="True" id="f913a8b3" points="[0.0, 1.875, 3.75, ..., 354.375, 356.25, 358.125]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<dimCoord circular="True" id="f913a8b3" points="[0.9375, 2.8125, 4.6875, ..., 355.312, 357.188,
359.062]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
Expand All @@ -92,8 +93,8 @@
</dimCoord>
</coord>
<coord datadims="[0]">
<auxCoord bounds="[[0.803914, 0.763465],
[0.222443, 0.177555]]" id="a5c170db" long_name="sigma" points="[0.784571, 0.199878]" shape="(2,)" units="Unit('1')" value_type="float32"/>
<auxCoord bounds="[[0.823493, 0.784571],
[0.246215, 0.199878]]" id="a5c170db" long_name="sigma" points="[0.803914, 0.222443]" shape="(2,)" units="Unit('1')" value_type="float32"/>
</coord>
<coord>
<dimCoord bounds="[[332352.0, 333096.0]]" id="cb784457" points="[332724.0]" shape="(1,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='gregorian')" value_type="float64"/>
Expand All @@ -104,11 +105,11 @@
<coord interval="1 hour" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0x38f24240" dtype="float32" shape="(2, 145, 192)"/>
<data checksum="0x777b79f0" dtype="float32" shape="(2, 145, 192)"/>
</cube>
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="x_wind" units="m s-1">
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="northward_wind" units="m s-1">
<attributes>
<attribute name="STASH" value="m01s00i002"/>
<attribute name="STASH" value="m01s00i003"/>
<attribute name="source" value="Data from Met Office Unified Model"/>
<attribute name="um_version" value="6.6"/>
</attributes>
Expand All @@ -120,7 +121,8 @@
<dimCoord id="9c8bdf81" points="[306816.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="[1]">
<dimCoord id="77a50eb5" points="[-90.0, -88.75, -87.5, ..., 87.5, 88.75, 90.0]" shape="(145,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<dimCoord id="77a50eb5" points="[-89.375, -88.125, -86.875, ..., 86.875, 88.125,
89.375]" shape="(144,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
Expand All @@ -133,8 +135,7 @@
</dimCoord>
</coord>
<coord datadims="[2]">
<dimCoord circular="True" id="f913a8b3" points="[0.9375, 2.8125, 4.6875, ..., 355.312, 357.188,
359.062]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<dimCoord circular="True" id="f913a8b3" points="[0.0, 1.875, 3.75, ..., 354.375, 356.25, 358.125]" shape="(192,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
Expand All @@ -158,11 +159,11 @@
<coord interval="1 hour" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0x777b79f0" dtype="float32" shape="(2, 145, 192)"/>
<data checksum="0xaafff359" dtype="float32" shape="(2, 144, 192)"/>
</cube>
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="y_wind" units="m s-1">
<cube core-dtype="float32" dtype="float32" fill_value="-1.07374e+09" standard_name="specific_humidity" units="kg kg-1">
<attributes>
<attribute name="STASH" value="m01s00i003"/>
<attribute name="STASH" value="m01s00i010"/>
<attribute name="source" value="Data from Met Office Unified Model"/>
<attribute name="um_version" value="6.6"/>
</attributes>
Expand All @@ -174,14 +175,13 @@
<dimCoord id="9c8bdf81" points="[306816.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="[1]">
<dimCoord id="77a50eb5" points="[-89.375, -88.125, -86.875, ..., 86.875, 88.125,
89.375]" shape="(144,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<dimCoord id="77a50eb5" points="[-90.0, -88.75, -87.5, ..., 87.5, 88.75, 90.0]" shape="(145,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
<geogCS earth_radius="6371229.0"/>
</dimCoord>
</coord>
<coord datadims="[0]">
<dimCoord bounds="[[1620.0, 2000.0],
[8820.0, 9680.0]]" id="fb105c19" long_name="level_height" points="[1810.0, 9250.0]" shape="(2,)" units="Unit('m')" value_type="float32">
<dimCoord bounds="[[1810.0, 2210.0],
[9250.0, 10130.0]]" id="fb105c19" long_name="level_height" points="[2000.0, 9680.0]" shape="(2,)" units="Unit('m')" value_type="float32">
<attributes>
<attribute name="positive" value="up"/>
</attributes>
Expand All @@ -200,8 +200,8 @@
</dimCoord>
</coord>
<coord datadims="[0]">
<auxCoord bounds="[[0.823493, 0.784571],
[0.246215, 0.199878]]" id="a5c170db" long_name="sigma" points="[0.803914, 0.222443]" shape="(2,)" units="Unit('1')" value_type="float32"/>
<auxCoord bounds="[[0.803914, 0.763465],
[0.222443, 0.177555]]" id="a5c170db" long_name="sigma" points="[0.784571, 0.199878]" shape="(2,)" units="Unit('1')" value_type="float32"/>
</coord>
<coord>
<dimCoord bounds="[[332352.0, 333096.0]]" id="cb784457" points="[332724.0]" shape="(1,)" standard_name="time" units="Unit('hours since 1970-01-01 00:00:00', calendar='gregorian')" value_type="float64"/>
Expand All @@ -212,6 +212,6 @@
<coord interval="1 hour" name="time"/>
</cellMethod>
</cellMethods>
<data checksum="0xaafff359" dtype="float32" shape="(2, 144, 192)"/>
<data checksum="0x38f24240" dtype="float32" shape="(2, 145, 192)"/>
</cube>
</cubes>
Loading