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 rose #794

Merged
merged 124 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
728eec4
Wrap rose
michaelgrund Jan 17, 2021
49044ff
Create test_rose.py
michaelgrund Jan 17, 2021
009dc41
Update index.rst
michaelgrund Jan 17, 2021
dc999d2
[format-command] fixes
actions-bot Jan 17, 2021
048cfa0
Update base_plotting.py
michaelgrund Jan 17, 2021
09fb0e1
Update base_plotting.py
michaelgrund Jan 17, 2021
f33fd7d
updated docstrings
michaelgrund Jan 17, 2021
5aa59c6
add baseline plots for testing rose
michaelgrund Jan 18, 2021
8d368db
Update base_plotting.py
michaelgrund Jan 18, 2021
39c64ec
[format-command] fixes
actions-bot Jan 18, 2021
132757a
Merge branch 'master' into patch-2
michaelgrund Jan 19, 2021
2c69ce8
corrected typos
Jan 19, 2021
4772972
updated tests
Jan 19, 2021
d699e62
updated test_rose.py
michaelgrund Jan 20, 2021
4c48b7c
removed pytest from test_rose.py
michaelgrund Jan 20, 2021
70cd244
Update pygmt/base_plotting.py
michaelgrund Jan 22, 2021
9a24db9
updated docstrings
michaelgrund Jan 22, 2021
e803b8f
updated docstrings
michaelgrund Jan 22, 2021
fce3503
updated docstrings
michaelgrund Jan 22, 2021
3f398ff
updated docstrings
michaelgrund Jan 22, 2021
6aeeabc
Merge branch 'master' into patch-2
michaelgrund Jan 23, 2021
f91bdae
update
michaelgrund Jan 23, 2021
1c10e3f
Merge branch 'patch-2' of https://github.com/michaelgrund/pygmt into …
michaelgrund Jan 23, 2021
405ee62
updated format
michaelgrund Jan 23, 2021
93b5320
updated
michaelgrund Jan 23, 2021
f5a611f
adjusted aliases according to the rose wrapper for Julia
michaelgrund Jan 24, 2021
7db6f13
corrected typo
michaelgrund Jan 24, 2021
9f24e7b
adjustments to handle input if 'inquire' = True
michaelgrund Jan 26, 2021
9fb5979
added some modifications and a gallery example
michaelgrund Jan 27, 2021
86bfdb2
Merge branch 'master' into patch-2
michaelgrund Jan 27, 2021
e12c2a0
updates
michaelgrund Jan 27, 2021
8fb7896
updates
michaelgrund Jan 27, 2021
e61ba24
added missing import
michaelgrund Jan 27, 2021
2befeb4
added test for bools
michaelgrund Jan 28, 2021
538a76a
Merge branch 'master' into patch-2
michaelgrund Jan 29, 2021
566b51d
Merge branch 'master' into patch-2
michaelgrund Jan 29, 2021
04d8ab0
move rose function from base_plotting.py to rose.py
michaelgrund Jan 29, 2021
24de7a0
Merge branch 'patch-2' of https://github.com/michaelgrund/pygmt into …
michaelgrund Jan 29, 2021
caea72c
Merge branch 'master' into patch-2
michaelgrund Jan 29, 2021
cbf969f
Merge branch 'master' into patch-2
michaelgrund Jan 30, 2021
bffd365
Update pygmt/src/rose.py
michaelgrund Jan 31, 2021
96a52b5
Merge branch 'master' into patch-2
michaelgrund Jan 31, 2021
9855d68
adjustments based on review
michaelgrund Jan 31, 2021
abd4fb5
test updates
michaelgrund Jan 31, 2021
e54ab13
added 'diameter' argument to gallery example
michaelgrund Jan 31, 2021
dfbc352
Update pygmt/base_plotting.py
michaelgrund Feb 1, 2021
acd1bfb
Update pygmt/base_plotting.py
michaelgrund Feb 1, 2021
b52b2c6
updates
michaelgrund Feb 1, 2021
7707e85
Update pygmt/src/rose.py
michaelgrund Feb 7, 2021
fd9f7aa
merge master into patch-2
michaelgrund Feb 7, 2021
54b9d5d
updated figure.py
michaelgrund Feb 7, 2021
ef1fb86
updated branch
michaelgrund Feb 10, 2021
227c067
Merge branch 'master' into patch-2
michaelgrund Feb 11, 2021
8b9fe59
update to avoid pylint warnings
michaelgrund Feb 11, 2021
d677e91
Merge branch 'master' into patch-2
michaelgrund Feb 11, 2021
939c7e8
Merge branch 'master' into patch-2
michaelgrund Feb 12, 2021
edbfd7e
Merge branch 'master' into patch-2
michaelgrund Feb 12, 2021
b4b9be7
Merge branch 'master' into patch-2
michaelgrund Feb 13, 2021
dec9116
Merge branch 'master' into patch-2
michaelgrund Feb 19, 2021
e4cd8c2
Merge branch 'master' into patch-2
michaelgrund Feb 20, 2021
29ef52e
Merge branch 'master' into patch-2
michaelgrund Feb 28, 2021
b12f4c1
Merge branch 'master' into patch-2
michaelgrund Mar 2, 2021
27f7b55
Merge branch 'master' into patch-2
michaelgrund Mar 4, 2021
14b4e88
Merge branch 'master' into patch-2
michaelgrund Mar 18, 2021
a96347d
moved rose gallery example to new embellishments folder
michaelgrund Mar 18, 2021
99cf74a
adjusted how data will be passed into module
michaelgrund Mar 19, 2021
ed3ea86
formatting
michaelgrund Mar 19, 2021
155641d
Merge branch 'master' into patch-2
michaelgrund Mar 21, 2021
db9bf9a
updated rose.py and added comments to gallery example
michaelgrund Mar 21, 2021
c24302c
Merge branch 'master' into patch-2
michaelgrund Mar 21, 2021
929480f
Merge branch 'master' into patch-2
michaelgrund Mar 21, 2021
309e454
Merge branch 'master' into patch-2
michaelgrund Mar 22, 2021
adfb515
Update pygmt/src/rose.py
michaelgrund Mar 22, 2021
9296640
Update pygmt/src/rose.py
michaelgrund Mar 22, 2021
7b205d2
Update pygmt/src/rose.py
michaelgrund Mar 22, 2021
ebb7f5b
Update pygmt/src/rose.py
michaelgrund Mar 22, 2021
d438269
[format-command] fixes
actions-bot Mar 22, 2021
07335c7
Merge branch 'master' into patch-2
michaelgrund Mar 23, 2021
a48adf6
Merge branch 'master' into patch-2
michaelgrund Mar 24, 2021
cd57a33
Merge branch 'master' into patch-2
michaelgrund Mar 25, 2021
185a995
added test plots into DVC
michaelgrund Mar 25, 2021
6eb3c41
adjusted tests for rose
michaelgrund Mar 25, 2021
fde3583
Merge branch 'master' into patch-2
michaelgrund Mar 25, 2021
d4523e6
formatting
michaelgrund Mar 25, 2021
0a64131
updated gallery example
michaelgrund Mar 25, 2021
a60393f
Merge branch 'master' into patch-2
michaelgrund Mar 26, 2021
9556c60
Merge branch 'master' into patch-2
michaelgrund Mar 26, 2021
27a2c49
Merge branch 'master' into patch-2
michaelgrund Mar 26, 2021
151164e
Merge branch 'master' into patch-2
michaelgrund Mar 29, 2021
7503be5
Merge branch 'master' into patch-2
michaelgrund Mar 30, 2021
62679e6
Merge branch 'master' into patch-2
michaelgrund Mar 30, 2021
62193a2
Merge branch 'master' into patch-2
michaelgrund Mar 31, 2021
374eef7
updates based on code review
michaelgrund Mar 31, 2021
3ecc451
Update examples/gallery/embellishments/rose.py
michaelgrund Mar 31, 2021
683b3ba
updates based on code review
michaelgrund Mar 31, 2021
e0ac586
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
50acec1
Merge branch 'master' into patch-2
michaelgrund Mar 31, 2021
08a1b94
updates based on code review from seisman
michaelgrund Mar 31, 2021
2a5ae8a
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
8da61b0
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
e4f5fe9
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
4049d45
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
209917f
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
b677cfa
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
524a500
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
285b2e6
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
1dd2838
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
cd6d4e8
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
f6a5061
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
dcebf12
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
fb2d3df
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
21ff7fb
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
5120edb
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
88d0160
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
f25d34b
formatting
michaelgrund Mar 31, 2021
473bc3e
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
c310ffa
removed -I option and if query, adjusted gallery example
michaelgrund Mar 31, 2021
b6ff595
Update pygmt/src/rose.py
michaelgrund Mar 31, 2021
93eb24e
Apply suggestions from code review
weiji14 Apr 1, 2021
950709e
Update pygmt/src/rose.py
weiji14 Apr 1, 2021
7789ee3
Remove whitespace before return fig
weiji14 Apr 1, 2021
9c62d4b
Merge branch 'master' into patch-2
Apr 1, 2021
da6b829
Use pytest fixtures for sample data to test rose
weiji14 Apr 1, 2021
415fde4
Merge branch 'master' into patch-2
michaelgrund Apr 1, 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
1 change: 1 addition & 0 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Plotting data and laying out the map:
Figure.shift_origin
Figure.text
Figure.meca
Figure.rose

Color palette table generation:

Expand Down
209 changes: 209 additions & 0 deletions pygmt/base_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1962,3 +1962,212 @@ def update_pointers(data_pointers):
with file_context as fname:
arg_str = " ".join([fname, build_arg_string(kwargs)])
lib.call_module("meca", arg_str)

@fmt_docstring
@use_alias(
A="sector_width",
B="frame",
C="cmap",
D="shift_sectors",
Em="plot_vectors",
F="no_scalebar",
G="color",
I="inquire",
JX="diameter",
L="labels",
M="vector_params",
Q="conf_level",
R="region",
S="norm",
T="orient_data",
U="timestamp",
V="verbose",
W="pen",
X="xshift",
Y="yshift",
Z="scale",
i="columns",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
def rose(self, length=None, azimuth=None, data=None, **kwargs):
"""
Plot windrose diagram or polar histogram (sector diagram or rose
diagram) based on length-azimuth data pairs. Options include full
circle and half circle plots. The outline of the windrose is drawn
with the same color as *MAP_DEFAULT_PEN* (see
:gmt-docs:`gmt.conf.html#term-MAP_DEFAULT_PEN`).

Full option list at :gmt-docs:`rose.html`

{aliases}

Parameters
----------

length/azimuth : float or 1d arrays
The length and azimuth values, or arrays of length and azimuth
values

data : str or 2d array
Either a data file name or a 2d numpy array with the tabular data.
Use option *columns* (i) to choose which columns are length and
azimuth, respectively. If a file with only azimuths are given,
use **columns** to indicate the single column with azimuths; then
all lengths are set to unity (see ``scale = 'u'`` to set actual
lengths to unity as well).

orient_data : bool
Specifies that the input data are orientation data (i.e., have a
180 degree ambiguity) instead of true 0-360 degree directions
[Default]. We compensate by counting each record twice: First as
azimuth and second as azimuth +180. Ignored if range is given as
-90/90 or 0/180.

region : str or list
*Required if this is the first plot command*. ``'r0/r1/az0/az1'``.
Specifies the ‘region’ of interest in (*r*,*azimuth*) space. Here,
*r0* is 0, *r1* is max length in units. For *az0* and *az1*,
specify either -90/90 or 0/180 for half circle plot or 0/360 for
full circle.

diameter : str
Sets the diameter of the rose diagram. Only this form of the
projection machinery is supported for this module. If not given,
then we default to a diameter of 7.5 cm.

sector_width : str
Gives the sector width in degrees for sector and rose diagram.
Default ``'0'`` means windrose diagram. Append *r* to draw rose
diagram instead of sector diagram (e.g. ``'10r'``).

norm : bool
Normalize input radii (or bin counts if **sector_width** is used)
by the largest value so all radii (or bin counts) range from 0
to 1.

frame : str
Set map boundary frame and axes attributes. Remember that *x*
here is radial distance and *y* is azimuth. The ylabel may be
used to plot a figure caption. The scale bar length is determined
by the radial gridline spacing.

scale : float or str
Multiply the data radii by scale. E.g., use ``scale = 0.001`` to
convert your data from m to km. To exclude the radii from
consideration, set them all to unity with ``scale = 'u'`` [Default
is no scaling].

columns : str or 1d array
Select input columns and transformations. E.g. choose
``columns = [1, 0]`` or ``columns = '1,0'`` if the length values
are stored in the second column and the direction (azimuth)
values in the first one. Note: zero-based indexing is used.

color : str
Selects shade, color or pattern for filling the sectors. Default
is no fill.

cmap : str
Give a CPT. The *r*-value for each sector is used to look-up the
sector color. Cannot be used with a rose diagram.

pen : str
Set pen attributes for sector outline or rose plot, e.g.
``pen = '0.5p'``. [Default is no outline]. To change pen used to
draw vector (requires **plot_vectors**) [Default is same as sector
outline] use e.g. ``pen = 'v0.5p'``.

labels : str
``'wlabel,elabel,slabel,nlabel'``. Specify labels for the 0, 90,
180, and 270 degree marks. For full-circle plot the default is
WEST,EAST,SOUTH,NORTH and for half-circle the default is
90W,90E,-,0. A **-** in any entry disables that label
(e.g. ``labels = 'W,E,-,N'``). Use ``labels = ''`` to disable
all four labels. Note that the *GMT_LANGUAGE* setting will
affect the words used.

no_scalebar : bool
Do NOT draw the scale length bar (``no_scalebar = True``).
Default plots scale in lower right corner provided **frame**
is used.

shift_sectors : bool
Shift sectors so that they are centered on the bin interval
(e.g., first sector is centered on 0 degrees).

plot_vectors : str
``plot_vectors = 'mode_file'``. Plot vectors showing the
principal directions given in the *mode_file* file.
Alternatively, specify **plot_vectors** to compute and plot
mean direction. See **vector_params** to control the vector
attributes. Finally, to instead save the computed mean
direction and other statistics, use
``plot_vectors = '+wmode_file'``. The eight items saved to
a single record are: *mean_az*, *mean_r*, *mean_resultant*,
*max_r*, *scaled_mean_r*, *length_sum*, *n*, *sign@alpha*,
where the last term is 0 or 1 depending on whether the mean
resultant is significant at the level of confidence set via
**conf_level**.

vector_params : str
Used with **plot_vectors** to modify vector parameters. For
vector heads, append vector head size [Default is 0, i.e., a
line]. See VECTOR ATTRIBUTES under :gmt-docs:`rose.html` for
specifying additional attributes. If **plot_vectors** is not
given and the current plot mode is to draw a windrose diagram
then using **vector_params** will add vector heads to all
individual directions using the supplied attributes.

conf_level : float or str
Sets the confidence level used to determine if the mean
resultant is significant (i.e., Lord Rayleigh test for
uniformity) [``conf_level = 0.05``]. Note: The critical
values are approximated [Berens, 2009] and requires at
least 10 points; the critical resultants are accurate to at
least 3 significant digits. For smaller data sets you
should consult exact statistical tables.

Berens, P., 2009, CircStat: A MATLAB Toolbox for Circular
Statistics, *J. Stat. Software*, 31(10), 1-21,
10.18637/jss.v031.i10.

inquire :
Inquire. Computes statistics needed to specify a useful
**frame**. No plot is generated. The following statistics
are written to stdout: *n*, *mean az*, *mean r*, *mean
resultant length*, *max bin sum*, *scaled mean*, and
*linear length sum*.

{U}
{V}
{XY}
{p}
{t}

"""

kwargs = self._preprocess(**kwargs)

kind = data_kind(data, length, azimuth)

extra_arrays = []
if "t" in kwargs and is_nonstr_iter(kwargs["t"]):
extra_arrays.append(kwargs["t"])
kwargs["t"] = ""

with Session() as lib:
# Choose how data will be passed in to the module
if kind == "file":
file_context = dummy_context(data)
elif kind == "matrix":
file_context = lib.virtualfile_from_matrix(data)
elif kind == "vectors":
file_context = lib.virtualfile_from_vectors(
np.atleast_1d(length), np.atleast_1d(azimuth), *extra_arrays
)

with file_context as fname:
arg_str = " ".join([fname, build_arg_string(kwargs)])
lib.call_module("rose", arg_str)
Loading