Skip to content

Wrap velo#525

Merged
weiji14 merged 61 commits into
GenericMappingTools:masterfrom
lhoupert:add-velo
Apr 30, 2021
Merged

Wrap velo#525
weiji14 merged 61 commits into
GenericMappingTools:masterfrom
lhoupert:add-velo

Conversation

@lhoupert

@lhoupert lhoupert commented Jul 14, 2020

Copy link
Copy Markdown
Contributor

Adding the velo function! Original GMT velo function can be found at https://docs.generic-mapping-tools.org/latest/supplements/geodesy/velo.html.

Live documentation preview: https://pygmt-git-fork-lhoupert-add-velo-gmt.vercel.app/api/generated/pygmt.Figure.velo.html
Gallery example preview: https://pygmt-git-fork-lhoupert-add-velo-gmt.vercel.app/gallery/seismology/velo_arrow_ellipse.html

I followed advice from @weiji14 [see the feature request I opened here]. I implemented the function by mostly copy-modify-pasted from plot and edited the doc string. The options for velo are quite different from plot so most of the parameters were changed.

Problems encountered
I need help to understand how pygmt is handling the dataframe data. The gmt velo function requires the argument table (One or more ASCII (or binary, see -bi[ncols][type]) data table file(s) holding a number of data columns. If no tables are given then we read from standard input.). My opinion is that in pygmt, Figure.velo should reads data values from files, numpy array or panda dataframe.

Can someone help to figure out what should be the pygmt code to run the gmt example given at the end of my request?

I converted the table from standard input into a panda dataframe:

data={'Long.': {0: 0, 1: -8, 2: 0, 3: -5, 4: 5, 5: 0}, 
    ...:  'Lat.': {0: -8, 1: 5, 2: 0, 3: -5, 4: 0, 5: -5}, 
    ...:  'Evel': {0: 0, 1: 3, 2: 4, 3: 6, 4: -6, 5: 6}, 
    ...:  'Nvel': {0: 0, 1: 3, 2: 6, 3: 4, 4: 4, 5: -4}, 
    ...:  'Esig': {0: 4, 1: 0, 2: 4, 3: 6, 4: 6, 5: 6}, 
    ...:  'Nsig': {0: 6, 1: 0, 2: 6, 3: 4, 4: 4, 5: 4}, 
    ...:  'CorEN': {0: 0.5, 1: 0.5, 2: 0.5, 3: 0.5, 4: -0.5, 5: -0.5}, 
    ...:  'SITE': {0: '4x6', 1: '3x3', 2: 'NaN', 3: '6x4', 4: '-6x4', 5: '6x-4'}}  

df1 = pd.DataFrame(data)

Original GMT example for velo (more details here)
The following should make big red arrows with green ellipses outlined in red. Note that the 39% confidence scaling will give an ellipse which fits inside a rectangle of dimension Esig by Nsig.

gmt psvelo << END -h2 -R-10/10/-10/10 -W0.25p,red -Ggreen -L -Se0.2/0.39/18 \
    -B1g1 -Jx0.4/0.4 -A0.3p -P -V > test.ps
#Long. Lat. Evel Nvel Esig Nsig CorEN SITE
#(deg) (deg) (mm/yr) (mm/yr)
0. -8. 0.0 0.0 4.0 6.0 0.500 4x6
-8. 5. 3.0 3.0 0.0 0.0 0.500 3x3
0. 0. 4.0 6.0 4.0 6.0 0.500
-5. -5. 6.0 4.0 6.0 4.0 0.500 6x4
5. 0. -6.0 4.0 6.0 4.0 -0.500 -6x4
0. -5. 6.0 -4.0 6.0 4.0 -0.500 6x-4
END

test2

Fixes #510

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Brand new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Psvelo [Plot velocity vectors, crosses, and wedges]

8 participants