Skip to main content

A sample Python project

Project description


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.


First you need to get an API. Read Once you have it, create a .env file under your working folder that includes:


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,
             '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 import lcoe
print (lcoe(output_gen))


  • pesap
  • Sergio Castellanos


  • 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for swc, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size swc-0.4.0-py2.py3-none-any.whl (7.7 MB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page