I was working on a university project in astronomy, and while i was trying to do some simple calculations, I recieved this error:
TypeError: ufunc ‘deg2rad’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ”safe”
this is my code:
def azimuth(hour_angle, declination):
alt = altitude(hour_angle, declination)
dec = convert2dd(declination, 'DMS')
ha = convert2dd(hour_angle, 'HMS')
sin_azi = - np.sin(np.deg2rad(ha)) * np.cos(np.deg2rad(dec)) / np.cos(np.deg2rad(alt))
azi = np.arcsin(sin_azi)
return np.rad2deg(azi)
convert2dd function converts coordinates from systems HMS and DMS to decimal degrees and it is working properly.
and also altitude function calculates the altitude of the object in a similar way but it doesn’t rise any error.
i was trying this:
print(azimuth('22:33:34.79', '29:36:53.24'))
and expecting to get some float number like:
56.2534561
which is a decimal degree.
Hamidreza is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1