7
7
import pandas as pd
8
8
from pygmt .alias import Alias , AliasSystem
9
9
from pygmt .clib import Session
10
- from pygmt .exceptions import GMTInvalidInput , GMTValueError
10
+ from pygmt .exceptions import GMTValueError
11
11
from pygmt .helpers import build_arg_list , fmt_docstring , kwargs_to_strings , use_alias
12
12
13
13
__doctest_skip__ = ["solar" ]
18
18
B = "frame" ,
19
19
G = "fill" ,
20
20
R = "region" ,
21
- T = "terminator/terminator_datetime-" ,
22
21
V = "verbose" ,
23
22
W = "pen" ,
24
23
c = "panel" ,
@@ -43,6 +42,7 @@ def solar(
43
42
44
43
{aliases}
45
44
- J=projection
45
+ - T=terminator, **+d**: terminator_datetime
46
46
47
47
Parameters
48
48
----------
@@ -99,28 +99,31 @@ def solar(
99
99
>>> fig.show()
100
100
"""
101
101
self ._activate_figure ()
102
- if kwargs .get ("T" ) is not None :
103
- msg = "Use 'terminator' and 'terminator_datetime' instead of 'T'."
104
- raise GMTInvalidInput (msg )
105
102
106
- valid_terminators = ["day_night" , "civil" , "nautical" , "astronomical" ]
107
- if terminator not in valid_terminators and terminator not in "dcna" :
108
- raise GMTValueError (
109
- terminator , description = "solar terminator type" , choices = valid_terminators
110
- )
111
- kwargs ["T" ] = terminator [0 ]
103
+ datetime_string = None
112
104
if terminator_datetime :
113
105
try :
114
106
datetime_string = pd .to_datetime (terminator_datetime ).strftime (
115
107
"%Y-%m-%dT%H:%M:%S.%f"
116
108
)
117
109
except ValueError as verr :
118
- msg = "Unrecognized datetime format."
119
- raise GMTInvalidInput (msg ) from verr
120
- kwargs ["T" ] += f"+d{ datetime_string } "
110
+ raise GMTValueError (terminator_datetime , description = "datetime" ) from verr
121
111
122
112
aliasdict = AliasSystem (
123
113
J = Alias (projection , name = "projection" ),
114
+ T = [
115
+ Alias (
116
+ terminator ,
117
+ name = "terminator" ,
118
+ mapping = {
119
+ "day_night" : "d" ,
120
+ "civil" : "c" ,
121
+ "nautical" : "n" ,
122
+ "astronomical" : "a" ,
123
+ },
124
+ ),
125
+ Alias (datetime_string , name = "terminator_datetime" , prefix = "+d" ),
126
+ ],
124
127
).merge (kwargs )
125
128
126
129
with Session () as lib :
0 commit comments