Hrishikesh Radkar
Hrishikesh Radkar

Reputation: 21

PVLIB: How can I add module and inverter specifications which are not present in CEC and SAM library?

I am working on a PV system installed in Amsterdam. The PVsystem code is as follows. I am getting good results with the inverter and the modules specified in the code which is obtained with 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()

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?

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

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'

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.

Upvotes: 2

Views: 2408

Answers (1)

Cameron Stark
Cameron Stark

Reputation: 1312

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.

Welcome to the community! If you haven't already I encourage you to dig through the pvlib-python documentation and continue to learn Python basics through playing with the examples in the documentation. I encourage you to checkout the pandas tutorials and any other highly rated pandas learning material you can find to get yourself running with data science in 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'

This is because you're asking for a column in the DataFrame table that's not there. No worries, you can make your own module.

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?

It isn't necessary to change the library. You can construct a module yourself since it is a Series from the pandas library. Here's an example showing how you can output the module as a dictionary, change a couple parameters and create your own module.

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

Then you can just insert "my_new_module" into 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')

The hard part here is having the right coefficients that you can trust. You may have an easier time using module_database = pvlib.pvsystem.retrieve_sam(name='CECMod') and replacing those parameters since they can be substituted more easily with data from the module spec sheet.

This should work identically for inverters as well.

Upvotes: 5

Related Questions