A sample Python project
Project description
SWC
This is a code that I wrote to make use of the System Advisor Model and the NSRDB API.
How to install
pip install swc
Developer Instalation/configuration
Pipenv installation
In macOS
brew install pipenv
Install virtualenv with pipenv
pipenv install --three
How to use
Using the solar radiation data as input, we implemented an easy way to change the configuration parameters to simulate the performance of a PV system.
Configuration
First you need to get an API. Read https://developer.nrel.gov/signup/. Once you have it, create a .env file under your working folder that includes:
API_KEY=YOUR API_KEY_GOES_HERE
And thats it!
Solar radiation data
To get solar radiation data from the NSRB from a Jupyter Notebook or Console
import swc.nsrdb as nsrdb
site_info = {'lat': 18.3,
'lng: -99.3,
'api_key':'YOUR_API_KEY',
'force_download': False,
'year': '2014'}
df = nsrdb.get_nsrdb(**site_info)
SAM simulation
To perform a SAM simulation using the data from the NSRDB
import swc.sam_simulation as sam
simulation_params = {
'lat': site_info['lat'],
'lng': site_info['lng'],
'losses': 4.3,
'dc_ac_ratio': 1.2,
'inv_eff': 96.,
'tilt': 20,
'system_capacity': 100,
'elevation': 1100,
'timezone': -6,
'configuration': 0, # 0 For fixed tilt, 2 for 1-axis and 4 for 2-axis
'gcr': 0.4,
'azimuth': 100,
}
output_data, output_params = sam.sam_simulation(df, **simulation_params)
LCOE Calculation
Using output_data (pd.Dataframe with hourly generation)
from src.solar import lcoe
print (lcoe(output_gen))
Authors
- pesap
- Sergio Castellanos
Todo
- Change the request method from the NSRDB API
- Add more inputs in
performance_simulation
Important information
I made this code for my personal use. The code merges the NSRDB-API and the SAM-SDK in one easy code. I do not own any of the above software. If you want to know more about the SAM-SDK or NSRDB-API please visit their respective websites.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.