-
Notifications
You must be signed in to change notification settings - Fork 228
Wrap GMT's standard data type GMT_DATASET for table inputs #2729
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
124 commits
Select commit
Hold shift + click to select a range
713ad0a
Add data types GMT_DATASEGMENT, GMT_DATATABLE and GMT_DATASET
seisman 9c580f9
Updates
seisman 3ce3341
Fix formatting
seisman b655f88
Finally, a working version
seisman 221efec
Fix the code structure
seisman 6f4a651
Simplify the two options for grd2xyz
seisman 9a1dc0c
fix
seisman 1843b35
Add docstrings to pygmt/datatypes.py
seisman bd52024
Improve the docstrings
seisman 19eb3aa
Get rid of temporary files from grdtrack
seisman 8546048
Revert "Get rid of temporary files from grdtrack"
seisman 76944a8
pygmt.grdtrack: Support consistent table-like outputs
seisman bac13bd
Update to virtualfile_to_data which can also be used for grids
seisman d59092b
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
seisman ba6d94e
Add read_virtualfile_to_data to simplify the logic
seisman 9cd1502
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
seisman 589a9dd
Fix a typo
seisman ff7459c
Merge branch 'main' into datatypes/gmtdataset
seisman 7b485b0
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
seisman 47a79e1
Merge branch 'main' into datatypes/gmtdataset
seisman a06a5b4
Merge read_virtualfile and read_virtualfile_to_data into a single fun…
seisman 7e59970
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
seisman f5a9d44
Refactor the virtualfile_to_data function to support writing to a rea…
seisman 276b6f7
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
seisman 5470495
Simplify the codes following the gmtdataset changes
seisman 555bfe3
Move gmtdataset_to_vectors as a method of the GMT_DATASET class
seisman 40510f5
Merge branch 'datatypes/gmtdataset' into tempfile/grdtrack
seisman 6d26c10
Update after gmtdataset changes
seisman 2205cbb
Add Pythonic objects
seisman 4e67ebf
Add more notes about GMT.jl implementation
seisman 4707b87
Refactor the codes using nested classes
seisman 013f4bb
Add more examples
seisman 19fd164
Deal with text column
seisman 0772711
Merge branch 'main' into datatypes/gmtdataset
seisman 0b8733d
Merge branch 'main' into datatypes/gmtdataset
seisman 87f4cf0
Merge branch 'tempfile/grdtrack' into datatypes/gmtdataset
seisman 3cff015
Fix linting issues
seisman 9843eca
Standarize virtual file names
seisman 9af418a
Improve the GMT_DATASET doctest
seisman 7160a4f
Fix a typo
seisman 6e07b95
Improve the doctest for GMT_DATASET.to_vectors()
seisman 7da3654
Add more comments to the GMT_DATASET.to_vectors function
seisman afecfc0
Remove the GMT_DATASET.to_vectors_v2 method
seisman 89efc18
Remove the GMT_DATASET.to_pydata method to focus on the GMT dataset s…
seisman c7a0982
Fix linting issues
seisman 3c46aca
Remove two blank lines
seisman 78c3959
Let pandas deal with the conversion to numpy
seisman 10d0c1e
Merge branch 'main' into datatypes/gmtdataset
seisman c86208c
Disable some pylint warnings
seisman caa9d10
Let pandas deal with 1-D arrays directly
seisman d37efcf
Fix linting issues
seisman 5c3f1b1
Add a return_table function
seisman cd11f98
Add the validate_output_type function to check the output_type parameter
seisman 4a42c4d
Use pd.DataFrame.from_dict to construct the DataFrame object
seisman de31384
Refactor grdvolume.py
seisman 333c5eb
Refactor select.py
seisman 4e14d30
Merge branch 'validators/output_type' into datatypes/gmtdataset
seisman 061355f
Use validate_output_type
seisman f36448f
Refactor blockm*
seisman 1ca2b76
Refactor filter1d
seisman 2760a21
Fix a bug in filter1d test
seisman e99cd1e
Refactor project.py
seisman 4ff0a15
Refactor the table part of grdhisteq
seisman 1bd46ad
Refactor the table part of triangulate
seisman 48f94cf
Fix a bug in grdhisteq
seisman 49625df
Fix grdhisteq
seisman a3c37fa
Merge branch 'main' into datatypes/gmtdataset
seisman 473dc7b
Fix merge errors
seisman df48ada
grdtrack: Use validate_output_table_type
seisman fd95fa1
Merge branch 'main' into datatypes/gmtdataset
seisman 232973a
Merge branch 'main' into datatypes/gmtdataset
seisman 3b5e4f8
Formatting
seisman 0f1deec
Merge branch 'main' into datatypes/gmtdataset
seisman c1a95b4
Merge branch 'main' into datatypes/gmtdataset
seisman 9f701b7
Merge branch 'main' into datatypes/gmtdataset
seisman 3d5147d
Consistently use column_names
seisman b9454ce
Always convert text data to string dtype
seisman 8742467
Change the to_vectors method to to_dataframe which returns a pd.DataF…
seisman 2a2b607
Merge branch 'main' into datatypes/gmtdataset
seisman 2ca768f
Merge branch 'main' into datatypes/gmtdataset
seisman b7e0823
Requires pandas>=1.2.0
seisman e9de4bb
Fix formatting
seisman b09b13a
Merge branch 'main' into datatypes/gmtdataset
seisman 2cba0c7
Remove pylint directives
seisman 99fc619
Merge branch 'main' into datatypes/gmtdataset
seisman 2baa7af
Merge branch 'main' into datatypes/gmtdataset
seisman 1754e9a
Minor fix
seisman af96106
Merge branch 'main' into datatypes/gmtdataset
seisman d7d0164
Merge branch 'main' into datatypes/gmtdataset
seisman ccb9f47
Merge branch 'main' into datatypes/gmtdataset
seisman 96643ad
Merge branch 'main' into datatypes/gmtdataset
seisman 6ddab7f
Merge branch 'main' into datatypes/gmtdataset
seisman d70a7c4
Rewrap and add type hints
seisman a73927e
Temporarily enable benchmarks
seisman cad0bbe
Merge branch 'main' into datatypes/gmtdataset
seisman 79c499d
Move dataset definition into pygmt/datatypes/dataset.py
seisman c4d47db
Remove unused imports
seisman 1fdb9f9
Merge branch 'main' into datatypes/gmtdataset
seisman 76a09f0
Fix open_virtual_file to open_virtualfile
seisman 9a035ef
Improve docstrings
seisman 828c9c1
Add doctests for virtualfile_to_data
seisman 4a5eea3
isort
seisman a878635
clib.Session: Add the virtualfile_to_data method for creating virtual…
seisman c72701e
Improve docstrings
seisman 761aff4
Improve the return_table function
seisman 279eeb4
column_names default to None
seisman e933497
Update select
seisman d1f3150
Update blockm
seisman 77739f8
Update grdtrack
seisman 4815c59
Merge branch 'virtualfile_to_data' into datatypes/gmtdataset
seisman 2b1d565
Remove the old codes
seisman 9ddca59
Merge branch 'main' into datatypes/gmtdataset
seisman a21b2df
Revert non-related changes and focus on the _GMT_DATASET class
seisman 180f3ec
Minor fixes and improvements
seisman 84b3bf4
Merge branch 'main' into datatypes/gmtdataset
seisman 6e71924
Merge branch 'main' into datatypes/gmtdataset
seisman 08be754
Merge branch 'main' into datatypes/gmtdataset
seisman cc5c4ec
Move the object->str conversion of text column to the to_dataframe me…
seisman f654c93
Merge branch 'main' into datatypes/gmtdataset
seisman e5698a5
Merge branch 'main' into datatypes/gmtdataset
seisman 661af0b
Apply suggestions from code review
seisman 394a054
Update pygmt/datatypes/dataset.py
seisman 63ed85f
Merge branch 'main' into datatypes/gmtdataset
seisman 17d2b4c
Remove a blank line
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
""" | ||
GMT data types for ctypes. | ||
|
||
See the GMT source code gmt_resources.h for the original C struct definitions. | ||
""" | ||
import ctypes as ctp | ||
|
||
|
||
class GMT_DATASEGMENT(ctp.Structure): | ||
""" | ||
For holding segment lines in memory. | ||
""" | ||
|
||
_fields_ = [ | ||
("n_rows", ctp.c_uint64), # Number of points in this segment | ||
("n_columns", ctp.c_uint64), # Number of fields in each record (>= 2) | ||
("min", ctp.POINTER(ctp.c_double)), # Minimum coordinate for each column | ||
("max", ctp.POINTER(ctp.c_double)), # Maximum coordinate for each column | ||
# Data x, y, and possibly other columns | ||
("data", ctp.POINTER(ctp.POINTER(ctp.c_double))), | ||
("label", ctp.c_char_p), # Label string (if applicable) | ||
("header", ctp.c_char_p), # Segment header (if applicable) | ||
("text", ctp.POINTER(ctp.c_char_p)), # text beyond the data | ||
("hidden", ctp.c_void_p), # Book-keeping variables "hidden" from the API | ||
] | ||
|
||
|
||
class GMT_DATATABLE(ctp.Structure): | ||
""" | ||
To hold an array of line segment structures and header information in one | ||
container. | ||
""" | ||
|
||
_fields_ = [ | ||
("n_headers", ctp.c_uint), # Number of file header records (0 if no header) | ||
("n_columns", ctp.c_uint64), # Number of columns (fields) in each record | ||
("n_segments", ctp.c_uint64), # Number of segments in the array | ||
("n_records", ctp.c_uint64), # Total number of data records across all segments | ||
("min", ctp.POINTER(ctp.c_double)), # Minimum coordinate for each column | ||
("max", ctp.POINTER(ctp.c_double)), # Maximum coordinate for each column | ||
# Array with all file header records, if any | ||
("header", ctp.POINTER(ctp.c_char_p)), | ||
# Pointer to array of segments | ||
("segment", ctp.POINTER(ctp.POINTER(GMT_DATASEGMENT))), | ||
("hidden", ctp.c_void_p), # Book-keeping variables "hidden" from the API | ||
] | ||
|
||
|
||
class GMT_DATASET(ctp.Structure): | ||
""" | ||
Single container for an array of GMT tables (files). | ||
""" | ||
|
||
_fields_ = [ | ||
("n_tables", ctp.c_uint64), # The total number of tables (files) contained | ||
("n_columns", ctp.c_uint64), # The number of data columns | ||
("n_segments", ctp.c_uint64), # The total number of segments across all tables | ||
# The total number of data records across all tables | ||
("n_records", ctp.c_uint64), | ||
("min", ctp.POINTER(ctp.c_double)), # Minimum coordinate for each column | ||
("max", ctp.POINTER(ctp.c_double)), # Maximum coordinate for each column | ||
# Pointer to array of tables | ||
("table", ctp.POINTER(ctp.POINTER(GMT_DATATABLE))), | ||
# The datatype (numerical, text, or mixed) of this dataset | ||
("type", ctp.c_int32), | ||
("geometry", ctp.c_int32), # The geometry of this dataset | ||
# To store a referencing system string in PROJ.4 format | ||
("ProjRefPROJ4", ctp.c_char_p), | ||
# To store a referencing system string in WKT format | ||
("ProjRefWKT", ctp.c_char_p), | ||
("ProjRefEPSG", ctp.c_int), # To store a referencing system EPSG code | ||
("hidden", ctp.c_void_p), # Book-keeping variables "hidden" from the API | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.