0

我正在编写一个程序来评估美国各个城市光伏每小时的能源输出。为简单起见,我将它们放在字典 (tmy3_cities) 中,以便循环浏览它们。为了阅读代码,我遵循了TMY 到 Github 上的 Power Tutorial。我没有显示整个循环,而是只添加了读取时间并将时间移动 30 分钟的代码。

因此,本教程中的代码适用于所有 TMY3 文件,除了休斯顿、亚特兰大和巴尔的摩(为简单起见,HAB)。所有的 tmy3 文件都是从NREL下载并重命名为我自己使用的。我在读取这三个文件时遇到的错误与日期时间有关,它本质上归结为“ValueError:int() 的无效文字,基数为 10:'1',经过一些回溯。

我没有陷入同样的​​问题,而是将每个文件单独输入到阅读器中,果然,只有 HAB tmy3 文件会出错。

其次,我再次下载了文件。这,显然没有影响。

为了绕过这个问题,我通过excel将日期和时间列从工作tmy3文件(例如迈阿密)复制并粘贴到非工作文件(即HAB)中。

我不确定还能做什么,因为我对 Python 和一般编码仍然相当陌生。

#The dictionary below is not important to the problem below, but is 
provided only for some clarification.
tmy3_cities = {'miami': 'TMY3Miami.csv',
        'houston': 'TMY3Houston.csv',
        'phoenix': 'TMY3Phoenix.csv',
        'atlanta': 'TMY3Atlanta.csv',
        'los_angeles': 'TMY3LosAngeles.csv',
        'las_vegas': 'TMY3LasVegas.csv',
        'san_francisco': 'TMY3SanFrancisco.csv',
        'baltimore': 'TMY3Baltimore.csv',
        'albuquerque': 'TMY3Albuquerque.csv',
        'seattle': 'TMY3Seattle.csv',
        'chicago': 'TMY3Chicago.csv',
        'denver': 'TMY3Denver.csv',
        'minneapolis': 'TMY3Minneapolis.csv',
        'helena': 'TMY3Helena.csv',
        'duluth': 'TMY3Duluth.csv',
        'fairbanks': 'TMY3Fairbanks.csv'}

#The code below was taken from the tutorial.
pvlib_abspath = os.path.dirname(os.path.abspath(inspect.getfile(pvlib)))

#This is the only section of the code that was modified.
datapath = os.path.join(pvlib_abspath, 'data', 'TMY3Atlanta.csv')

tmy_data, meta = pvlib.tmy.readtmy3(datapath, coerce_year=2015)
tmy_data.index.name = 'Time'

# TMY data seems to be given as hourly data with time stamp at the end
# Shift the index 30 Minutes back for calculation of sun positions
tmy_data = tmy_data.shift(freq='-30Min')['2015']

print(tmy_data.head())

我希望读取的每个 tmy3 文件都生成自己的 tmy_data DataFrame。想看全文请评论

4

0 回答 0