Skip to content

Commit

Permalink
fix: include unknown value in exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutterley committed Jan 13, 2024
1 parent c14cf9e commit 97ab183
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pyTMD/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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'):
Expand All @@ -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'):
Expand Down
4 changes: 2 additions & 2 deletions pyTMD/io/constituents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 97ab183

Please sign in to comment.