擅长:python、mysql、java
<p>Numpy有naitive <code>datetime</code>和<code>timedelta</code><a href="https://docs.scipy.org/doc/numpy-1.14.0/reference/arrays.datetime.html" rel="nofollow noreferrer">support</a>,因此您可以采用如下方法:</p>
<pre><code>start = datetime.datetime(2018,5,29,15,21,0)
end = datetime.datetime(2019,5,29,15,21,0)
n = np.arange(start, end, dtype='datetime64[m]') # [m] specifies the interval as minutes
altitudes = np.vectorize(lambda x, y, z: localSun(x, y, z).altitude())(30,0,n)</code></pre>
<p><a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.vectorize.html" rel="nofollow noreferrer">np.vectorize</a>一点也不快,但在您可以修改'localSun'以使用日期时间数组之前,它可以正常工作。在</p>