You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm unsure if "stateful" is the appropriate word here. What I really mean is to let PyGMT keep track of its stats and some information, then later PyGMT calls can know what already happened.
I think the "stats" can be useful in many cases. Here are some quick ideas. Let's say we have a dict pygmt.__stats__ for PyGMT and a dict fig.__stats__ for each Figure instance, which can store anything we want. The variable names have double underscores so they are for internal use only, but it's also possible to make them public to users.
pygmt.__stats__.call_history can be a list of commands that are passed to the GMT API via call_module. The list can be used to generate the equivalent bash script, although we can't handle virtual files and any other Python data structures.
fig.__stats__.projection: the projection of the current figure
fig.__stats__.dimensions: width and height of the current figure/frame/subplot/inset. Users can access these values via public functions, and then can do some mathematic calculates (e.g., to have an inset map with a width of 0.25 * w or shift the plot origin by 1.2 * w (w is the width of current figure stored in fig.__stats__.dimensions)).
I believe there are more interesting ideas about a stateful PyGMT, so thoughts and comments are welcomed.
The text was updated successfully, but these errors were encountered:
I'm unsure if "stateful" is the appropriate word here. What I really mean is to let PyGMT keep track of its stats and some information, then later PyGMT calls can know what already happened.
I think the "stats" can be useful in many cases. Here are some quick ideas. Let's say we have a dict
pygmt.__stats__
for PyGMT and a dictfig.__stats__
for each Figure instance, which can store anything we want. The variable names have double underscores so they are for internal use only, but it's also possible to make them public to users.pygmt.__stats__.call_history
can be a list of commands that are passed to the GMT API viacall_module
. The list can be used to generate the equivalent bash script, although we can't handle virtual files and any other Python data structures.fig.__stats__.projection
: the projection of the current figurefig.__stats__.region
: the region parameter of the current figure (c.f. https://www.pygmt.org/dev/api/generated/pygmt.clib.Session.extract_region.html)fig.__stats__.dimensions
: width and height of the current figure/frame/subplot/inset. Users can access these values via public functions, and then can do some mathematic calculates (e.g., to have an inset map with a width of 0.25 * w or shift the plot origin by 1.2 * w (w is the width of current figure stored infig.__stats__.dimensions
)).I believe there are more interesting ideas about a stateful PyGMT, so thoughts and comments are welcomed.
The text was updated successfully, but these errors were encountered: