I am still a newbie in python and I need to use PyAstronomy module for writing a code. I want to call this function as an Input for another code:
def phaseAngle(pos, los='-z'):
"""
Calculate the phase angle.
Parameters
----------
pos : array
Either a one-dimensional array with xyz coordinate or a
[3,N] array containing N xyz positions.
los : LineOfSight object
A `LineOfSight` object from the pyasl giving the line of
sight.
Returns
-------
Phase angle : The phase angle in degrees. Depending on the input,
it returns a single value or an array.
"""
from PyAstronomy.pyasl import LineOfSight
l = LineOfSight(los)
if pos.shape == (3,):
# It is a single value
return numpy.arccos(numpy.sum(-pos * (-l.los)) /
numpy.sqrt(numpy.sum(pos**2))) / numpy.pi * 180.
else:
# It is an array of positions
N = len(pos[::, 0])
result = numpy.zeros(N)
for i in smo.range(N):
print(i, numpy.sum((-pos[i, ::]) * (-l.los)), pos[i, ::])
result[i] = numpy.arccos(numpy.sum((-pos[i, ::]) * (-l.los)) /
numpy.sqrt(numpy.sum(pos[i, ::]**2)))
return result / numpy.pi * 180.
In the main code the inputs are entered this way by calling KeplerEllipse from pyasl:
...
from PyAstronomy import pyasl
...
ke = pyasl.KeplerEllipse(1.3, 2., e=0.5, Omega=70., i=10.0, w=110.0)
that works very well and gives the positions and velocities as the outputs. But I need to use this phase angle as another input. But, I don't know how to inverse the output and input of def phaseAngle(pos, los='-z') so that I use the phase angle as an input and add it to
ke = pyasl.KeplerEllipse(1.3, 2., e=0.5, Omega=70., i=10.0, w=110.0, ??? )
phaseAngleas this particular argument value inKeplerEllipse...KeplerEllipse(..., arg=phaseAngle(...), ...)def phaseAnglethe return (output) is "phase angle" and not the input.