-
Notifications
You must be signed in to change notification settings - Fork 214
/
test_rose.py
182 lines (158 loc) · 4.22 KB
/
test_rose.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
"""
Test Figure.rose.
"""
import numpy as np
import pytest
from pygmt import Figure
from pygmt.datasets import load_sample_data
@pytest.fixture(scope="module", name="data")
def fixture_data():
"""
Load the sample numpy array data.
"""
return np.array(
[[40, 60], [60, 300], [20, 180], [30, 190], [60, 90], [40, 110], [80, 125]]
)
@pytest.fixture(scope="module", name="data_fractures_compilation")
def fixture_data_fractures_compilation():
"""
Load the sample fractures compilation dataset which contains fracture lengths and
azimuths as hypothetically digitized from geological maps.
Lengths are stored in the first column, azimuths in the second.
"""
return load_sample_data(name="fractures")
@pytest.mark.mpl_image_compare
def test_rose_data_file(data_fractures_compilation):
"""
Test supplying data from sample dataset.
"""
fig = Figure()
fig.rose(
data=data_fractures_compilation,
region=[0, 1, 0, 360],
sector=15,
diameter="5.5c",
fill="blue",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
pen="1p",
norm="",
scale=0.4,
)
return fig
@pytest.mark.mpl_image_compare
def test_rose_2d_array_single():
"""
Test supplying a 2-D numpy array containing a single pair of lengths and directions.
"""
data = np.array([[40, 60]])
fig = Figure()
fig.rose(
data=data,
region=[0, 1, 0, 360],
sector=10,
diameter="5.5c",
fill="cyan",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
pen="1p",
norm=True,
scale=0.4,
)
return fig
@pytest.mark.mpl_image_compare
def test_rose_2d_array_multiple(data):
"""
Test supplying a 2-D numpy array containing a list of lengths and directions.
"""
fig = Figure()
fig.rose(
data=data,
region=[0, 1, 0, 360],
sector=10,
diameter="5.5c",
fill="blue",
frame=["x0.2g0.2", "y30g30", "+gmoccasin"],
pen="1p",
norm=True,
scale=0.4,
)
return fig
@pytest.mark.benchmark
@pytest.mark.mpl_image_compare
def test_rose_plot_data_using_cpt(data):
"""
Test supplying a 2-D numpy array containing a list of lengths and directions.
Use a cmap to color sectors.
"""
fig = Figure()
fig.rose(
data=data,
region=[0, 1, 0, 360],
sector=15,
diameter="5.5c",
cmap="batlow",
frame=["x0.2g0.2", "y30g30", "+gdarkgray"],
pen="1p",
norm=True,
scale=0.4,
)
return fig
@pytest.mark.mpl_image_compare
def test_rose_plot_with_transparency(data_fractures_compilation):
"""
Test supplying the sample fractures compilation dataset to the data parameter.
Use transparency.
"""
fig = Figure()
fig.rose(
data=data_fractures_compilation,
region=[0, 1, 0, 360],
sector=15,
diameter="5.5c",
fill="blue",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
pen="1p",
norm=True,
scale=0.4,
transparency=50,
)
return fig
@pytest.mark.mpl_image_compare
def test_rose_no_sectors(data_fractures_compilation):
"""
Test supplying the sample fractures compilation dataset to the data parameter.
Plot data without defining a sector width, add a title and rename labels.
"""
fig = Figure()
fig.rose(
data=data_fractures_compilation,
region=[0, 500, 0, 360],
diameter="10c",
labels="180/0/90/270",
frame=["xg100", "yg45", "+tWindrose diagram"],
pen="1.5p,red3",
transparency=40,
scale=0.5,
)
return fig
@pytest.mark.mpl_image_compare
def test_rose_bools(data_fractures_compilation):
"""
Test supplying the sample fractures compilation dataset to the data parameter.
Test bools.
"""
fig = Figure()
fig.rose(
data=data_fractures_compilation,
region=[0, 1, 0, 360],
sector=10,
diameter="10c",
frame=["x0.2g0.2", "y30g30", "+glightgray"],
fill="red3",
pen="1p",
orientation=False,
norm=True,
vectors=True,
no_scale=True,
shift=False,
)
return fig