Skip to content

Commit

Permalink
Add 'main' conda-forge channel, needed for docs builds. (#240)
Browse files Browse the repository at this point in the history
* Add 'main' conda-forge channel, needed for docs builds.

* Use fixed spherical-earth-radius in GRIB1, ignoring change in gribapi default.

* Codestyle fix.
  • Loading branch information
pp-mo authored and lbdreyer committed Feb 24, 2021
1 parent 0cc5152 commit 06534bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 47 deletions.
68 changes: 21 additions & 47 deletions iris_grib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,56 +342,30 @@ def _compute_extra_keys(self):
self.extra_keys['_forecastTimeUnit'] = self._timeunit_string()

# shape of the earth

# pre-defined sphere
if self.shapeOfTheEarth == 0:
soe_code = self.shapeOfTheEarth
# As this class is now *only* for GRIB1, 'shapeOfTheEarth' is not a
# value read from the actual file : It is really a GRIB2 param, and
# the value is merely what eccodes (gribapi) gives as the default.
# This was always = 6, until eccodes 0.19, when it changed to 0.
# See https://jira.ecmwf.int/browse/ECC-811
# The two represent different sized spherical earths.
if soe_code not in (6, 0):
raise ValueError('Unexpected shapeOfTheEarth value =', soe_code)

soe_code = 6
# *FOR NOW* maintain the old behaviour (radius=6371229) in all cases,
# for backwards compatibility.
# However, this does not match the 'radiusOfTheEarth' default from the
# gribapi so is probably incorrect (see above issue ECC-811).
# So we may change this in future.

if soe_code == 0:
# New supposedly-correct default value, matches 'radiusOfTheEarth'.
geoid = coord_systems.GeogCS(semi_major_axis=6367470)

# custom sphere
elif self.shapeOfTheEarth == 1:
geoid = coord_systems.GeogCS(
self.scaledValueOfRadiusOfSphericalEarth *
10 ** -self.scaleFactorOfRadiusOfSphericalEarth)

# IAU65 oblate sphere
elif self.shapeOfTheEarth == 2:
geoid = coord_systems.GeogCS(6378160, inverse_flattening=297.0)

# custom oblate spheroid (km)
elif self.shapeOfTheEarth == 3:
geoid = coord_systems.GeogCS(
semi_major_axis=self.scaledValueOfEarthMajorAxis *
10 ** -self.scaleFactorOfEarthMajorAxis * 1000.,
semi_minor_axis=self.scaledValueOfEarthMinorAxis *
10 ** -self.scaleFactorOfEarthMinorAxis * 1000.)

# IAG-GRS80 oblate spheroid
elif self.shapeOfTheEarth == 4:
geoid = coord_systems.GeogCS(6378137, None, 298.257222101)

# WGS84
elif self.shapeOfTheEarth == 5:
geoid = \
coord_systems.GeogCS(6378137, inverse_flattening=298.257223563)

# pre-defined sphere
elif self.shapeOfTheEarth == 6:
elif soe_code == 6:
# Old value, does *not* match the 'radiusOfTheEarth' parameter.
geoid = coord_systems.GeogCS(6371229)

# custom oblate spheroid (m)
elif self.shapeOfTheEarth == 7:
geoid = coord_systems.GeogCS(
semi_major_axis=self.scaledValueOfEarthMajorAxis *
10 ** -self.scaleFactorOfEarthMajorAxis,
semi_minor_axis=self.scaledValueOfEarthMinorAxis *
10 ** -self.scaleFactorOfEarthMinorAxis)

elif self.shapeOfTheEarth == 8:
raise ValueError("unhandled shape of earth : grib earth shape = 8")

else:
raise ValueError("undefined shape of earth")

gridType = gribapi.grib_get_string(self.grib_message, "gridType")

if gridType in ["regular_ll", "regular_gg", "reduced_ll",
Expand Down
1 change: 1 addition & 0 deletions requirements/ci/py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: iris-grib-dev

channels:
- conda-forge/label/rc_iris
- conda-forge

dependencies:
- python=3.6
Expand Down
1 change: 1 addition & 0 deletions requirements/ci/py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: iris-grib-dev

channels:
- conda-forge/label/rc_iris
- conda-forge

dependencies:
- python=3.7
Expand Down

0 comments on commit 06534bc

Please sign in to comment.