Skip to content
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

Wrap velo #525

Merged
merged 61 commits into from
Apr 30, 2021
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e3c296f
add new velo function
lhoupert Jul 14, 2020
c6e3476
create new velo function
lhoupert Jul 14, 2020
c2b951c
format alias
lhoupert Jul 14, 2020
1cf7967
clarify the type of data input
lhoupert Jul 14, 2020
fc7bec8
remove reference to vector x, y (not of use anymore)
lhoupert Jul 14, 2020
7b905d7
clear code from reference to variable sizes and direction
lhoupert Jul 14, 2020
1fcf089
start with test
lhoupert Nov 5, 2020
ac05994
fix raw string
lhoupert Nov 5, 2020
38514ef
update add-velo with upstream master branch and fix issues
lhoupert Nov 5, 2020
fd6e421
clarify aliases and edit test
lhoupert Nov 5, 2020
4858aff
Apply suggestions from code review
lhoupert Nov 6, 2020
099a3d6
update docstring
lhoupert Nov 6, 2020
8c6c0e1
fix errors from make lint
lhoupert Nov 6, 2020
480abd0
remove baseline img
lhoupert Nov 6, 2020
98d5ded
create example and edit test so it fit the example
lhoupert Nov 6, 2020
dea4b1c
Apply suggestions from code review
lhoupert Nov 8, 2020
132995a
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt…
lhoupert Nov 8, 2020
c908e78
Apply suggestions from code review
lhoupert Nov 8, 2020
6e3076a
temporarily disable pylint check as base_plotting.py exceed 2000 lines
lhoupert Nov 8, 2020
6dff809
Merge branch 'add-velo' of https://github.com/lhoupert/pygmt into add…
lhoupert Nov 8, 2020
e5de366
edit gallery example to add text
lhoupert Nov 8, 2020
76c9b28
Apply suggestions from code review
lhoupert Nov 9, 2020
7dccfa9
update baseline test image
lhoupert Nov 9, 2020
1fe7005
Update examples/gallery/plot/velo_arrow_ellipse.py
lhoupert Nov 9, 2020
e2e956c
Apply suggestions from code review
lhoupert Nov 12, 2020
8364134
detect data type
lhoupert Nov 12, 2020
7a9de97
remove scaling as alias
lhoupert Nov 12, 2020
909827a
Revert "remove scaling as alias"
lhoupert Nov 13, 2020
1e5fe88
raise error if alias S is not defined
lhoupert Nov 13, 2020
cfcae90
edit function arguments
lhoupert Nov 13, 2020
92f94f1
edit dataframe check
lhoupert Nov 13, 2020
0e66deb
Merge branch 'master' into add-velo
weiji14 Apr 5, 2021
437e415
Fix velo import errors and do some light code linting
weiji14 Apr 5, 2021
dd24153
Refactor velo to use virtualfile_from_data and add three more unit tests
weiji14 Apr 5, 2021
cc0ef72
Alias panel (c) for velo, and lightly edit some docstrings
weiji14 Apr 5, 2021
34ad182
Merge branch 'master' into add-velo
weiji14 Apr 5, 2021
90e9e0d
Alias scale (H), intensity (I) and zvalue (Z) from GMT 6.2.0
weiji14 Apr 5, 2021
d3850b7
Merge branch 'master' into add-velo
weiji14 Apr 5, 2021
d67bfcd
Fix typos and add intersphinx mappings
weiji14 Apr 5, 2021
c90ec47
Remove dash-colon option to interchange column order
weiji14 Apr 5, 2021
80743aa
[skip ci] Fix a few more typos and indentation issues
weiji14 Apr 5, 2021
2661e2c
Update the frame, region, projection and color of velo example
weiji14 Apr 5, 2021
ef3465e
Merge branch 'master' into add-velo
weiji14 Apr 5, 2021
86cf8a0
Update dvc hash for test_velo_pandas_dataframe
weiji14 Apr 5, 2021
be959fc
Use serial/Oxford comma in velo summary description
weiji14 Apr 5, 2021
0653349
Merge branch 'master' into add-velo
weiji14 Apr 10, 2021
c9f859d
Merge branch 'master' into add-velo
weiji14 Apr 18, 2021
92feb97
Apply suggestions from code review
weiji14 Apr 18, 2021
71d3797
Apply suggestions from code review
weiji14 Apr 20, 2021
9ef3983
Rename alias intensity for -I to shading
weiji14 Apr 20, 2021
88d1c8f
Rename alias facecolor for -G to color
weiji14 Apr 20, 2021
984b4cb
Merge branch 'master' into add-velo
weiji14 Apr 20, 2021
b8a2410
Move docstring for projection (J) and region (R) up a bit
weiji14 Apr 20, 2021
c9c7b66
Merge branch 'master' into add-velo
weiji14 Apr 26, 2021
23e908c
Rename alias to spec (S) and update baseline images for GMT 6.2.0rc1
weiji14 Apr 26, 2021
d33f7a5
Merge branch 'master' into add-velo
weiji14 Apr 30, 2021
6b99454
Fix typo on examples/gallery/symbols/velo_arrow_ellipse.py
weiji14 Apr 30, 2021
f949f16
Mark fig.velo tests with xfail
weiji14 Apr 30, 2021
1064c82
Rename alias uncertainty_color to uncertaintycolor for parameter E
weiji14 Apr 30, 2021
8a7cb44
Merge branch 'master' into add-velo
weiji14 Apr 30, 2021
da9ee3b
Move velo_arrow_ellipse.py under "Seismology and Geodesy" category
weiji14 Apr 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
edit function arguments
  • Loading branch information
lhoupert committed Nov 13, 2020
commit cfcae90a0ae8591b667a6d5f46e62b1b69b1d704
23 changes: 8 additions & 15 deletions pygmt/base_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,15 +1945,15 @@ def update_pointers(data_pointers):
t="transparency",
)
@kwargs_to_strings(R="sequence", i="sequence_comma")
def velo(self, data=None, **kwargs):
def velo(self, data=None, vector="+p1p+e", **kwargs):
"""
Plot velocity vectors, crosses, and wedges

Reads data values from files, numpy array or pandas DataFrame and will
plot velocity arrows on a map. Most options are the same as for plot,
except *scaling*.

Must provide *data* and *scaling*.
Must provide *data*, *projection*, *region* and *scaling*.


Full option list at :gmt-docs:`supplements/geodesy/velo.html`
Expand Down Expand Up @@ -2079,8 +2079,9 @@ def velo(self, data=None, **kwargs):
Other Parameters
----------------
vector : bool or str
Modify vector parameters. For vector heads, append vector head size
[Default is 9p]. For specifying additional attributes, see
Modify vector parameters. By defaul, the vector head outline is
drawn (+p) and a vector head is placed at the end of the vector path
(+e). For specifying additional attributes, see
:gmt-docs:`supplements/geodesy/velo.html#vector-attributes`.

{B}
Expand Down Expand Up @@ -2127,18 +2128,10 @@ def velo(self, data=None, **kwargs):

kind = data_kind(data)

extra_arrays = []
if "G" in kwargs and not isinstance(kwargs["G"], str):
if kind != "vectors":
raise GMTInvalidInput(
"Can't use arrays for color if data is matrix or file."
)
extra_arrays.append(kwargs["G"])
del kwargs["G"]

if "S" in kwargs and not isinstance(kwargs["S"],str):
if "S" not in kwargs or ( "S" in kwargs and not isinstance(kwargs["S"],str)):
raise GMTInvalidInput(
"Scaling is a required and has to be a string."
"Scaling is a required argument and has to be a string."
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding the condition

if "S" not in kwargs

I was hoping triggering an error if scaling was not defined as an argument, for example by calling velo like that:
figtest.velo(data=dataf)

However, it didn't raise any error. It seems that it doesn't run through this part of the code. Any idea why?
Any suggestion on how to write a condition where I want data, scaling, projection and region defined as an argument?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no data is given, this will error out at the kind = data_kind(data) code line (as it requires data to be not None. Also, we don't need to check for projection or region (see #525 (comment)).

However, it didn't raise any error. It seems that it doesn't run through this part of the code. Any idea why?

Not sure, the logic seems ok. Did you try just with if "S" not in kwargs (discarding the 'or' bit)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @weiji14 , it didnt do anything. It seems that if no additional argument is defined (figtest.velo(data=dataf)), this part of the script is not executed . I tried with if 1==1 and nothing appears...

with Session() as lib:
Expand All @@ -2159,7 +2152,7 @@ def velo(self, data=None, **kwargs):
*[data[column] for column in data]
)
else:
raise GMTInvalidInput("Unrecognized data type: {}".format(type(data)))
raise GMTInvalidInput(f"Unrecognized data type: {type(data)}")

with file_context as fname:
arg_str = " ".join([fname, build_arg_string(kwargs)])
Expand Down