Skip to content

Commit 2ba8420

Browse files
committed
Merge branch 'main' into arg_with_space
2 parents 83c8c3b + 77aaa7a commit 2ba8420

File tree

5 files changed

+108
-10
lines changed

5 files changed

+108
-10
lines changed

.github/workflows/dvc-diff.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: iterative/[email protected]
2323

2424
- name: Setup continuous machine learning (CML)
25-
uses: iterative/[email protected].0
25+
uses: iterative/[email protected].3
2626

2727
- name: Pull image data from cloud storage
2828
run: dvc pull --remote upstream

.github/workflows/publish-to-pypi.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ jobs:
5353
ls -lh dist/
5454
5555
- name: Publish to Test PyPI
56-
uses: pypa/gh-action-pypi-publish@v1.4.2
56+
uses: pypa/gh-action-pypi-publish@v1.5.0
5757
with:
5858
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
5959
repository_url: https://test.pypi.org/legacy/
6060

6161
- name: Publish to PyPI
6262
if: startsWith(github.ref, 'refs/tags')
63-
uses: pypa/gh-action-pypi-publish@v1.4.2
63+
uses: pypa/gh-action-pypi-publish@v1.5.0
6464
with:
6565
password: ${{ secrets.PYPI_API_TOKEN }}
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Generate points along great circles
3+
-----------------------------------
4+
5+
The :meth:`pygmt.project` method can generate points along a great circle
6+
whose center and end points can be defined via the ``center`` and ``endpoint``
7+
parameters, respectively. Using the ``generate`` parameter allows to generate
8+
(*r*, *s*, *p*) points every *dist* units of *p* along a profile as
9+
output. By default all units (*r*, *s* and *p*) are set to degrees while
10+
``unit=True`` allows to set the unit for *p* to km.
11+
"""
12+
13+
import pygmt
14+
15+
fig = pygmt.Figure()
16+
17+
# generate points every 10 degrees along a great circle from 10N,50W to 30N,5W
18+
points1 = pygmt.project(center=[-50, 10], endpoint=[-5, 30], generate=10)
19+
# generate points every 750 km along a great circle from 10N,50W to 57.5N,90W
20+
points2 = pygmt.project(center=[-50, 10], endpoint=[-90, 57.5], generate=750, unit=True)
21+
# generate points every 350 km along a great circle from 10N,50W to 68N,5W
22+
points3 = pygmt.project(center=[-50, 10], endpoint=[-5, 68], generate=350, unit=True)
23+
24+
# create a plot with coast and Mercator projection (M)
25+
fig.basemap(region=[-100, 0, 0, 70], projection="M12c", frame=True)
26+
fig.coast(shorelines=True, area_thresh=5000)
27+
28+
# plot individual points of first great circle as seagreen line
29+
fig.plot(x=points1.r, y=points1.s, pen="2p,seagreen")
30+
# plot individual points as seagreen squares atop
31+
fig.plot(x=points1.r, y=points1.s, style="s.45c", color="seagreen", pen="1p")
32+
33+
# plot individual points of second great circle as orange line
34+
fig.plot(x=points2.r, y=points2.s, pen="2p,orange")
35+
# plot individual points as orange inverted triangles atop
36+
fig.plot(x=points2.r, y=points2.s, style="i.6c", color="orange", pen="1p")
37+
38+
# plot individual points of third great circle as red line
39+
fig.plot(x=points3.r, y=points3.s, pen="2p,red3")
40+
# plot individual points as red circles atop
41+
fig.plot(x=points3.r, y=points3.s, style="c.3c", color="red3", pen="1p")
42+
43+
fig.show()

pygmt/figure.py

+51-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
import base64
55
import os
6+
import warnings
67
from tempfile import TemporaryDirectory
78

89
try:
@@ -129,13 +130,14 @@ def region(self):
129130
C="gs_option",
130131
E="dpi",
131132
F="prefix",
132-
I="icc_gray",
133+
I="resize",
134+
N="bb_style",
133135
T="fmt",
134136
Q="anti_aliasing",
135137
V="verbose",
136138
)
137139
@kwargs_to_strings()
138-
def psconvert(self, **kwargs):
140+
def psconvert(self, icc_gray=False, **kwargs):
139141
r"""
140142
Convert [E]PS file(s) to other formats.
141143
@@ -153,9 +155,14 @@ def psconvert(self, **kwargs):
153155
Parameters
154156
----------
155157
crop : str or bool
156-
Adjust the BoundingBox and HiResBoundingBox to the minimum required
157-
by the image content. Append ``u`` to first remove any GMT-produced
158-
time-stamps. Default is True.
158+
Adjust the BoundingBox and HiResBoundingBox to the minimum
159+
required by the image content. Default is True. Append **+u** to
160+
first remove any GMT-produced time-stamps. Append **+r** to
161+
*round* the HighResBoundingBox instead of using the ``ceil``
162+
function. This is going against Adobe Law but can be useful when
163+
creating very small images where the difference of one pixel
164+
might matter. If ``verbose`` is used we also report the
165+
dimensions of the final illustration.
159166
gs_option : str
160167
Specify a single, custom option that will be passed on to
161168
GhostScript as is.
@@ -167,8 +174,33 @@ def psconvert(self, **kwargs):
167174
using the input names as base, which are appended with an
168175
appropriate extension. Use this option to provide a different name,
169176
but without extension. Extension is still determined automatically.
170-
icc_gray : bool
171-
Enforce gray-shades by using ICC profiles.
177+
resize : str
178+
[**+m**\ *margins*][**+s**\ [**m**]\ *width*\
179+
[/\ *height*]][**+S**\ *scale*] ].
180+
Adjust the BoundingBox and HiResBoundingBox by scaling and/or
181+
adding margins. Append **+m** to specify extra margins to extend
182+
the bounding box. Give either one (uniform), two (x and y) or four
183+
(individual sides) margins; append unit [Default is set by
184+
:term:`PROJ_LENGTH_UNIT`]. Append **+s**\ *width* to resize the
185+
output image to exactly *width* units. The default unit is set
186+
by :term:`PROJ_LENGTH_UNIT` but you can append a new unit and/or
187+
impose different width and height (**Note**: This may change the
188+
image aspect ratio). What happens here is that Ghostscript will do
189+
the re-interpolation work and the final image will retain the DPI
190+
resolution set by ``dpi``. Append **+sm** to set a maximum size
191+
and the new *width* is only imposed if the original figure width
192+
exceeds it. Append /\ *height* to also impose a maximum height in
193+
addition to the width. Alternatively, append **+S**\ *scale* to
194+
scale the image by a constant factor.
195+
bb_style : str
196+
Set optional BoundingBox fill color, fading, or draw the outline
197+
of the BoundingBox. Append **+f**\ *fade* to fade the entire plot
198+
towards black (100%) [no fading, 0]. Append **+g** \*paint* to
199+
paint the BoundingBox behind the illustration and append **+p**\
200+
[*pen*] to draw the BoundingBox outline (append a pen or accept
201+
the default pen of 0.25p,black). Note: If both **+g** and **+f**
202+
are used then we use paint as the fade color instead of black.
203+
Append **+i** to enforce gray-shades by using ICC profiles.
172204
anti_aliasing : str
173205
[**g**\|\ **p**\|\ **t**\][**1**\|\ **2**\|\ **4**].
174206
Set the anti-aliasing options for **g**\ raphics or **t**\ ext.
@@ -192,6 +224,18 @@ def psconvert(self, **kwargs):
192224
# Default cropping the figure to True
193225
if "A" not in kwargs:
194226
kwargs["A"] = ""
227+
228+
if icc_gray:
229+
msg = (
230+
"The 'icc_gray' parameter has been deprecated since v0.6.0"
231+
" and will be removed in v0.8.0."
232+
)
233+
warnings.warn(msg, category=FutureWarning, stacklevel=2)
234+
if "N" not in kwargs:
235+
kwargs["N"] = "+i"
236+
else:
237+
kwargs["N"] += "+i"
238+
195239
# Manually handle prefix -F argument so spaces aren't converted to \040
196240
# by build_arg_string function. For more information, see
197241
# https://github.com/GenericMappingTools/pygmt/pull/1487

pygmt/tests/test_figure.py

+11
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,14 @@ def test_figure_set_display_invalid():
252252
"""
253253
with pytest.raises(GMTInvalidInput):
254254
set_display(method="invalid")
255+
256+
257+
def test_figure_icc_gray():
258+
"""
259+
Check if icc_gray parameter works correctly if used.
260+
"""
261+
fig = Figure()
262+
fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True)
263+
with pytest.warns(expected_warning=FutureWarning) as record:
264+
fig.psconvert(icc_gray=True, prefix="Test")
265+
assert len(record) == 1 # check that only one warning was raised

0 commit comments

Comments
 (0)