-
Notifications
You must be signed in to change notification settings - Fork 224
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
Ensure plotting xarray grids with different central meridians work on some projections #560
Changes from 12 commits
d4282d0
d6ce55e
a302be6
d1f7df6
1caaac4
840fe6b
0d702fd
b83ddbf
e7e51f3
af0cc0a
c26d7a2
4d7d545
ad432e5
0134272
f228e5c
406f847
b3e063a
8f14fe2
0516b06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,9 +93,32 @@ def test_grdimage_over_dateline(xrgrid): | |
|
||
|
||
@check_figures_equal() | ||
def test_grdimage_central_longitude(grid, fig_ref, fig_test): | ||
@pytest.mark.parametrize("lon0", [0, 123, 180]) | ||
@pytest.mark.parametrize("proj_type", ["H", "W"]) | ||
def test_grdimage_central_meridians(grid, proj_type, lon0, fig_ref, fig_test): | ||
""" | ||
Test that plotting a grid centred at different longitudes/meridians work. | ||
Test that plotting a grid with different central meridians (lon0) using | ||
Hammer (H) and Mollweide (W) projection systems work. | ||
""" | ||
fig_ref.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo") | ||
fig_test.grdimage(grid, projection="W120/15c", cmap="geo") | ||
fig_ref.grdimage( | ||
"@earth_relief_01d_g", projection=f"{proj_type}{lon0}/15c", cmap="geo" | ||
) | ||
fig_test.grdimage(grid, projection=f"{proj_type}{lon0}/15c", cmap="geo") | ||
|
||
|
||
@check_figures_equal() | ||
@pytest.mark.parametrize("lat0", [0, 30]) | ||
@pytest.mark.parametrize("lon0", [0, 123, 180]) | ||
@pytest.mark.parametrize("proj_type", ["Q", "S"]) | ||
def test_grdimage_central_meridians_and_standard_parallels( | ||
grid, proj_type, lon0, lat0, fig_ref, fig_test | ||
): | ||
""" | ||
Test that plotting a grid with different central meridians (lon0) and | ||
standard_parallels (lat0) using Cylindrical Equidistant (Q) and General | ||
Stereographic (S) projection systems work. | ||
""" | ||
fig_ref.grdimage( | ||
"@earth_relief_01d_g", projection=f"{proj_type}{lon0}/{lat0}/15c", cmap="geo" | ||
) | ||
fig_test.grdimage(grid, projection=f"{proj_type}{lon0}/{lat0}/15c", cmap="geo") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is meant to resolve @MarkWieczorek's longstanding issue at #390 (we're getting there). Specifically, we check plotting xarray grids on different central meridians (lon0) at 0, 123 and 180deg, and different standard parallels (lat0) 0, 30deg for Cylindrical Equidistant (Q) and General Stereographic (S) projections systems. These plots are compared to a baseline/reference plot using a NetCDF grid directly. Good news: With GMT 6.1.1, plotting these grids don't crash or give a black image anymore. Also for a few lon0/lat0 combinations e.g. (Q0/0, Q0/30, S123/0, S180/0), the plots are perfect. Bad news: Certain lon0/lat0 combinations plot in xarray, but aren't exactly the same as the NetCDF plots. There's an RMS difference of ~25 for the Cylindrical Equidistant plots Q123/0, Q123/30, Q180/0, Q180/30 (see my comment at #560 (comment) for a visual diff). The General Stereographic plots also show minor RMS differences <2 for S0/0, S0/30, S123/30, S180/30, with the diff appearing as a strip along 0deg longitude (i.e. Greenwich, see #560 (comment) for a visual diff). I've also tested combinations of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for taking to the time to look into this. My attitude is that if you think you have done all you can with GMT 6.1.1, then you should release pygmt 0.2 as soon as possible, even if there are still some bugs that might be upstream. pygmt 0.1.2 is completely unusable for me (for plotting global projected data with xarray grids), and as far as I can tell with my tests from pygmt/master, things appear to be ok (i.e., no kernel crashes, and the images appear to be fine without detailed inspection). Nevertheless, the problem with the last column on the right of the plot being incorrect is a clear bug and will need to resolved in the following release. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems there is nothing we can do in PyGMT to fix these bugs. We could do a 0.2.0 release soon. |
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 test checks that #515 is fixed (and it is!), specifically, that PyGMT can plot xarray grids using the Hammer (H) (and Mollweide (W)) projection system on central longitudes 0, 123 and 180deg.