-
Notifications
You must be signed in to change notification settings - Fork 366
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
Create ocean bathymetry example #2195
Conversation
This time the page built successfully on circleci: bathymetry example |
Several changes: I realized this fits better under lines_and_polygons, so moved the file there. There is also now more text at top introducing the example, and the colorbar now has an arrow to indicate the depth can go below -10,000 m. Link to current version I should also bring up the earlier commit adding bbox=None to the BasicReader class. This was because the circleci docs builder is not using fiona and passing a bbox as in this example threw an error. Since the two classes are treated interchangeably, I would not expect this to cause an error. Therefore, now the behavior is that passing a bbox will not cause an error but will be silently ignored unless you are using FionaReader. Is this reasonable, or maybe that situation should raise a warning instead noting that the bounding box will not be used? |
|
||
# Construct colormap: | ||
# Depth levels in the colorbar are spaced as in the data | ||
norm = matplotlib.colors.Normalize(vmin=-10000, vmax=0) # in meters |
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.
Would it be better to quantize this and use BoundaryNorm() here since you have explicit levels?
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.
Thanks for this comment @greglucas . I have switched it to use BoundaryNorm. This ended up helping better link the data to the colorbar.
# Add custom colorbar | ||
axi = fig.add_axes([0.85, 0.1, 0.025, 0.8]) | ||
ax.add_feature(cfeature.BORDERS, linestyle=':') | ||
matplotlib.colorbar.ColorbarBase(ax=axi, |
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 use fig.colorbar()
here instead since I think that is more typical than going for the base classes in an example.
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.
Done.
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.
Nice, this reads much simpler to me now. Just a few minor comments.
Thanks for providing those comments. When working through them, I found the color displayed for depth=0 was not matching the colorbar, which is fixed now. Hopefully things are squared away now but please let me know if you see any other issues. |
Thanks @lgolston! |
Thanks a lot for all this work, it’s great to see it being finished!
Am 14.07.2023 um 22:03 schrieb Greg Lucas ***@***.***>:
Thanks @lgolston<https://github.com/lgolston>!
—
Reply to this email directly, view it on GitHub<#2195 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFIM3AWSASPVRAGU3ZODLYDXQGQYNANCNFSM6AAAAAAZNYEIT4>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Rationale
In a previous pull request (#1916) @mattphysics created a notebook for plotting ocean bathymetry using Natural Earth data, but it was not finished. I have here converted it to converted it to a script, reduced the length in some places, and propose adding it to the example gallery.
Implications
The shapereader.natural_earth interface does not work on this particular file, since the .zip contains multiple shapefiles corresponding to different depths. I think it is a nice example using cartopy's shapereader.Reader interface. The axis extent is set to [90, 160, -15, 60] to help speed up the script versus plotting the whole world.