-
Notifications
You must be signed in to change notification settings - Fork 293
Add support for cartopy projections with geographic data #1966
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
Conversation
Update: I'm still finishing up some stuff for this PR. It probably shouldn't be merged until after the |
Ok, I think this is pretty close to a working state. This branch:
a default slice plot with this is
This can be annotated like any other plot with GeoAxes to give contextual information. p._setup_plots()
p.plots['AIRDENS'].axes.set_global()
p.plots['AIRDENS'].axes.coastlines()
p.show() now a few examples:
and
|
ping @dopplershift and @pelson you guys might be interested in this :) |
@zssherman how do you want to deal with upstreaming the |
I think we probably want to add a way to call This is really, really awesome. |
@ngoldbaum I can do it separately if you would like? Sadly I've been out sick, so it might take a day or two.
I do have coastlines etc in the plot callback. And @munkm Great work!
|
Thanks @zssherman and @ngoldbaum! It means a lot coming from the both of you! |
So I meant to bring up a few issues I have with this that I'd like to ask about before I take off the 'WIP' label, one of which @ngoldbaum already brought up!
|
Also I'm sorry to hear that you're out sick @zssherman! I hope you feel better soon. 🙂 |
Ok I rebased so that the |
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.
Looks good to me. Only minor comments.
It is worth noting that down the road we will likely want to shift the spherical coordinate handler to this, too, even though it won't necessarily need coastlines.
What do you think about making a note if the data is geographic and the projection is not set, and saying, hey, you might want to set the projection somehow.
onto a representation of that sphere flattened into 2d space. There exist a | ||
number of projection types, which can be found in the `the cartopy | ||
documentation <https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html>`_. | ||
yt now supports these projection types for geographically loaded data. |
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.
Can you change this to be:
`yt` now supports using these projection types, through cartopy, for geopgraphically loaded data.
or something that indicates more directly we're using cartopy?
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.
Ah, great point! Cartopy is definitely doing all of the transformation behind-the-scenes so it should be highlighted.
number of projection types, which can be found in the `the cartopy | ||
documentation <https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html>`_. | ||
yt now supports these projection types for geographically loaded data. | ||
Underlying data is assumed to have an underlying projection type of `PlateCarree`. If |
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.
Make this a link to the docs for PlateCaree
, or at least note that PlateCaree
means that it's lat/lon grid?
request on the yt github page for this feature. | ||
|
||
It should be noted that | ||
these projections are not the same as yt's ProjectionPlot. For more information |
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.
good note!
|
||
.. code-block:: python | ||
|
||
p.set_mpl_projection('Robinson') |
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.
Is it possible to do this in the instantiation of SlicePlot
itself, with an argument?
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.
Right now I don't think so, but I could add that if it'd be useful.
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.
I think it would be good, so that we can enable it to be done as the first result, rather than as the second iteration.
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.
Ok, I've added in that functionality and updated the test and the documentation to reflect this additional functionality. We should now be able to pass in geo_projection=
into SlicePlot
and the initial plot should have a projection other than PlateCarree
.
@ngoldbaum and I just talked about updating the docs on this PR to ensure that users wanting to use this feature have cartopy installed to avoid potential issues with the GEOS library in shapely / cartopy. We've decided that the following improvements would be helpful:
Nathan, I think that covers everything. Did I miss anything? |
Yup and just because it was annoying to figure out, the pip install command that should work on macs is:
|
Sounds good. Maybe we could out an error message if a projection is chosen that is not supported without cartopy. |
I'm running into some issues when plotting data that doesn't cover the whole domain. I'm using this dataset: http://ds.iris.edu/ds/products/emc-dna13/ the binary version of which is at http://ds.iris.edu/files/products/emc/data/DNA13/DNA13_percent.nc . ( Porritt, R. W., R.M. Allen, and F. F. Pollitz. 2014. “Seismic imaging east of the Rocky Mountains with USArray.” Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2013.10.034. ) Here is a gist that loads into yt: https://gist.github.com/MatthewTurk/57360f40433817ecee4ef76bb817d970 It hangs inside cartopy's I'm not entirely certain why this is happening. Cartopy seems to be expecting some distances that are |
OK, I was able to reduce it to something that doesn't use yt; now I'm trying to determine how we might avoid it in the future.
|
I submitted an issue upstream here: SciTools/cartopy#1184 |
Hope my clarification in the issue above was helpful. In summary, it is just taking a really long time for cartopy to re-project the data. v0.17 (release due this week) of cartopy will support pykdtree, and when installed will make the transformation an order of magnitude quicker. Hopefully that solves the issue in yt for you @munkm. |
Seems that my "hotfixes" for the extent-setting have caused secondary problems; I'm going to revert them and then we can figure out how to move forward with either the forthcoming new release of cartopy that @pelson noted or if I can find an alternate implementation. |
^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
As mentioned above, the default data transform is assumed to be of `PlateCarree | ||
<https://scitools.org.uk/cartopy/docs/latest/crs/projections.html#platecarree>`_, |
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 is a very minor note. There are multiple places in this doc file with a link where the link text is "PlateCarree." This will cause sphinx to think a label has multiple definition and issue a warning. This can be fixed by making the trailing underscore into two underscores, e.g.:
`PlateCarree
<https://scitools.org.uk/cartopy/docs/latest/crs/projections.html#platecarree>`__
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.
Ah, thanks for that @brittonsmith! I really appreciate the explanation too. It should be fixed now.
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 looks great to me!
``yt`` now supports these projection | ||
types for geographically loaded data. | ||
Underlying data is assumed to have a transform of `PlateCarree | ||
<https://scitools.org.uk/cartopy/docs/latest/crs/projections.html#platecarree>`_, |
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.
There's the other one.
@munkm along with britton's suggestion, maybe we should try testing with cartopy 0.17.0 now that that has been released. Supposedly that will fix the perf issues that Matt ran into. If updating cartopy causes issues we can back that out and go in and fix those issues in a separate PR. |
BTW with Britton approving I feel comfortable merging this. |
PR Summary
This PR adds in support for projecting geographic data sources on various map types. As it stands, the code in this PR assumes that geographic data is read in as
PlateCarree
type and can be projected onto the maps listed here: https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html.PR Checklist