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 — Wrap GMT's standard data type GMT_DATASET for table inputs by seisman · Pull Request #2729 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Oct 9, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Description of proposed changes

Similar to #2398, this PR contains some experimental codes to support GMT's standard data type GMT_DATASET for table inputs.

Here are some technical background. In GMT, table inputs are stored in a GMT_DATASET object. A GMT_DATASET object can contain several table files (stored in GMT_DATATABLE) and each table can contain several segments (stored in GMT_DATASEGMENT), and each data segment have M rows and N columns.

References: https://docs.generic-mapping-tools.org/latest/devdocs/api.html#struct-dataset

The ultimate goals are:

  • Avoid using GMTTempfile for modules that output a table [tracked in Get rid of temporary files from pygmt functions and plotting methods #2730]
  • Have a Pythonic representation for the GMT_DATASET object and pass it as input to some modules

Currently, I'm doing too much work in this PR, for example:

  1. Wrapping the GMT C API GMT_Read_Virtualfile Merged to main in clib: Wrap the GMT API function GMT_Read_VirtualFile #2993
  2. Provide a new session method virtualfile_to_data to allow GMT modules write output into a virtual file. Merged to main in clib: Add the virtualfile_out method for creating output virtualfile #3057
  3. Wrapping the GMT_DATASET data type and related GMT_DATATABLE and GMT_DATASEGMENT
  4. Refactor many modules (e.g., grd2xyz, grdtrack) to show how this PR will change the way we handle table-like outputs.

Thus, we need to split this PR into a few smaller PRs if this PR is proven to be working.

Sorry, something went wrong.

Uh oh!

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

weiji14 reacted with heart emoji
All reactions
  • ❤️ 1 reaction
seisman added 4 commits October 9, 2023 18:48
@seisman
Add data types GMT_DATASEGMENT, GMT_DATATABLE and GMT_DATASET
713ad0a
@seisman
Updates
9c580f9
@seisman
Fix formatting
3ce3341
@seisman
Finally, a working version
b655f88
@seisman
seisman marked this pull request as draft October 9, 2023 11:06
@seisman seisman added the enhancement Improving an existing feature label Oct 9, 2023
seisman added 3 commits October 9, 2023 19:16
@seisman
Fix the code structure
221efec
@seisman
Simplify the two options for grd2xyz
6f4a651
@seisman
fix
9a1dc0c
seisman
seisman commented Oct 9, 2023
View reviewed changes
Comment thread pygmt/src/grd2xyz.py Resolved

Uh oh!

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

@seisman seisman added the needs review This PR has higher priority and needs review. label Oct 9, 2023
seisman
seisman commented Oct 9, 2023
View reviewed changes
Comment thread pygmt/clib/session.py Resolved

Uh oh!

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

seisman added 3 commits October 9, 2023 20:24
@seisman
Add docstrings to pygmt/datatypes.py
1843b35
@seisman
Improve the docstrings
bd52024
@seisman
Get rid of temporary files from grdtrack
19eb3aa
seisman
seisman commented Oct 9, 2023
View reviewed changes
Comment thread pygmt/src/grdtrack.py Resolved

Uh oh!

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

@seisman seisman mentioned this pull request Oct 9, 2023
Get rid of temporary files from pygmt functions and plotting methods #2730
Closed
28 of 31 tasks
@seisman
Revert "Get rid of temporary files from grdtrack"
8546048
This reverts commit 19eb3aa.
@seisman seisman mentioned this pull request Oct 10, 2023
pygmt.grdtrack: Support consistent table-like outputs #2733
Merged
7 tasks
seisman added 8 commits October 10, 2023 14:18
@seisman
pygmt.grdtrack: Support consistent table-like outputs
76944a8
@seisman
Update to virtualfile_to_data which can also be used for grids
bac13bd
@seisman
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
d59092b
@seisman
Add read_virtualfile_to_data to simplify the logic
ba6d94e
@seisman
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
9cd1502
@seisman
Fix a typo
589a9dd
@seisman
Merge branch 'main' into datatypes/gmtdataset
ff7459c
@seisman
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
7b485b0
@weiji14 weiji14 mentioned this pull request Oct 10, 2023
Consistent table-like output for PyGMT functions/methods #1318
Closed
9 of 13 tasks
seisman added 2 commits October 11, 2023 10:49
@seisman
Merge branch 'main' into datatypes/gmtdataset
47a79e1
@seisman
Merge read_virtualfile and read_virtualfile_to_data into a single fun…
a06a5b4
…ction
@seisman
Remove the old codes
2b1d565
@seisman seisman mentioned this pull request Feb 27, 2024
pygmt.triangulate: Refactor to use codes consistent with other wrappers #3073
Merged
seisman added 2 commits February 28, 2024 12:40
@seisman
Merge branch 'main' into datatypes/gmtdataset
9ddca59
@seisman
Revert non-related changes and focus on the _GMT_DATASET class
a21b2df
@seisman

seisman commented Feb 28, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

In commit a21b2df, I've reverted all changes that I made to the module wrappers so that we can focus on wrapping GMT_DATASET in this PR.

The reverted changes will be included in PR #3083.

All reactions

Sorry, something went wrong.

Uh oh!

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

@seisman
Minor fixes and improvements
180f3ec
@seisman seisman added the needs review This PR has higher priority and needs review. label Feb 28, 2024
@seisman

seisman commented Feb 28, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

CodSpeed Performance Report

Merging #2729 will degrade performances by 90.44%

Comparing datatypes/gmtdataset (76a09f0) with main (ab39616)

Summary

⚡ 1 improvements ❌ 12 regressions ✅ 85 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main datatypes/gmtdataset Change
⚡ test_blockmean_input_xyz 412.7 ms 366.8 ms +12.54%
❌ test_contour_matrix[DataFrame] 90.8 ms 281.6 ms -67.76%
❌ test_contour_matrix[Dataset] 103.9 ms 294.7 ms -64.74%
❌ test_contour_matrix[array] 88.6 ms 279.3 ms -68.3%
❌ test_filter1d_format 199.6 ms 518.8 ms -61.52%
❌ test_grd2xyz 43.1 ms 229.9 ms -81.28%
❌ test_grdtrack_input_dataframe_and_dataarray 43.9 ms 233.8 ms -81.22%
❌ test_grdvolume_no_outgrid 41.7 ms 294.9 ms -85.86%
❌ test_project_input_matrix[DataFrame] 41.6 ms 422.7 ms -90.16%
❌ test_project_input_matrix[Dataset] 50.7 ms 431.8 ms -88.25%
❌ test_project_input_matrix[array] 40.3 ms 421.3 ms -90.44%
❌ test_select_input_dataframe 184.5 ms 371.8 ms -50.37%
❌ test_delaunay_triples_input_xyz 169.3 ms 357.8 ms -52.67%

This benchmark report looks scary, but it doesn't match my test in #2730 (comment). I guess it's because codspeed doesn't count the I/O time (via pd.read_csv).

All reactions

Sorry, something went wrong.

Uh oh!

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

seisman added 2 commits February 29, 2024 17:19
@seisman
Merge branch 'main' into datatypes/gmtdataset
84b3bf4
@seisman
Merge branch 'main' into datatypes/gmtdataset
6e71924
@seisman seisman mentioned this pull request Mar 1, 2024
clib: Add virtualfile_to_dataset method for converting virtualfile to a dataset #3083
Merged
seisman added 4 commits March 2, 2024 16:45
@seisman
Merge branch 'main' into datatypes/gmtdataset
08be754
@seisman
Move the object->str conversion of text column to the to_dataframe me…
cc5c4ec
…thod
@seisman
Merge branch 'main' into datatypes/gmtdataset
f654c93
@seisman
Merge branch 'main' into datatypes/gmtdataset
e5698a5
@seisman
seisman requested a review from a team March 6, 2024 06:20
@seisman

seisman commented Mar 6, 2024

Copy link
Copy Markdown
Member Author

Ping @GenericMappingTools/pygmt-maintainers for review on this PR. There are so many pending changes/PRs that rely on the changes in this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

weiji14
weiji14 reviewed Mar 6, 2024
View reviewed changes
Comment thread pygmt/datatypes/dataset.py Resolved

Uh oh!

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

Comment thread pygmt/datatypes/dataset.py Resolved

Uh oh!

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

Comment thread pygmt/datatypes/dataset.py Resolved

Uh oh!

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

Comment thread pygmt/datatypes/dataset.py Resolved

Uh oh!

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

Comment thread pygmt/datatypes/dataset.py Resolved

Uh oh!

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

seisman and others added 2 commits March 7, 2024 06:00
@seisman @weiji14
Apply suggestions from code review
661af0b
Co-authored-by: Wei Ji <[email protected]>
@seisman @weiji14
Update pygmt/datatypes/dataset.py
394a054
Co-authored-by: Wei Ji <[email protected]>
weiji14
weiji14 approved these changes Mar 6, 2024
View reviewed changes

@weiji14 weiji14 left a comment

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.

Super big thank you for pushing this through @seisman, especially in cherry-picking many of the changes into separate PRs to make this easier to review! I'm still a little unsure about the triple-nested classes as mentioned at #2729 (comment), but we can always un-nest them later if needed (since they're marked as private classes).

Won't hold this PR up any longer, excited to have PyGMT not store intermediate CSV files in the next release 🚀

Sorry, something went wrong.

Uh oh!

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

All reactions
@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 Mar 7, 2024
seisman added 2 commits March 7, 2024 10:45
@seisman
Merge branch 'main' into datatypes/gmtdataset
63ed85f
@seisman
Remove a blank line
17d2b4c
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Mar 7, 2024
@seisman
seisman merged commit a5d8b14 into main Mar 7, 2024
@seisman
seisman deleted the datatypes/gmtdataset branch March 7, 2024 02:47
@seisman seisman mentioned this pull request May 27, 2024
pygmt.x2sys_cross: Refactor to use virtualfiles for output tables [BREAKING CHANGE: Dummy times in 3rd and 4th columns now have np.timedelta64 type] #3182
Merged
@seisman seisman mentioned this pull request Nov 26, 2024
GMT_DATASET: Refactor nested classes to improve code readability #3653
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@weiji14 weiji14 weiji14 approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

enhancement Improving an existing feature

Projects

None yet

Milestone

0.12.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@seisman @weiji14
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 01402792 — 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.