-3
 sun_ra=round(sunpy.sun.apparent_rightascension(t),4)*15.0

File "/home/user/.local/lib/python2.7/site-packages/astropy/units/quantity.py", line 963, in float raise TypeError('Only dimensionless scalar quantities can be ' TypeError: Only dimensionless scalar quantities can be converted to Python scalars

  • 1
    It would help to see your code... in particular line 31..... – Preston Martin Oct 07 '16 at 15:40
  • 1
    Use `sunpy.sun.apparent_rightascension(t).value` to get a floating point value: `round()` knows how to deal with that. Or if you want to be more explicit: `sunpy.sun.apparent_rightascension(t).to(units.degree).value`. –  Oct 07 '16 at 18:01
  • 1
    Overall, though, *don't* round. Use formatting when printing the value, but otherwise, just keep the actual, exact value and don't round it. –  Oct 07 '16 at 18:02

1 Answers1

1
 sun_ra=round(sunpy.sun.apparent_rightascension(t),4)*15.0

round looks like the scalar Python function. It will raise an error if given an array or list. But on Py3 I get a different error.

The other possibility is that the sunpy function expects a scalar, and t is not. But for that I'd expect an error further into that function.

So I think your use of round is an error.

hpaulj
  • 221,503
  • 14
  • 230
  • 353
  • 1
    Almost: `sunpy.sun.apparent_rightascension` will return an `astropy.coordinate.Angle` or similar, which is an `astropy.units.Quantity` (a float with a unit attached to it). `round` obviously doesn't know how to handle that. –  Oct 07 '16 at 17:59