GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add function to load Black Marble dataset by weiji14 · Pull Request #3469 · GenericMappingTools/pygmt

Conversation

@weiji14

@weiji14 weiji14 commented Sep 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Description of proposed changes

Function to load the @earth_night_ NASA Black Marble mosaic RGB images stored as GeoTIFF files.

Preview at https://pygmt-dev--3469.org.readthedocs.build/en/3469/api/generated/pygmt.datasets.load_black_marble.html

Example usage:

import pygmt

image = pygmt.datasets.load_black_marble(resolution="06m")

fig = pygmt.Figure()
fig.grdimage(grid=image)
fig.show()

produces

earth_night

Implementation is adapted from #2235.

Fixes #1442, supersedes #1457

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
weiji14 added 3 commits September 30, 2024 15:43
@weiji14
Implement load_black_marble
43c40dc
Function to load the `@earth_night_` NASA Black Marble mosaic RGB images stored as GeoTIFF files.
@weiji14
Add entry for datasets.load_black_marble in doc/api/index.rst
ef0f5c9
@weiji14
Add unit tests for load_black_marble
f11decc
@weiji14 weiji14 added the feature Brand new feature label Sep 30, 2024
@weiji14 weiji14 added this to the 0.14.0 milestone Sep 30, 2024
@weiji14 weiji14 self-assigned this Sep 30, 2024
seisman
seisman approved these changes Sep 30, 2024
View reviewed changes
@weiji14
weiji14 marked this pull request as ready for review September 30, 2024 03:01
weiji14
weiji14 commented Sep 30, 2024
View reviewed changes
Comment thread pygmt/datasets/earth_night.py
Comment on lines +94 to +96
# If rioxarray is installed, set the coordinate reference system
if hasattr(image, "rio"):
image = image.rio.write_crs(input_crs="OGC:CRS84")

@weiji14 weiji14 Sep 30, 2024

Copy link
Copy Markdown
Member Author

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 line is not covered by a unit test. Should I add one, or we can ignore it?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Sep 30, 2024

Copy link
Copy Markdown
Member

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.

It should be covered when rioxarray is installed, right?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Sep 30, 2024

Copy link
Copy Markdown
Member

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.

Or do we have to import rioxarray to register the rio accessor

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weiji14 weiji14 Sep 30, 2024

Copy link
Copy Markdown
Member Author

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.

The equivalent line in load_blue_marble is covered here in test_grdimage_image.py which has an import rioxarray at the top of the file:

pygmt/pygmt/tests/test_grdimage_image.py

Line 18 in 66f258a

xr_image = load_blue_marble(resolution="01d")

We don't test load_black_marble anywhere else except in test_datasets_earth_night.py, and since rioxarray is not imported in that file, this line isn't covered because there is no rio accessor.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weiji14 weiji14 Sep 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

Maybe we can cover this line in the test_grdcut_image.py file at https://github.com/GenericMappingTools/pygmt/pull/3115/files#r1780370539?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Sep 30, 2024

Copy link
Copy Markdown
Member

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.

since rioxarray is not imported in that file, this line isn't covered because there is no rio accessor.

This is not ideal. So even if rioxarray is installed, the rio accessor may still not exist because users don't import the rioxarray package.

I think we should add the following lines to this file (and any other files that try to access the rio accessor):

pygmt/pygmt/datasets/tile_map.py

Lines 21 to 23 in 66f258a

with contextlib.suppress(ImportError):
# rioxarray is needed to register the rio accessor
import rioxarray # noqa: F401

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Sep 30, 2024

Copy link
Copy Markdown
Member

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.

xref: #3323

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weiji14 reacted with thumbs up emoji weiji14 reacted with laugh emoji
All reactions
  • 👍 1 reaction
  • 😄 1 reaction

@weiji14 weiji14 Sep 30, 2024

Copy link
Copy Markdown
Member Author

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, done at commit 66183ed. I've also applied this to pygmt/datasets/earth_day.py, hopefully you don't mind.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@weiji14 weiji14 added the final review call This PR requires final review and approval from a second reviewer label Sep 30, 2024
@weiji14
Import rioxarray to register rio accessor
66183ed
Xref #3323
seisman
seisman approved these changes Sep 30, 2024
View reviewed changes
@seisman

seisman commented Sep 30, 2024

Copy link
Copy Markdown
Member

Alos need to add earth_night_01d to caching.py

weiji14 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weiji14
Add @earth_day_01d to pygmt/helpers/caching.py
61a5b44
@weiji14
weiji14 enabled auto-merge (squash) September 30, 2024 04:46
@weiji14 weiji14 removed the final review call This PR requires final review and approval from a second reviewer label Sep 30, 2024
@weiji14
weiji14 disabled auto-merge September 30, 2024 04:50
@weiji14
weiji14 merged commit 923111a into main Sep 30, 2024
@weiji14
weiji14 deleted the load_black_marble branch September 30, 2024 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@seisman seisman seisman approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@weiji14 weiji14

Labels

feature Brand new feature

Projects

None yet

Milestone

0.14.0

Development

Successfully merging this pull request may close these issues.

Function to load NASA Blue and Black marble mosaic images

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@weiji14 @seisman
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.