77import pandas as pd
88from pygmt .alias import Alias , AliasSystem
99from pygmt .clib import Session
10- from pygmt .exceptions import GMTInvalidInput , GMTValueError
10+ from pygmt .exceptions import GMTValueError
1111from pygmt .helpers import build_arg_list , fmt_docstring , kwargs_to_strings , use_alias
1212
1313__doctest_skip__ = ["solar" ]
1818 B = "frame" ,
1919 G = "fill" ,
2020 R = "region" ,
21- T = "terminator/terminator_datetime-" ,
2221 V = "verbose" ,
2322 W = "pen" ,
2423 c = "panel" ,
@@ -43,6 +42,7 @@ def solar(
4342
4443 {aliases}
4544 - J=projection
45+ - T=terminator, **+d**: terminator_datetime
4646
4747 Parameters
4848 ----------
@@ -99,28 +99,31 @@ def solar(
9999 >>> fig.show()
100100 """
101101 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 )
105102
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
112104 if terminator_datetime :
113105 try :
114106 datetime_string = pd .to_datetime (terminator_datetime ).strftime (
115107 "%Y-%m-%dT%H:%M:%S.%f"
116108 )
117109 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
121111
122112 aliasdict = AliasSystem (
123113 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+ ],
124127 ).merge (kwargs )
125128
126129 with Session () as lib :
0 commit comments