Skip to content

GMTDataArrayAccessor: Improve the documentation to clarify how the accessor works - #3955

Merged
seisman merged 10 commits into
mainfrom
docs/accessor
Jun 2, 2025
Merged

seisman merged 10 commits into
mainfrom
docs/accessor

Conversation

@seisman seisman added this to the 0.16.0 milestone May 22, 2025
@seisman seisman added documentation Improvements or additions to documentation needs review This PR has higher priority and needs review. labels May 22, 2025
@seisman seisman changed the title GMTDataArrayAccessor: Improve the documentation GMTDataArrayAccessor: Improve the documentation to clarify how the accessor works May 22, 2025
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels May 22, 2025
Comment thread pygmt/xarray/accessor.py
Comment on lines +35 to +37
:class:`xarray.DataArray` instance. Thus, the *gmt* accessor will be re-initialized
in cases where the :class:`xarray.DataArray` is manipulated (e.g., arithmetic and
slice operations) or when accessing a :class:`xarray.DataArray` from a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Slice"-ing is still mentioned here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, slice operation creates a new xarray.DataArray instance, so the gmt accessor is re-initialized. The registration and gtype information are correct if the source encoding exists (e.g., loaded via xr.load_dataarray) or incorrect if the source encoding is None (e.g., xr.DataArray created from scracth).

Comment thread pygmt/xarray/accessor.py Resolved
plotting functions. Refer to :class:`pygmt.GMTDataArrayAccessor` for detailed
explanations and workarounds.
:class:`xarray.DataArray` grid can be accessed via the *gmt* accessor. Refer to
:class:`pygmt.GMTDataArrayAccessor` for detailed explanations and limitations.

@seisman seisman May 26, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've also simplified the notes in the load_xxx functions. Please review it and then I'll apply the changes to other load_xxx functions after approval.

Edit: I've updated all files.

@seisman
seisman merged commit 6396328 into main Jun 2, 2025
@seisman
seisman deleted the docs/accessor branch June 2, 2025 10:27
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GMTDataArrayAccessor doesn't work for temporary files that have been sliced

3 participants