Skip to content

Commit c2bfa20

Browse files
authored
Merge pull request #2377 from jianyangli/fix_sbdb_import_unit_error
Bugfix: SBDB query return unit with exponentials
2 parents 35722a2 + 6329863 commit c2bfa20

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ casda
1818

1919
- Add the ability to produce 2D and 3D cutouts from ASKAP images and cubes. [#2366]
2020

21+
jplsbdb
22+
^^^^^^^
23+
24+
- Fix a bug for jplsdbd query when the returned physical quantity contains
25+
a unit with exponential. [#2377]
2126

2227
Infrastructure, Utility and Other Changes and Additions
2328
-------------------------------------------------------

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)