Skip to content

Commit 45bd4f4

Browse files
committed
bugfix for sbdb query unit with exponentials
1 parent d53047b commit 45bd4f4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

astroquery/jplsbdb/core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,13 @@ def _process_data_element(self, val):
337337
# change units where necessary
338338
if q['units'] in conf.data_unit_replace.keys():
339339
q['units'] = conf.data_unit_replace[q['units']]
340+
# change exponential symbol in unit string from '^' to '**'
341+
if (q['units'] is not None) and ('^' in q['units']):
342+
q['units'] = q['units'].replace('^', '**')
340343
try:
341344
unit = u.Unit(q['units'])
345+
except ValueError:
346+
unit = u.Unit(q['units'], format='ogip')
342347
except TypeError:
343348
unit = 1
344349

astroquery/jplsbdb/tests/test_jplsbdb_remote.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ def test_units(self):
4444
assert sbdb['orbit']['model_pars']['A2'].unit.bases == [u.au, u.d]
4545
assert sbdb['orbit']['model_pars']['A2'].unit.is_equivalent(u.au / u.d**2)
4646
assert sbdb['orbit']['elements']['tp'].unit.bases[0] == u.d
47+
48+
sbdb = SBDB.query('Bennu', id_type='search', phys=True)
49+
assert sbdb['phys_par']['I'].unit == u.Unit('J / (K m2 s(1/2))')

0 commit comments

Comments
 (0)