gpt4 book ai didi

PVLIB:如何添加 CEC 和 SAM 库中不存在的模块和逆变器规范?

转载 作者:行者123 更新时间:2023-12-02 19:43:43 27 4
gpt4 key购买 nike

我正在开发安装在阿姆斯特丹的光伏系统。 PV系统代码如下。我使用使用 retrieve_sam 获得的代码中指定的逆变器和模块获得了良好的结果。

import pvlib
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS
from pandas.plotting import register_matplotlib_converters
from pvlib.modelchain import ModelChain

# Define location for the Netherlands
location = pvlib.location.Location(latitude=52.53, longitude=5.15, tz='UTC',
altitude=50, name='amsterdam')

#import the database
module_database = pvlib.pvsystem.retrieve_sam(name='SandiaMod')
inverter_database = pvlib.pvsystem.retrieve_sam(name='cecinverter')

module = module_database.Canadian_Solar_CS5P_220M___2009_
# module = module_database.DMEGC_Solar_320_M6_120BB_ (I want to add this module)
inverter = inverter_database.ABB__PVI_3_0_OUTD_S_US__208V_

temperature_model_parameters =
pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']

modules_per_string = 10
inverter_per_string = 1

# Define a PV system characteristics
surface_tilt = 12.5
surface_azimuth = 180
system = pvlib.pvsystem.PVSystem(surface_tilt=surface_tilt,
surface_azimuth=surface_azimuth, albedo=0.25,
module=module, module_parameters=module,
temperature_model_parameters=temperature_model_parameters,
modules_per_string=modules_per_string,
inverter_per_string=inverter_per_string,
inverter=inverter,
inverter_parameters=inverter,
racking_model='open_rack')


# Define a weather file
def importPSMData():
df = pd.read_csv('/Users/laxmikantradkar/Desktop/PVLIB/solcast_data1.csv', delimiter=';')

# Rename the columns for input to PVLIB
df.rename(columns={'Dhi': 'dhi', 'Dni': 'dni', 'Ghi': 'ghi', 'AirTemp':
'temp_air', 'WindSpeed10m': 'wind_speed', }, inplace=True)
df.rename(columns={'Year': 'year', 'Month': 'month', 'Day': 'day', 'Hour':
'hour', 'Minute': 'minute'}, inplace=True)
df['dt'] = pd.to_datetime(df[['year', 'month', 'day', 'hour', 'minute']])
df.set_index(df['dt'], inplace=True)


# Rename data parameters to run to datetime
# df.rename(columns={'PeriodEnd': 'period_end'}, inplace=True)


# Drop unnecessary columns
df = df.drop('PeriodStart', 1)
df = df.drop('Period', 1)
df = df.drop('Azimuth', 1)
df = df.drop('CloudOpacity', 1)
df = df.drop('DewpointTemp', 1)
df = df.drop('Ebh', 1)
df = df.drop('PrecipitableWater', 1)
df = df.drop('SnowDepth', 1)
df = df.drop('SurfacePressure', 1)
df = df.drop('WindDirection10m', 1)
df = df.drop('Zenith', 1)
return df


mc = ModelChain(system=system, location=location)
weatherData = importPSMData()
mc.run_model(weather=weatherData)
ac_energy = mc.ac

# ac_energy.to_csv('/Users/laxmikantradkar/Desktop/ac_energy_netherlands.csv')

plt.plot(ac_energy)
plt.show()

现在我想更换库中不存在的模块和逆变器。谁能告诉我该怎么做吗?

是否可以访问库并手动添加逆变器和模块的行/列?如果是,图书馆位于哪里?

../Desktop/PVLIB/venv/lib/python3.8/site-packages/pvlib/data/sam-library-sandia-modules-2015-6-30.csv

当我尝试更改上述路径中的模块/逆变器参数时,我收到错误,因为 DataFrame' 对象没有属性“模块名称”

我两天前开始使用 PVLIB_python,所以我对这门语言很陌生。我真的很感谢你的帮助。请随时纠正我。

最佳答案

I started working on PVLIB_python 2 days ago, so I am new to the language. I really appreciate your help. Feel free to correct me at any point.

欢迎来到社区!如果您还没有,我鼓励您深入研究 pvlib-python 文档,并通过使用文档中的示例继续学习 Python 基础知识。我鼓励您查看 pandas tutorials以及您可以找到的任何其他高评价的 pandas 学习 Material ,让您自己在 Python 中运行数据科学。

When I change try to change the module/inverter parameters from above path, I receive an error as DataFrame' object has no attribute 'Module name'

这是因为您要求的 DataFrame 表中不存在一列。不用担心,您可以制作自己的模块。

Now I want to change the module and inverter which is not present in the library. Could anyone please tell me how to do this? Is it possible to access the library and manually add the row/column of inverter and module? If yes, where is the library located?

无需更改库。您可以自己构建一个模块,因为它是 pandas 库中的一个系列。下面的示例展示了如何将模块输出为字典、更改几个参数并创建您自己的模块。

my_new_module = module.copy() # create your own copy of the module
print("Before:", my_new_module, sep="\n") # show module before
my_new_module["Notes"] = "This is how to change a field in the module. Do this for every field in the module."
my_new_module.name = "DMEGC_Solar_320_M6_120BB_" # rename the Series appropriately
print("\nAfter:", my_new_module, sep="\n") # show module after

然后您可以将“my_new_module”插入PVSystem:

system = pvlib.pvsystem.PVSystem(
surface_tilt=surface_tilt,
surface_azimuth=surface_azimuth,
albedo=0.25,
module=my_new_module, # HERE'S THE NEW MODULE!
module_parameters=module,
temperature_model_parameters=temperature_model_parameters,
modules_per_string=modules_per_string,
inverter_per_string=inverter_per_string,
inverter=inverter,
inverter_parameters=inverter,
racking_model='open_rack')

这里的困难部分是拥有您可以信任的正确系数。您可能会更轻松地使用 module_database = pvlib.pvsystem.retrieve_sam(name='CECMod') 并替换这些参数,因为它们可以更轻松地用模块规范表中的数据替换。

这对于逆变器也应该同样有效。

关于PVLIB:如何添加 CEC 和 SAM 库中不存在的模块和逆变器规范?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59708281/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com