-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug while reading information from CDMS table #2375
Labels
Comments
cc @keflavich |
The error reported here is actually: from astroquery.linelists.cdms import CDMS
CDMS.query_lines(232567.224454 * u.MHz, 234435.809432 * u.MHz, molecule='H2C(CN)2', parse_name_locally=True) leading to
Then, if correctly queried: In [39]: CDMS.query_lines(232567.224454 * u.MHz, 234435.809432 * u.MHz, molecule='H2C\(CN\)2', parse_name_locally=True)
Out[39]:
<Table length=49>
FREQ ERR LGINT DR ELO GUP TAG QNFMT Ju Ku vu Jl Kl vl F name
MHz MHz MHz nm2 1 / cm
float64 float64 float64 int64 str10 int64 int64 int64 str2 int64 str2 int64 int64 int64 str6 str8
----------- ------- ------- ----- ---------- ----- ----- ----- ---- ----- ---- ----- ----- ----- ------ --------
232588.7246 0.2828 -4.1005 3 293.85404 45 66506 303 44 14 30 -- -- -- 451333 H2C(CN)2 Unfortunately, I can't see a way to make the parser behave generally here. It looks like every CDMS file has a different fixed-format table. I'll try to figure out a way to generalize it, but for now, it looks like this molecule is just wrong. |
2 tasks
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
astroquery/lineslists/cdms/core.py:
There are 2 issues I found in this file:
The function find() doesn't work with molecules that have parenthesis in their names and gives an IndexError in this case because the find() function from class Lookuptable uses the re package that consider the parenthesis as a specific symbol. To avoid this confusion, the parenthesis "(" in name of the molecules should be replaced by the string : "\(" so that the find() function understand it as a parenthesis.
This is a few lines I added in my own version of core.py to take into account molecules with parenthesis:
I found that the actual value of GUP starts at 47 not 48
For the TAG it starts at 50 not 51.
Because of this shift, this commande gives a TypeError:
freqs, aij, deg, EU, partfunc = get_molecular_parameters("H2C(CN)2", catalog="CDMS", fmin=232567.224454 * u.MHz, fmax=234435.809432 * u.MHz)
The Error I've got before making changes in my own version:
TypeError Traceback (most recent call last)
Input In [5], in
----> 1 freqs, aij, deg, EU, partfunc = get_molecular_parameters(
2 "H2C(CN)2", catalog="CDMS", fmin=232567.224454 * u.MHz, fmax=234435.809432 * u.MHz
3 )
File ~/venv/lib/python3.9/site-packages/pyspeckit/spectrum/models/lte_molecule.py:271, in get_molecular_parameters(molecule_name, tex, fmin, fmax, catalog, **kwargs)
269 freq_MHz = freqs.to(u.MHz).value
270 deg = np.array(jpltbl['GUP'])
--> 271 EL = jpltbl['ELO'].quantity.to(u.erg, u.spectral())
272 dE = freqs.to(u.erg, u.spectral())
273 EU = EL + dE
File ~/venv/lib/python3.9/site-packages/astropy/table/column.py:927, in BaseColumn.quantity(self)
920 """
921 A view of this table column as a
~astropy.units.Quantity
object with922 units given by the Column's
unit
parameter.923 """
924 # the Quantity initializer is used here because it correctly fails
925 # if the column's values are non-numeric (like strings), while .view
926 # will happily return a quantity with gibberish for numerical values
--> 927 return Quantity(self, self.unit, copy=False, dtype=self.dtype, order='A', subok=True)
File ~/venv/lib/python3.9/site-packages/astropy/units/quantity.py:511, in Quantity.new(cls, value, unit, dtype, copy, order, subok, ndmin)
507 # check that array contains numbers or long int objects
508 if (value.dtype.kind in 'OSU' and
509 not (value.dtype.kind == 'O' and
510 isinstance(value.item(0), numbers.Number))):
--> 511 raise TypeError("The value must be a valid Python or "
512 "Numpy numeric type.")
514 # by default, cast any integer, boolean, etc., to float
515 if dtype is None and value.dtype.kind in 'iuO':
TypeError: The value must be a valid Python or Numpy numeric type.
This is the change I made:
The text was updated successfully, but these errors were encountered: