@@ -32,15 +32,15 @@ def solar(
32
32
r"""
33
33
Plot day-night terminators and other sunlight parameters.
34
34
35
- This function plots the day-night terminator. Alternatively, it can plot the
35
+ This method plots the day-night terminator. Alternatively, it can plot the
36
36
terminators for civil twilight, nautical twilight, or astronomical twilight.
37
37
38
38
Full GMT docs at :gmt-docs:`solar.html`.
39
39
40
40
{aliases}
41
41
- G = fill
42
42
- J = projection
43
- - T = terminator, **+d**: terminator_datetime
43
+ - T = terminator, **+d**/**+z** : terminator_datetime
44
44
- V = verbose
45
45
- W = pen
46
46
- c = panel
@@ -49,8 +49,7 @@ def solar(
49
49
Parameters
50
50
----------
51
51
terminator
52
- Set the type of terminator displayed, which can be set with either the full name
53
- or the first letter of the name. Available options are:
52
+ Set the type of terminator. Choose one of the following:
54
53
55
54
- ``"astronomical"``: Astronomical twilight
56
55
- ``"civil"``: Civil twilight
@@ -60,8 +59,12 @@ def solar(
60
59
Refer to https://en.wikipedia.org/wiki/Twilight for the definitions of different
61
60
types of twilight.
62
61
terminator_datetime : str or datetime object
63
- Set the UTC date and time of the displayed terminator [Default is the current
64
- UTC date and time]. It can be passed as a string or Python datetime object.
62
+ Set the date and time for the terminator calculation. It can be provided as a
63
+ string or any datetime-like object recognized by :func:`pandas.to_datetime`. The
64
+ time can be specified in UTC or using a UTC offset. The offset must be an
65
+ integer number of hours (e.g., -8 or +5); fractional hours are truncated
66
+ towards zero (e.g., -8.5 becomes -8 and +5.5 becomes +5). [Default is the
67
+ current UTC date and time].
65
68
{region}
66
69
{projection}
67
70
{frame}
@@ -102,12 +105,16 @@ def solar(
102
105
"""
103
106
self ._activate_figure ()
104
107
105
- datetime_string = None
108
+ datetime_string , datetime_timezone = None , None
106
109
if terminator_datetime :
107
110
try :
108
- datetime_string = pd .to_datetime (terminator_datetime ).strftime (
109
- "%Y-%m-%dT%H:%M:%S.%f"
110
- )
111
+ _datetime = pd .to_datetime (terminator_datetime )
112
+ datetime_string = _datetime .strftime ("%Y-%m-%dT%H:%M:%S.%f" )
113
+ # GMT's solar module uses the C 'atoi' function to parse the timezone
114
+ # offset. Ensure the offset is an integer number of hours (e.g., -8 or +5).
115
+ # Fractional hours (e.g., -8.5 or +5.5) are truncated towards zero.
116
+ if utcoffset := _datetime .utcoffset ():
117
+ datetime_timezone = int (utcoffset .total_seconds () / 3600 )
111
118
except ValueError as verr :
112
119
raise GMTValueError (terminator_datetime , description = "datetime" ) from verr
113
120
@@ -125,6 +132,7 @@ def solar(
125
132
},
126
133
),
127
134
Alias (datetime_string , name = "terminator_datetime" , prefix = "+d" ),
135
+ Alias (datetime_timezone , name = "terminator_timezone" , prefix = "+z" ),
128
136
],
129
137
W = Alias (pen , name = "pen" ),
130
138
).add_common (
0 commit comments