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

Add support for loading NetCDF files with Mercator projections #2026

Merged
merged 1 commit into from May 25, 2016

Conversation

djkirkham
Copy link
Contributor

@djkirkham djkirkham commented May 23, 2016

This change supports loading and saving NetCDF files with a Mercator projection with some parameters restricted (false_easting == false_northing == 0, scale_factor_at_projection_origin == 1). This allows some support for Mercator projections without needing to modify Cartopy.

This pull request requires additional test data (SciTools/iris-test-data#42).

@djkirkham
Copy link
Contributor Author

djkirkham commented May 24, 2016

Just had a thought. When loading a NetCDF file with a Mercator projection where the values for the restricted parameters do not match the defaults, an exception is raised. Previously, any NetCDF file defining a Mercator projection would still be loaded, without the projection and containing anonymous coordinates for x and y. So this change provides less functionality than before. Perhaps we should change the errors to warnings, and not load the projection?


"""

#: True longitude of planar origin in degrees.
Copy link
Member

Choose a reason for hiding this comment

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

Comments should be structured as # My comment here. please 😄

Copy link
Member

Choose a reason for hiding this comment

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

These are "Doc Comments" for documenting the attributes in Sphinx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's pretend I knew that and didn't just copy the comments from another class...

Copy link
Member

Choose a reason for hiding this comment

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

If you don't want them documented (probably no need, but I don't really mind) then remove the :.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave them as they are


def __repr__(self):
return "Mercator(central_lon={!r}, "\
"ellipsoid={!r})".format(
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively (and a pattern I personally prefer):

res = 'Mercator(central_longitude={!r}, ellipsoid={!r})'
return res.format(self.central_longitude, self.ellipsoid)

Saves the slightly forced splitting of lines. I'm also assuming you've changed the name of central_longitude 😉

@ajdawson
Copy link
Member

I'm generally in favour of being permissive on load. I don't think we want to be throwing an exception if we can help it. Partially loading the data allows the user to fill in any missing details manually (perhaps according to some other convention), but throwing an error leaves them stuck.

<attribute name="geospatial_lat_min" value="0.0"/>
<attribute name="geospatial_lon_max" value="0.0"/>
<attribute name="geospatial_lon_min" value="0.0"/>
<attribute name="history" value="Created: 2016-05-23T09:40:00Z"/>
Copy link
Member

Choose a reason for hiding this comment

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

Is this history attribute going to give us problems with ever-changing values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the result of a load test, so the attribute doesn't change; it is loaded in from a file.

def test_merc(self):
tm = merc()
expected = "Mercator(longitude_of_projection_origin=90.0, "\
"ellipsoid=GeogCS(semi_major_axis=6377563.396, semi_minor_axis=6356256.909))"
Copy link
Member

Choose a reason for hiding this comment

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

This line goes over the 80 character limit. I assume that this was not picked up by the coding standards test because this is one of the files skipped by the test. Nevertheless as this is new code it would be good if it obeyed the 80 character limit!

@DPeterK
Copy link
Member

DPeterK commented May 25, 2016

Tests pass!! 🎉

I've one last comment (the one just above about the line length) and then after a squash of commits I'm 👍

@DPeterK
Copy link
Member

DPeterK commented May 25, 2016

Stupid long-running tests timing out 😑 ⏳ 💥 I'm going to merge this anyway as (a) the tests that are timing out are nothing to do with @djkirkham's changes, and (b) the tests all passed before the squash.

Boom. Progress.

@DPeterK DPeterK merged commit 2931a88 into SciTools:master May 25, 2016
@QuLogic QuLogic added this to the v1.10 milestone May 25, 2016
@djkirkham djkirkham deleted the add-netcdf-mercator branch October 26, 2017 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants