Skip to main content

capetools 🕶

A set of python 🐍 tools to process and model PV

I put together a set of tools used to clean data and model bifacial systems using pvfactors, pvlib and bifacialvf 🌞

Install

As of 02/2019: bifacialvf has not yet merged this PR, the simulate function cannot take arbitrary metereological data on the form of pandas DataFrames. So we are force to install a custom fork of bifacialvf from here. This is way, a formal release of capetools to PyPI is not possible rght now, so we have to install by cloning from github.

The recommended method is to install capetools on a conda envirnment. Ideally create a conda env with python 3.6 and then clone and install using pip.

conda create --name=your_env_name python=3.7

git clone https://github.com/tcapelle/capetools/

go inside the cloned capetools repo and do:

pip install .

or on editable mode, git clone this repo, and from within the repo install using:

pip install -e .

Getting started 💪

from capetools.imports import *
from capetools.utils.missing import *
from capetools.utils.tmy import read_pvgis
from capetools.modelling.mypvfactors import *
from capetools.modelling.mybifacialvf import *
PATH = Path.cwd().parent/'data'
fname = PATH/'pvgis_tmy_chambery.csv'

We will ingest a PVGIS downloaded file for Chambery

gps_data, months, tmy_data = read_pvgis(fname)
tmy_data.head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
temp humidity ghi dni dhi infra ws wd pressure
time(UTC)
2012-01-01 00:00:00 2.87 88.28 0.0 -0.0 0.0 259.63 1.33 170.0 99504.0
2012-01-01 01:00:00 3.59 90.07 0.0 -0.0 0.0 268.30 1.39 166.0 99508.0
2012-01-01 02:00:00 4.32 91.86 0.0 -0.0 0.0 276.97 1.45 162.0 99511.0
2012-01-01 03:00:00 5.04 93.64 0.0 -0.0 0.0 285.64 1.51 167.0 99517.0
2012-01-01 04:00:00 5.76 95.43 0.0 -0.0 0.0 294.32 1.57 171.0 99524.0

We can quickly look at missing data:

plot_missing(tmy_data)

png

as expected, no missing data !

Simulations

pvfactors

params = system_def(n_pvrows=3); params
{'n_pvrows': 3,
 'pvrow_height': 1.6218180900789148,
 'pvrow_width': 2.02,
 'tracking': False,
 'axis_azimuth': 0,
 'surface_tilt': 38,
 'surface_azimuth': 180,
 'albedo': 0.4,
 'gcr': 0.5,
 'rho_front_pvrow': 0.075,
 'rho_back_pvrow': 0.075,
 'cut': {0: {'front': 1, 'back': 7},
  1: {'front': 1, 'back': 7},
  2: {'front': 1, 'back': 7}}}
data = get_data(fname, params)
pvarray = run_pvfactors_simulation(data, params)
/home/tc256760/anaconda3/envs/fastai/lib/python3.7/site-packages/pvfactors/viewfactors/vfmethods.py:181: RuntimeWarning: invalid value encountered in true_divide
  vf_pvrow_to_gnd_surf * pvrow_surf_length / gnd_surf_length, 0.)
/home/tc256760/anaconda3/envs/fastai/lib/python3.7/site-packages/pvfactors/viewfactors/vfmethods.py:181: RuntimeWarning: divide by zero encountered in true_divide
  vf_pvrow_to_gnd_surf * pvrow_surf_length / gnd_surf_length, 0.)
/home/tc256760/anaconda3/envs/fastai/lib/python3.7/site-packages/pvfactors/viewfactors/vfmethods.py:531: RuntimeWarning: divide by zero encountered in true_divide
  vf_1_to_2 = (d1 + d2 - l1 - l2) / (2. * width)
/home/tc256760/anaconda3/envs/fastai/lib/python3.7/site-packages/pvfactors/viewfactors/vfmethods.py:531: RuntimeWarning: invalid value encountered in true_divide
  vf_1_to_2 = (d1 + d2 - l1 - l2) / (2. * width)
/home/tc256760/anaconda3/envs/fastai/lib/python3.7/site-packages/pvfactors/viewfactors/vfmethods.py:607: RuntimeWarning: invalid value encountered in true_divide
  vf_1_to_2 = np.abs(sum_2 - sum_1) / (2. * width_1)
/home/tc256760/anaconda3/envs/fastai/lib/python3.7/site-packages/pvfactors/viewfactors/vfmethods.py:222: RuntimeWarning: invalid value encountered in true_divide
  vf_i_to_j * length_i / length_j, 0.)
ax = plot_idx(pvarray)
ax.set_xlim(-2, 10)
(-2, 10)

png

res_pvfactors = individual_report(pvarray, index=data.index)
res_pvfactors.head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
qinc_0 qinc_1 qinc_2 qinc_3 qinc_4 qinc_5 qinc_6 qinc_front qinc_back
time(UTC)
2019-01-01 00:00:00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2019-01-01 01:00:00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2019-01-01 02:00:00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2019-01-01 03:00:00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2019-01-01 04:00:00 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
res_pvfactors['21 June 2019'].plot();

png

bifacialvf

res_bifacialvf = run_bifacialvf_simulation(data)
  0%|          | 0/8760 [00:00<?, ?it/s]/home/tc256760/Apps/bifacialvf/bifacialvf/vf.py:300: RuntimeWarning: divide by zero encountered in double_scalars
  projectedX2 = PcellX + np.float64(PcellY) / math.tan(startElvDown);      # Projection of ElvDown to ground in +x direction (X1 and X2 opposite nomenclature for front irradiance method)
  0%|          | 40/8760 [00:00<00:22, 379.91it/s]


********* 
Running Simulation for TMY3:  Chambery
Location:   Chambery
Lat:  45.637001  Long:  5.881  Tz  -1.0
Parameters: beta:  0   Sazm:  180   Height:  0.5   rtr separation:  8.0   Row type:  interior   Albedo:  0.4
Saving into output.csv




100%|██████████| 8760/8760 [00:27<00:00, 314.85it/s]

Finished
res_bifacialvf['21 June 2019'].plot();

png

Coontributing 👇

Read nbdev documentation please.

Metadata

Release files for capetools 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for capetools 1.0.2
File Size Uploaded Provenance Actions
capetools-1.0.2.tar.gz 21.8 kB Without provenance Details for capetools-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for capetools 1.0.2
File Interpreter ABI Platform Actions
capetools-1.0.2-py3-none-any.whl Python 3 none any Details for capetools-1.0.2-py3-none-any.whl

Total release size: 42.5 kB

Release files / capetools-1.0.2.tar.gz

Download URL capetools-1.0.2.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ee8e4c595ccbb2201e007a4f13032a7d04e27acc54a6b2bce2134010460dbc1
BLAKE2b-256 checksum
How to use checksums
1c864cad8c56b7fe8dcd37bd9b0b05ab15796044c65875f4f5e51a8f765c3306
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

Release files / capetools-1.0.2-py3-none-any.whl

Download URL capetools-1.0.2-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3a3bbfa730f5b33b7d8f5a6ae94f6cbf13da9c418ea83e107f64a3f7869e859
BLAKE2b-256 checksum
How to use checksums
dea9e5644f647c580daf61da0de053440994f47444bf8d88e6c943db49f2c7b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

Security for capetools 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page