Skip to content
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

Travis test with both Iris latest-release and latest-master. #231

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
29 changes: 27 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ dist: xenial

env:
matrix:
- PYTHON_VERSION=36
- PYTHON_VERSION=37
- PYTHON_VERSION=36 LIMIT_TO_RELEASED_IRIS=false
- PYTHON_VERSION=37 LIMIT_TO_RELEASED_IRIS=false
# - PYTHON_VERSION=36 LIMIT_TO_RELEASED_IRIS=true
# - PYTHON_VERSION=37 LIMIT_TO_RELEASED_IRIS=true

install:
# Download iris-test-data
Expand Down Expand Up @@ -40,6 +42,22 @@ install:
export ENV_NAME="iris-grib-dev";
export ENV_FILE="${TRAVIS_BUILD_DIR}/requirements/ci/py${PYTHON_VERSION}.yml";

# Optionally download latest Iris from repo,
# and replace the Iris dependency with Iris' underlying dependencies.
- >
if [[ "${LIMIT_TO_RELEASED_IRIS}" == false ]]; then
IRIS_REF="https://github.com/SciTools/iris/archive/master.zip";
export IRIS_LOCATION="${HOME}/iris";
mkdir ${IRIS_LOCATION};
wget -O ${IRIS_LOCATION}/iris.zip ${IRIS_REF};
unzip -q ${IRIS_LOCATION}/iris.zip -d ${IRIS_LOCATION};

IRIS_ENV_FILE="${IRIS_LOCATION}/iris-master/requirements/ci/py${PYTHON_VERSION}.yml";
sed -i "/- iris/d" ${ENV_FILE};
echo "# IRIS DEPENDENCIES." >> ${ENV_FILE};
sed -ne "/dependencies:/,$ p" ${IRIS_ENV_FILE} | sed "1d" >> ${ENV_FILE};
fi;

# Create environment.
- >
conda env create --quiet --file=${ENV_FILE};
Expand All @@ -61,6 +79,13 @@ install:
# --------------
- echo "Configuring Iris";

# Optionally install latest Iris from downloaded source.
- >
if [[ "${LIMIT_TO_RELEASED_IRIS}" == false ]]; then
cd ${IRIS_LOCATION}/iris-master;
python setup.py --quiet install;
fi;

# Locate Iris installation.
- export IRIS_DIR=$(python -c "import iris; import os.path; print(os.path.dirname(iris.__file__))")

Expand Down
4 changes: 2 additions & 2 deletions iris_grib/_grib1_load_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ def add_bounded_time_coords(aux_coords_and_dims, grib):
if \
(grib.levelType == 'ml') and \
(hasattr(grib, 'pv')):
aux_coords_and_dims.append((AuxCoord(grib.level, standard_name='model_level_number', attributes={'positive': 'up'}), None))
aux_coords_and_dims.append((AuxCoord(grib.level, standard_name='model_level_number', units=1, attributes={'positive': 'up'}), None))
aux_coords_and_dims.append((DimCoord(grib.pv[grib.level], long_name='level_pressure', units='Pa'), None))
aux_coords_and_dims.append((AuxCoord(grib.pv[grib.numberOfCoordinatesValues//2 + grib.level], long_name='sigma'), None))
aux_coords_and_dims.append((AuxCoord(grib.pv[grib.numberOfCoordinatesValues//2 + grib.level], long_name='sigma', units=1), None))
factories.append(Factory(HybridPressureFactory, [{'long_name': 'level_pressure'}, {'long_name': 'sigma'}, Reference('surface_pressure')]))

if grib._originatingCentre != 'unknown':
Expand Down
13 changes: 8 additions & 5 deletions iris_grib/_load_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ def hybrid_factories(section, metadata):
# Create the model level number scalar coordinate.
scaledValue = section['scaledValueOfFirstFixedSurface']
coord = DimCoord(scaledValue, standard_name='model_level_number',
attributes=dict(positive='up'))
units=1, attributes=dict(positive='up'))
metadata['aux_coords_and_dims'].append((coord, None))

if typeOfFirstFixedSurface == 118:
Expand Down Expand Up @@ -1576,7 +1576,7 @@ def hybrid_factories(section, metadata):
metadata['aux_coords_and_dims'].append((coord, None))
# Create the sigma scalar coordinate.
offset = NV // 2 + scaledValue
coord = AuxCoord(pv[offset], long_name='sigma')
coord = AuxCoord(pv[offset], long_name='sigma', units=1)
metadata['aux_coords_and_dims'].append((coord, None))
# Create the associated factory reference.
factory = Factory(factory_class, factory_args)
Expand Down Expand Up @@ -2286,19 +2286,22 @@ def satellite_common(section, metadata):
if NB > 0:
# Create the satellite series coordinate.
satelliteSeries = section['satelliteSeries']
coord = AuxCoord(satelliteSeries, long_name='satellite_series')
coord = AuxCoord(satelliteSeries, long_name='satellite_series',
units=1)
# Add the satellite series coordinate to the metadata aux coords.
metadata['aux_coords_and_dims'].append((coord, None))

# Create the satellite number coordinate.
satelliteNumber = section['satelliteNumber']
coord = AuxCoord(satelliteNumber, long_name='satellite_number')
coord = AuxCoord(satelliteNumber, long_name='satellite_number',
units=1)
# Add the satellite number coordinate to the metadata aux coords.
metadata['aux_coords_and_dims'].append((coord, None))

# Create the satellite instrument type coordinate.
instrumentType = section['instrumentType']
coord = AuxCoord(instrumentType, long_name='instrument_type')
coord = AuxCoord(instrumentType, long_name='instrument_type',
units=1)
# Add the instrument type coordinate to the metadata aux coords.
metadata['aux_coords_and_dims'].append((coord, None))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
<dimCoord id="ecc4ad5a" long_name="height" points="[2.0]" shape="(1,)" units="Unit('m')" value_type="float64"/>
</coord>
<coord datadims="[1]">
<dimCoord id="0f43c07d" points="[-2396487.0124, -2392487.0124, -2388487.0124,
<dimCoord id="f429d179" points="[-2396487.0124, -2392487.0124, -2388487.0124,
..., 2387512.9876, 2391512.9876, 2395512.9876]" shape="(1199,)" standard_name="projection_x_coordinate" units="Unit('m')" value_type="float64">
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0" false_northing="0" secant_latitudes="(60.0, 30.0)"/>
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0.0" false_northing="0.0" secant_latitudes="(60.0, 30.0)"/>
</dimCoord>
</coord>
<coord datadims="[0]">
<dimCoord id="1e5b5e41" points="[-3870311.24926, -3866311.24926, -3862311.24926,
<dimCoord id="51f2bb31" points="[-3870311.24926, -3866311.24926, -3862311.24926,
..., -686311.249256, -682311.249256,
-678311.249256]" shape="(799,)" standard_name="projection_y_coordinate" units="Unit('m')" value_type="float64">
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0" false_northing="0" secant_latitudes="(60.0, 30.0)"/>
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0.0" false_northing="0.0" secant_latitudes="(60.0, 30.0)"/>
</dimCoord>
</coord>
<coord>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
<auxCoord id="61bde96d" long_name="originating_centre" points="[ US National Weather Service, National Centres for Environmental Prediction]" shape="(1,)" units="Unit('no_unit')" value_type="string"/>
</coord>
<coord datadims="[1]">
<dimCoord id="07a25078" points="[-2396487.0124, -2392487.0124, -2388487.0124,
<dimCoord id="62845c7c" points="[-2396487.0124, -2392487.0124, -2388487.0124,
..., 2387512.9876, 2391512.9876, 2395512.9876]" shape="(1199,)" standard_name="projection_x_coordinate" units="Unit('m')" value_type="float64">
<lambertConformal central_lat="60" central_lon="-98.0" ellipsoid="GeogCS(6371229.0)" false_easting="0" false_northing="0" secant_latitudes="(60.0, 30.0)"/>
<lambertConformal central_lat="60.0" central_lon="-98.0" ellipsoid="GeogCS(6371229.0)" false_easting="0.0" false_northing="0.0" secant_latitudes="(60.0, 30.0)"/>
</dimCoord>
</coord>
<coord datadims="[0]">
<dimCoord id="fef4faee" points="[-3870311.24926, -3866311.24926, -3862311.24926,
<dimCoord id="c75f3634" points="[-3870311.24926, -3866311.24926, -3862311.24926,
..., -686311.249256, -682311.249256,
-678311.249256]" shape="(799,)" standard_name="projection_y_coordinate" units="Unit('m')" value_type="float64">
<lambertConformal central_lat="60" central_lon="-98.0" ellipsoid="GeogCS(6371229.0)" false_easting="0" false_northing="0" secant_latitudes="(60.0, 30.0)"/>
<lambertConformal central_lat="60.0" central_lon="-98.0" ellipsoid="GeogCS(6371229.0)" false_easting="0.0" false_northing="0.0" secant_latitudes="(60.0, 30.0)"/>
</dimCoord>
</coord>
<coord>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
<dimCoord id="ecc4ad5a" long_name="height" points="[2.0]" shape="(1,)" units="Unit('m')" value_type="float64"/>
</coord>
<coord datadims="[1]">
<dimCoord id="0f43c07d" points="[-2396487.0124, -2392487.0124, -2388487.0124,
<dimCoord id="f429d179" points="[-2396487.0124, -2392487.0124, -2388487.0124,
..., 2387512.9876, 2391512.9876, 2395512.9876]" shape="(1199,)" standard_name="projection_x_coordinate" units="Unit('m')" value_type="float64">
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0" false_northing="0" secant_latitudes="(60.0, 30.0)"/>
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0.0" false_northing="0.0" secant_latitudes="(60.0, 30.0)"/>
</dimCoord>
</coord>
<coord datadims="[0]">
<dimCoord id="1e5b5e41" points="[-3870311.24926, -3866311.24926, -3862311.24926,
<dimCoord id="51f2bb31" points="[-3870311.24926, -3866311.24926, -3862311.24926,
..., -686311.249256, -682311.249256,
-678311.249256]" shape="(799,)" standard_name="projection_y_coordinate" units="Unit('m')" value_type="float64">
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0" false_northing="0" secant_latitudes="(60.0, 30.0)"/>
<lambertConformal central_lat="60.0" central_lon="262.0" ellipsoid="GeogCS(6371229.0)" false_easting="0.0" false_northing="0.0" secant_latitudes="(60.0, 30.0)"/>
</dimCoord>
</coord>
<coord>
Expand Down
25 changes: 11 additions & 14 deletions iris_grib/tests/unit/grib1_load_rules/test_grib1_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,17 @@ def test_grib1_hybrid_height(self):
self.assertEqual(sigma, {'long_name': 'sigma'})
self.assertEqual(ref, Reference(name='surface_pressure'))

ml_ref = iris.coords.CoordDefn('model_level_number', None, None,
cf_units.Unit('1'),
{'positive': 'up'}, None, False)
lp_ref = iris.coords.CoordDefn(None, 'level_pressure', None,
cf_units.Unit('Pa'),
{}, None, False)
s_ref = iris.coords.CoordDefn(None, 'sigma', None,
cf_units.Unit('1'),
{}, None, False)

aux_coord_defns = [coord._as_defn() for coord, dim in results[8]]
self.assertIn(ml_ref, aux_coord_defns)
self.assertIn(lp_ref, aux_coord_defns)
self.assertIn(s_ref, aux_coord_defns)
coords_and_dims = results[8]
coord, = [co for co, _ in coords_and_dims
if co.name() == 'model_level_number']
self.assertEqual(coord.units, '1')
self.assertEqual(coord.attributes['positive'], 'up')
coord, = [co for co, _ in coords_and_dims
if co.name() == 'level_pressure']
self.assertEqual(coord.units, 'Pa')
coord, = [co for co, _ in coords_and_dims
if co.name() == 'sigma']
self.assertEqual(coord.units, '1')


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions iris_grib/tests/unit/load_convert/test_satellite_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def _check(self, factors=1, values=111):

# Check the result.
expected = empty_metadata()
coord = AuxCoord(series, long_name='satellite_series')
coord = AuxCoord(series, long_name='satellite_series', units=1)
expected['aux_coords_and_dims'].append((coord, None))
coord = AuxCoord(number, long_name='satellite_number')
coord = AuxCoord(number, long_name='satellite_number', units=1)
expected['aux_coords_and_dims'].append((coord, None))
coord = AuxCoord(instrument, long_name='instrument_type')
coord = AuxCoord(instrument, long_name='instrument_type', units=1)
expected['aux_coords_and_dims'].append((coord, None))
standard_name = 'sensor_band_central_radiation_wavenumber'
coord = AuxCoord(values / (10.0 ** factors),
Expand Down