Skip to content

Migrate Figure.coast tests to dvc #1102

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

Closed
wants to merge 118 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
27f5d20
Add cyl_transverse_mercator.py
willschlitzer Dec 11, 2020
d64983f
Add cyl_universal_transverse_mercator.py
willschlitzer Dec 11, 2020
6ba8185
Changing land color to red in cyl_mercator.py to match GMT docs examp…
willschlitzer Dec 11, 2020
76850ee
Merge branch 'master' into cylindrical-projections
willschlitzer Dec 13, 2020
48431db
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 12, 2021
01052d2
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 18, 2021
c710988
Merge remote-tracking branch 'origin/master'
willschlitzer Jan 21, 2021
b94e0a2
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 21, 2021
413fec1
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 22, 2021
be51e2c
Merge branch 'master' of https://github.com/GenericMappingTools/pygmt
willschlitzer Jan 22, 2021
bc05e5b
Initial add of solar function to base_plotting.py
willschlitzer Jan 23, 2021
219ba77
Add fill and day_night parameter doc string
willschlitzer Jan 24, 2021
83417d7
Add additional parameters
willschlitzer Jan 24, 2021
a68f21d
Add terminator doc strings
willschlitzer Jan 24, 2021
43b75c8
Add timestamp to doc string
willschlitzer Jan 24, 2021
7b65d42
Add test_solar to test_solar.py
willschlitzer Jan 24, 2021
58add00
Add test_solar_coast to test_solar.py
willschlitzer Jan 24, 2021
a5e808b
Add test_solar_pen to test_solar.py
willschlitzer Jan 24, 2021
9cd30db
Add test_solar_civil_twighlight and test_solar_nautical_twighlight to…
willschlitzer Jan 24, 2021
9c1221e
Add test_solar_astronomical_twighlight to test_solar.py
willschlitzer Jan 24, 2021
de414f7
Add test_solar_fill_transparency to test_solar.py
willschlitzer Jan 24, 2021
8887811
Add 5 tests to test_solar.py
willschlitzer Jan 24, 2021
cc02480
Update solar doc string in base_plotting.py
willschlitzer Jan 24, 2021
62c43d7
Add solar to api/index.rst
willschlitzer Jan 24, 2021
01d0a9b
Removing time zone mention until fixed in upstream GMT
willschlitzer Jan 24, 2021
74b7bcb
Remove solar_coast
willschlitzer Jan 26, 2021
c7935a1
Remove solar_fill and solar_fill_transparency
willschlitzer Jan 26, 2021
1ea53b8
Remove solar_pen
willschlitzer Jan 26, 2021
25544a9
Remove solar_xy_shift
willschlitzer Jan 26, 2021
6391dea
Remove solar_perspective
willschlitzer Jan 26, 2021
001c76a
Remove unused imports in test_solar.py
willschlitzer Jan 26, 2021
18610a7
Correcting "twighlight" to "twilight"
willschlitzer Jan 26, 2021
0af2d2f
Merge branch 'master' into wrap-solar
willschlitzer Jan 26, 2021
c327c08
Add solar.py gallery example
willschlitzer Jan 26, 2021
2d1a05d
Merge branch 'master' into wrap-solar
willschlitzer Jan 27, 2021
a722ca5
Move solar function from base_plotting.py to solar.py
willschlitzer Jan 27, 2021
cea2f8f
Remove dummy_context unused import
willschlitzer Jan 27, 2021
0085853
change order of modules in __init__.py
willschlitzer Jan 27, 2021
2f46f92
Merge branch 'master' into wrap-solar
willschlitzer Jan 30, 2021
3f960b4
Update pygmt/src/solar.py
willschlitzer Jan 30, 2021
bf0e2d5
Update first line of solar doc string
willschlitzer Jan 30, 2021
afead71
Merge remote-tracking branch 'origin/wrap-solar' into wrap-solar
willschlitzer Jan 30, 2021
0a7a341
Apply suggestions from code review
willschlitzer Feb 3, 2021
04ee236
Merge branch 'master' into wrap-solar
willschlitzer Feb 3, 2021
0ed4478
Update solar gallery example
willschlitzer Feb 3, 2021
b95b404
Update examples/gallery/plot/solar.py
willschlitzer Feb 4, 2021
e172457
Apply suggestions from code review
willschlitzer Feb 4, 2021
7ed7684
Add comments to self for datetime parsing
willschlitzer Feb 5, 2021
b41e469
Manual merge of master branch into wrap-solar
willschlitzer Feb 7, 2021
fe3b9c0
Run make format
willschlitzer Feb 7, 2021
d99a384
Merge updates
willschlitzer Feb 19, 2021
ace6880
Fix import statements
willschlitzer Feb 19, 2021
0b3b4d8
Style fix
willschlitzer Feb 20, 2021
43db5ad
Style fix
willschlitzer Feb 20, 2021
338cb4f
Allow solar to accept terminator types and datetime objects
willschlitzer Feb 20, 2021
5cc7993
Merge branch 'master' into wrap-solar
willschlitzer Feb 20, 2021
0427019
Format fixes; add type of error to except statement
willschlitzer Feb 20, 2021
9cc19ed
Change error raising
willschlitzer Feb 20, 2021
cd64f39
Update date string building format
willschlitzer Feb 20, 2021
d8090fe
Remove old parameters, delete invalid tests
willschlitzer Feb 20, 2021
87097aa
Make suggested refactors for get_terminator_type and get_datetime_string
willschlitzer Feb 21, 2021
b2a0142
Move all funtions into solar function
willschlitzer Feb 21, 2021
672c04d
Update tests, change gallery example
willschlitzer Feb 21, 2021
c065e8f
Merge branch 'master' into wrap-solar
willschlitzer Feb 21, 2021
d2acbfa
Naming fix
willschlitzer Feb 21, 2021
d835de4
Update documentation for solar
willschlitzer Feb 21, 2021
7580b2e
Formatting fixes
willschlitzer Feb 21, 2021
857194a
Apply suggestions from code review
willschlitzer Feb 22, 2021
7596ab0
Merge branch 'master' into wrap-solar
willschlitzer Feb 22, 2021
eb49c79
Update pygmt/src/solar.py
willschlitzer Feb 22, 2021
3316a36
Remove term_string variable from solar.py
willschlitzer Feb 22, 2021
766c4eb
Apply suggestions from code review
willschlitzer Feb 22, 2021
0e8fb1c
Run make format
willschlitzer Feb 22, 2021
16811ca
Change test to use non-default terminator type
willschlitzer Feb 22, 2021
b7b5c81
[format-command] fixes
actions-bot Feb 22, 2021
034aca8
Update pygmt/src/solar.py
willschlitzer Feb 23, 2021
2290874
Merge branch 'master' into wrap-solar
willschlitzer Feb 25, 2021
8950aaa
Merge branch 'master' into wrap-solar
willschlitzer Feb 26, 2021
8e8700d
Merge branch 'master' into wrap-solar
seisman Feb 26, 2021
5f69372
Merge branch 'master' into wrap-solar
willschlitzer Feb 27, 2021
06332bb
Apply suggestions from code review
willschlitzer Feb 28, 2021
13228e5
Merge branch 'master' into wrap-solar
willschlitzer Mar 17, 2021
79c4182
run make format
willschlitzer Mar 17, 2021
e6ae4c0
Merge branch 'master' into wrap-solar
willschlitzer Mar 18, 2021
e367ea8
Update testing in test_solar.py
willschlitzer Mar 18, 2021
b2092e4
Add dvc file
willschlitzer Mar 18, 2021
aadca32
replace short aliases with long aliases
willschlitzer Mar 18, 2021
b545fb9
Update test_solar.py tests
willschlitzer Mar 18, 2021
33b67de
Add test_solar_set_terminator_datetime_object.png.dvc and test_solar_…
willschlitzer Mar 18, 2021
b161432
remove unused import
willschlitzer Mar 18, 2021
0e5b65f
remove if statement for testing if T is in kwargs
willschlitzer Mar 19, 2021
386ea48
move solar gallery example to embellishments
willschlitzer Mar 19, 2021
ac63d8a
add if statement for T being passed
willschlitzer Mar 19, 2021
e4f8c19
add test for raising GMTInvalidInput when T is passed
willschlitzer Mar 19, 2021
02c77fa
Update pygmt/src/solar.py
willschlitzer Mar 19, 2021
14265f4
Apply suggestions from code review
willschlitzer Mar 19, 2021
e60ce74
formatting fix
willschlitzer Mar 19, 2021
f1ace0c
add TODO
willschlitzer Mar 19, 2021
990bc65
update pen width
willschlitzer Mar 19, 2021
2e5e151
update teminator_datetime docstring
willschlitzer Mar 19, 2021
631b24d
update default time in docstring
willschlitzer Mar 19, 2021
d7afb77
run make format
willschlitzer Mar 19, 2021
0a3350d
Apply suggestions from code review
willschlitzer Mar 21, 2021
2a30f5f
Merge branch 'master' into wrap-solar
willschlitzer Mar 21, 2021
05f804d
Apply suggestions from code review
willschlitzer Mar 22, 2021
c0502ee
Merge branch 'master' into wrap-solar
willschlitzer Mar 22, 2021
7124ad1
run make format
willschlitzer Mar 22, 2021
fb3a721
update test_coast() to use long-form aliases
willschlitzer Mar 22, 2021
3a8deaf
update test_coast_iceland() to use @mpl_image_compare
willschlitzer Mar 22, 2021
29e4e80
update test_coast_aliases() to use @mpl_image_compare
willschlitzer Mar 22, 2021
6ca11db
update test_coast_dcw_single() to use @mpl_image_compare
willschlitzer Mar 22, 2021
59e0e17
update test_coast_dcw_multiple() to use @mpl_image_compare
willschlitzer Mar 22, 2021
5aff498
update test_coast_dcw_list() to use @mpl_image_compare
willschlitzer Mar 22, 2021
0823d1d
update test_coast_dcw_continent() to use @mpl_image_compare
willschlitzer Mar 22, 2021
a58fdd6
update test_coast_dcw_states() to use @mpl_image_compare
willschlitzer Mar 22, 2021
385fd4e
Add dvc files for test_coast.py
willschlitzer Mar 22, 2021
4168b19
Update main docstring in test_coast.py
willschlitzer Mar 22, 2021
a1aef1b
Remove deleted reference images
willschlitzer Mar 22, 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 @@ -38,6 +38,7 @@ Plotting data and laying out the map:
Figure.plot3d
Figure.set_panel
Figure.shift_origin
Figure.solar
Figure.subplot
Figure.text

Expand Down
46 changes: 46 additions & 0 deletions examples/gallery/embellishments/solar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Day-night terminator line and twilights
---------------------------------------

Use :meth:`pygmt.Figure.solar` to plot the day-night terminator line,
and civil, nautical, astronomical twilights.
"""
import datetime

import pygmt

fig = pygmt.Figure()
# Create a figure showing the global region on a Mollweide projection
# Land color is set to dark green and water color is set to light blue
fig.coast(region="d", projection="W0/15c", land="darkgreen", water="lightblue")
# Set a time for the day-night terminator and twilights, 1700 UTC on January 1, 2000
terminator_datetime = datetime.datetime(
year=2000, month=1, day=1, hour=17, minute=0, second=0
)
# Set the pen line to be 1p thick
# Set the fill for the night area to be navy blue at different transparency levels
fig.solar(
terminator="day_night",
terminator_datetime=terminator_datetime,
fill="navyblue@95",
pen="0.5p",
)
fig.solar(
terminator="civil",
terminator_datetime=terminator_datetime,
fill="navyblue@85",
pen="0.5p",
)
fig.solar(
terminator="nautical",
terminator_datetime=terminator_datetime,
fill="navyblue@80",
pen="0.5p",
)
fig.solar(
terminator="astronomical",
terminator_datetime=terminator_datetime,
fill="navyblue@80",
pen="0.5p",
)
fig.show()
1 change: 1 addition & 0 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def _repr_html_(self):
plot,
plot3d,
set_panel,
solar,
subplot,
text,
)
1 change: 1 addition & 0 deletions pygmt/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pygmt.src.meca import meca
from pygmt.src.plot import plot
from pygmt.src.plot3d import plot3d
from pygmt.src.solar import solar
from pygmt.src.subplot import set_panel, subplot
from pygmt.src.surface import surface
from pygmt.src.text import text_ as text # "text" is an argument within "text_"
Expand Down
99 changes: 99 additions & 0 deletions pygmt/src/solar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""
solar - Plot day-night terminators.
"""

import datetime

import pandas as pd
from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias


@fmt_docstring
@use_alias(
B="frame",
G="fill",
J="projection",
R="region",
U="timestamp",
V="verbose",
W="pen",
X="xshift",
Y="yshift",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def solar(self, terminator="d", terminator_datetime=None, **kwargs):
r"""
Plot day-light terminators.

This function plots the day-night terminator. Additionally, it can
plot the terminators for civil twilight, nautical twilight, and
astronomical twilight.

Full parameter list at :gmt-docs:`solar.html`

{aliases}

Parameters
----------
terminator : str
Set the type of terminator displayed. Valid arguments are
**day_night**, **civil**, **nautical**, and **astronomical**, which
can be set with either the full name or the first letter of the name.
[Default is **day_night**]
terminator_datetime : str or datetime object
Set the UTC date and time of the displayed terminator. It can be
passed as a string or a datetime object.
[Default is the current UTC date and time]
{R}
{J}
{B}
fill : str
Color or pattern for filling of terminators.
pen : str
Set pen attributes for lines. The default pen
is ``default,black,solid``.
{U}
{V}
{XY}
{c}
{p}
{t}
"""
# TODO: Incorporate "-T+zTZ"

kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
if "T" in kwargs:
raise GMTInvalidInput(
"Use 'terminator' and 'terminator_datetime' instead of 'T'."
)
if terminator not in [
"day_night",
"nautical",
"civil",
"astronomical",
"astro",
"d",
"n",
"c",
"a",
]:
raise GMTInvalidInput(
f"Unrecognized solar terminator type '{terminator}'. Valid values "
"are 'day_night', 'civil', 'nautical', and 'astronomical'."
)
kwargs["T"] = terminator[0]
if terminator_datetime:
try:
datetime_string = pd.to_datetime(terminator_datetime).strftime(
"%Y-%m-%dT%H:%M:%S.%f"
)
except ValueError as verr:
raise GMTInvalidInput("Unrecognized datetime format.") from verr
kwargs["T"] += f"+d{datetime_string}"
with Session() as lib:
lib.call_module("solar", build_arg_string(kwargs))
Binary file removed pygmt/tests/baseline/test_coast.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: a054a1df3a6eb6f6799ba0fc104ade45
size: 135451
path: test_coast.png
Binary file removed pygmt/tests/baseline/test_coast_aliases.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_aliases.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: d53aa16264ebd5ae546c95b88855b16a
size: 519870
path: test_coast_aliases.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_continent.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 479f5ea4fb662289c4bf0e9fc1d4ae4b
size: 91352
path: test_coast_dcw_continent.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_list.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 30c3f4c90ba740b7d9edae97d9d3b853
size: 93411
path: test_coast_dcw_list.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_multiple.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: c68c4ecaffdda779a6b20aba786dd919
size: 94025
path: test_coast_dcw_multiple.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_single.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 40fcf70e1f73ba2be60cbf9e3f15794d
size: 83794
path: test_coast_dcw_single.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_state.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: faddbe172a81a10563eebf75744d7339
size: 110297
path: test_coast_dcw_state.png
Binary file removed pygmt/tests/baseline/test_coast_iceland.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_iceland.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: c4efb846d4f0a26c7c3b4900ae0043bf
size: 23420
path: test_coast_iceland.png
Binary file removed pygmt/tests/baseline/test_coast_world_mercator.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_world_mercator.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 12884b768aa463d575019347dedfa6b0
size: 322546
path: test_coast_world_mercator.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_solar_default_terminator.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 0a7f4959b500b6fa3a560a6368db0f90
size: 25982
path: test_solar_default_terminator.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 0a7f4959b500b6fa3a560a6368db0f90
size: 25982
path: test_solar_set_terminator_datetime_object.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 9437b5fd846526c7cac12ab327a4d78f
size: 26501
path: test_solar_set_terminator_datetime_string.png
Loading