擅长:python、mysql、java
<p>因为您已经在使用<code>numpy</code>,所以您可以使用<a href="https://pandas.pydata.org/pandas-docs/stable/index.html" rel="nofollow noreferrer">^{<cd2>}</a>进一步。它具有强大的日期和时间操作例程,如<a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.date_range.html" rel="nofollow noreferrer">^{<cd3>}</a>:</p>
<pre><code>import pandas as pd
start = pd.Timestamp(year=2018, month=1, day=1)
stop = pd.Timestamp(year=2018, month=12, day=31)
dates = pd.date_range(start, stop, freq='min')
altitudes = localSun(30, 0, dates)
</code></pre>
<p>然后需要调整<code>localSun</code>来处理<a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Timestamp.html" rel="nofollow noreferrer">^{<cd5>}</a>的数组,而不是单个的<code>datetime.datetime</code>。在</p>
<p>从分钟改为秒,就像把<code>freq='min'</code>改为<code>freq='S'</code>一样简单。在</p>