Description
Description of the desired feature
The base_plotting.py file (https://github.com/GenericMappingTools/pygmt/blob/v0.2.0/pygmt/base_plotting.py) is the core of PyGMT and home to functions like fig.plot
, fig.grdimage
and so on. However, it has grown wayyyy too long (~2000 lines) and we're hitting pylint recommended limit (cf #525 (comment)), namely C0302: Too many lines in module
.
There will be even more modules coming too! I think we should make things modular and split each pygmt.Figure
function into it's own standalone file like so:
Current state
--pygmt
├── figure.py
└── base_plotting.py (contains `plot`, `grdimage`, `meca`, etc)
New state
--pygmt
├── src (new folder)
| ├── __init__.py
| ├── grdimage.py
| ├── meca.py
| └── *.py (all other `fig.*` modules split out from base_plotting.py)
└── figure.py
This is how GMT (see https://github.com/GenericMappingTools/gmt/tree/6.1/src) and GMT.jl (https://github.com/GenericMappingTools/GMT.jl/tree/master/src) organizes their source code too since there's so many GMT modules (https://docs.generic-mapping-tools.org/latest/modules.html).
Note that we originally had a gmt/modules
folder but that was removed in 252d5df, and the big Figure
class was made because of a decision to use an object orientated style (i.e. fig.plot()
, fig.grdimage()
, etc) at some point in 2017. I believe there should be a way to keep that object orientated style while splitting the class into several files, so this refactor should provide the same functionality for our users going forward.
Transition state
To ease the transition, we can do it chunk by chunk:
- Split off the big supplementary modules (i.e.
meca
) - Split off the grid plotting functions (
grdcontour
,grdimage
,grdview
) - etc
Relevant issues:
meca
- Wrap meca #516velo
- Psvelo [Plot velocity vectors, crosses, and wedges] #510segy
- SEGY Functionality #179
Are you willing to help implement and maintain this feature? Yes