Skip to content
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

Pycraf atm module results in error when running example #20

Closed
leonardoghizoni opened this issue Jan 15, 2020 · 1 comment
Closed

Pycraf atm module results in error when running example #20

leonardoghizoni opened this issue Jan 15, 2020 · 1 comment

Comments

@leonardoghizoni
Copy link

leonardoghizoni commented Jan 15, 2020

The path attenuation example returns an error for the gain computation:

File "pathattenuation.py", line 32, in
axes[0, 1].plot(_freqs, (-total_atten).to(cnv.dimless).value, linestyle, label=label)
File "/home/lghizoni/.local/lib/python3.6/site-packages/astropy/units/function/core.py", line 574, in array_ufunc
.format(function.name))
astropy.units.core.UnitTypeError: Cannot use ufunc 'negative' with function quantities

The problem seems to be the "(-total_atten)"

@bwinkel
Copy link
Owner

bwinkel commented Jan 26, 2020

This appears to be a problem of the astropy.units package, which is used for physical units support (in particular logarithmic units). What astropy version do you have installed? On recent versions of astropy the problem disappeared (at least on my machine). A (nasty) work-around has always been to force the unit to the linear-scale first, e.g.,

(-total_atten).to(cnv.dimless).value

would be equivalent to

(1 / total_atten.to(cnv.dimless)).value

@bwinkel bwinkel closed this as completed Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants