You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@mhvk can you please explain what is the difference between units and CDS units as I couldn't find any documentation. All I could find was #7751 and that too is not very clear.
from astropy.io import ascii
ascii.read('ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/557/A19/elm.dat', readme='ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/557/A19/ReadMe')
WARNING: UnitsWarning: '[K]' did not parse as cds unit: Invalid character at col 0 If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html [astropy.units.core]
WARNING: UnitsWarning: '[cm/s2]' did not parse as cds unit: Invalid character at col 0 If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html [astropy.units.core]
<Table length=4183>
logTe logg Mass e_Mass Age e_Age
[K] [cm/s2] Msun Msun Myr Myr
float64 float64 float64 float64 float64 float64
------- ------- ---------- ---------- ------------ -----------
3.85 3.0 0.24458909 0.0037877 34.94635274 8.27665511
3.85 3.1 0.23590794 0.0036602 39.31200393 8.5529015
3.85 3.2 0.22741011 0.00356954 41.6153104 8.72442808
3.85 3.3 0.21925183 0.00350333 41.70069556 8.8584415
Here, [K] should become dex(K) (i.e., u.dex(u.K)) and similarly for [cm/s2].
To get this to work, one would need to add square brackets to the parser/lexer in the cds.py file linked at top and make those behave like the dex function in generic.py, and also adjust the CDS.to_string() method to convert logarithmic units to [...].
@mhvk I have done the work of parsing and it is working fine for the above example(i.e. now it is not throwing any warning), can you please review the code. It's a very minor change. But can you suggest whether I am going right or not?
Now I just have to implement the to_string functionality.
P.S. sorry for the late reply, I found a lot of trouble studying the metaclasses :(
Activity
DShivansh commentedon Feb 13, 2020
@mhvk can you please explain what is the difference between units and CDS units as I couldn't find any documentation. All I could find was #7751 and that too is not very clear.
mhvk commentedon Feb 13, 2020
It's mostly the way to represent units in strings, which is mostly used in parsing and in
to_string, and, implicitly, in things like reading a CDS table. For instance, at http://vizier.u-strasbg.fr/cgi-bin/VizieR-3?-source=J/A%2bA/557/A19&-out.max=50&-out.form=HTML%20Table&-out.add=_r&-out.add=_RAJ,_DEJ&-sort=_r&-oc.form=sexa, you'll see that the units of some columns have square brackets around them, but these are not recognized as meaning log10-base. Indeed, if I follow instructions on how to download this as an astropy table, I get:Here,
[K]should becomedex(K)(i.e.,u.dex(u.K)) and similarly for[cm/s2].To get this to work, one would need to add square brackets to the parser/lexer in the
cds.pyfile linked at top and make those behave like thedexfunction ingeneric.py, and also adjust theCDS.to_string()method to convert logarithmic units to[...].DShivansh commentedon Feb 20, 2020
@mhvk I have done the work of parsing and it is working fine for the above example(i.e. now it is not throwing any warning), can you please review the code. It's a very minor change. But can you suggest whether I am going right or not?
Now I just have to implement the
to_stringfunctionality.P.S. sorry for the late reply, I found a lot of trouble studying the metaclasses :(