From 97ab1830e71ddc43c809d18883c7a35d532e7d8f Mon Sep 17 00:00:00 2001 From: Tyler Sutterley Date: Sat, 13 Jan 2024 16:52:46 +1300 Subject: [PATCH] fix: include unknown value in exceptions --- pyTMD/arguments.py | 10 ++++++---- pyTMD/io/constituents.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pyTMD/arguments.py b/pyTMD/arguments.py index 358aaa60..e4b7f2d2 100755 --- a/pyTMD/arguments.py +++ b/pyTMD/arguments.py @@ -694,7 +694,7 @@ def doodson_number( Returns ------- - numbers: float or dict + numbers: float, np.ndarray or dict Doodson or Cartwright number for each constituent References @@ -709,7 +709,8 @@ def doodson_number( kwargs.setdefault('corrections', 'OTIS') kwargs.setdefault('formalism', 'Doodson') # validate inputs - assert kwargs['formalism'] in ('Cartwright', 'Doodson'), 'Unknown formalism' + assert kwargs['formalism'].title() in ('Cartwright', 'Doodson'), \ + f'Unknown formalism {kwargs["formalism"]}' # constituents array (not all are included in tidal program) cindex = ['sa', 'ssa', 'mm', 'msf', 'mf', 'mt', 'alpha1', '2q1', 'sigma1', @@ -722,7 +723,8 @@ def doodson_number( coefficients = _arguments_table(**kwargs) if isinstance(constituents, str): # map between given constituents and supported in tidal program - assert constituents.lower() in cindex, f'Unsupported constituent' + assert constituents.lower() in cindex, \ + f'Unsupported constituent {constituents}' j, = [j for j,val in enumerate(cindex) if (val == constituents.lower())] # extract identifier in formalism if (kwargs['formalism'] == 'Cartwright'): @@ -737,7 +739,7 @@ def doodson_number( # for each input constituent for i,c in enumerate(constituents): # map between given constituents and supported in tidal program - assert c.lower() in cindex, f'Unsupported constituent {c.lower()}' + assert c.lower() in cindex, f'Unsupported constituent {c}' j, = [j for j,val in enumerate(cindex) if (val == c.lower())] # convert from coefficients to Doodson number if (kwargs['formalism'] == 'Cartwright'): diff --git a/pyTMD/io/constituents.py b/pyTMD/io/constituents.py index bd4a577a..afe60911 100644 --- a/pyTMD/io/constituents.py +++ b/pyTMD/io/constituents.py @@ -156,13 +156,13 @@ def phase(self, field: str): @property def doodson_number(self): - """Doodson number of constituents + """constituent Doodson number """ return [pyTMD.arguments.doodson_number(f) for f in self.fields] @property def cartwright_number(self): - """Cartwright numbers of constituents + """constituent Cartwright numbers """ return [pyTMD.arguments.doodson_number(f, formalism='Cartwright') for f in self.fields]