-
Notifications
You must be signed in to change notification settings - Fork 213
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
Universal virtualfile_from_data function to replace virtualfile_from_grid/matrix/vectors #949
Closed
6 tasks done
Labels
Milestone
Comments
5 tasks
This was referenced Mar 3, 2021
I'd add |
5 tasks
5 tasks
5 tasks
This was referenced Jul 8, 2021
Merged
2 tasks
5 tasks
This was referenced Nov 7, 2021
3 tasks
6 tasks
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Description of the desired feature
As a user, I'd like to be able to pass in any type of data into a PyGMT function in a consistent way, be it:
str
type filenamenumpy.ndarray
pandas.DataFrame
matrixgeopandas.GeoDataFrame
(Integration with geopandas to plot shapely geometries #608)xarray.DataArray
grid, or even 1d arrays!Current state
We have a not so nice
if... then
block that currently handles the Input/Output (I/O) of data into PyGMT. This results in an incosistent API. E.g.fig.plot
requiresnumpy.ndarray
inputs whilepygmt.grdtrack
requirespandas.DataFrame
inputs. Users (e.g. at https://forum.generic-mapping-tools.org/t/pygmt-plot-errorbars) should not have to figure out which PyData format is needed.Originally posted by @weiji14 in #946 (comment)
Future state
The idea is to have a
virtualfile_from_data()
function (open to other names) that wraps around the currentdummy_context
/virtualfile_from_matrix
/virtualfile_from_vectors
/virtualfile_from_grid
functions, which makes things easier for both end users and developers wrapping new modules that handle data.This universal
virtualfile_from_data()
may pave the way to support more data inputs in the future:geopandas.GeoDataFrame
inputs, useful forfig.plot
Integration with geopandas to plot shapely geometries #608Trace
/Stream
/Inventory
objects ObsPy integration #967io.StringIO
, useful forfig.legend
RFC Allow for io.StringIO inputs to certain modules #576pint
arrays? Allow passing in a column to plot for error_bars #735TLDR: Be able to throw any sort of data into a PyGMT function and it will 'just work'.
Note that
xarray
is in the process of refactoring to an APIv2 (see pydata/xarray#4309) that has some similarities with this issue. They call it a 'Flexible Backend", a sort of extensible 'plugin'-type system which is a bit more future proofed to allow for new data formats (e.g. GPU backed arrays) coming in.Are you willing to help implement and maintain this feature? Yes, but help is very welcome
Update: The
virtualfile_from_data
function has been created in #961. Feel free people to refactor some of the plotting/data processing functions in https://github.com/GenericMappingTools/pygmt/tree/master/pygmt/src to use this (e.g.contour
,meca
, etc).TODO:
The text was updated successfully, but these errors were encountered: