12
12
# import configurable items declared in __init__.py
13
13
from astroquery .linelists .cdms import conf
14
14
from astroquery .exceptions import InvalidQueryError , EmptyResponseError
15
+ from astroquery import log
15
16
16
17
import re
17
18
import string
@@ -409,7 +410,7 @@ def tryfloat(x):
409
410
410
411
return result
411
412
412
- def get_molecule (self , molecule_id , * , cache = True ):
413
+ def get_molecule (self , molecule_id , * , cache = True , return_response = False ):
413
414
"""
414
415
Retrieve the whole molecule table for a given molecule id
415
416
"""
@@ -418,6 +419,8 @@ def get_molecule(self, molecule_id, *, cache=True):
418
419
url = f'{ self .CLASSIC_URL } /entries/c{ molecule_id } .cat'
419
420
response = self ._request (method = 'GET' , url = url ,
420
421
timeout = self .TIMEOUT , cache = cache )
422
+ if return_response :
423
+ return response
421
424
result = self ._parse_cat (response )
422
425
423
426
species_table = self .get_species_table ()
@@ -449,7 +452,7 @@ def _parse_cat(self, response, *, verbose=False):
449
452
'GUP' : 42 ,
450
453
'TAG' : 44 ,
451
454
'QNFMT' : 52 ,
452
- 'Q1' : 56 ,
455
+ 'Q1' : 55 ,
453
456
'Q2' : 58 ,
454
457
'Q3' : 60 ,
455
458
'Q4' : 62 ,
@@ -472,7 +475,7 @@ def _parse_cat(self, response, *, verbose=False):
472
475
format = 'fixed_width' , fast_reader = False )
473
476
474
477
# int truncates - which is what we want
475
- result ['MOLWT' ] = [int (x / 1e4 ) for x in result ['TAG' ]]
478
+ result ['MOLWT' ] = [int (x / 1e3 ) for x in result ['TAG' ]]
476
479
477
480
result ['FREQ' ].unit = u .MHz
478
481
result ['ERR' ].unit = u .MHz
@@ -482,15 +485,18 @@ def _parse_cat(self, response, *, verbose=False):
482
485
result ['MOLWT' ].unit = u .Da
483
486
484
487
fix_keys = ['GUP' ]
485
- for suf in '' :
486
- for qn in (f'Q{ ii } ' for ii in range (1 , 15 )):
487
- qnind = qn + suf
488
- fix_keys .append (qnind )
488
+ for qn in (f'Q{ ii } ' for ii in range (1 , 15 )):
489
+ fix_keys .append (qn )
490
+ log .debug (f"fix_keys: { fix_keys } should include Q1, Q2, ..., Q14 and GUP" )
489
491
for key in fix_keys :
490
492
if not np .issubdtype (result [key ].dtype , np .integer ):
491
493
intcol = np .array (list (map (parse_letternumber , result [key ])),
492
494
dtype = int )
495
+ if any (intcol == - 999999 ):
496
+ intcol = np .ma .masked_where (intcol == - 999999 , intcol )
493
497
result [key ] = intcol
498
+ if not np .issubdtype (result [key ].dtype , np .integer ):
499
+ raise ValueError (f"Failed to parse { key } as integer" )
494
500
495
501
result ['LGINT' ].unit = u .nm ** 2 * u .MHz
496
502
result ['ELO' ].unit = u .cm ** (- 1 )
@@ -508,9 +514,12 @@ def parse_letternumber(st):
508
514
From the CDMS docs:
509
515
"Exactly two characters are available for each quantum number. Therefore, half
510
516
integer quanta are rounded up ! In addition, capital letters are used to
511
- indicate quantum numbers larger than 99. E. g. A0 is 100, Z9 is 359. Lower case characters
517
+ indicate quantum numbers larger than 99. E. g. A0 is 100, Z9 is 359. Lower case characters
512
518
are used similarly to signal negative quantum numbers smaller than –9. e. g., a0 is –10, b0 is –20, etc."
513
519
"""
520
+ if np .ma .is_masked (st ):
521
+ return - 999999
522
+
514
523
asc = string .ascii_lowercase
515
524
ASC = string .ascii_uppercase
516
525
newst = '' .join (['-' + str ((asc .index (x )+ 1 )) if x in asc else
0 commit comments