Skip to content

Commit

Permalink
Merge pull request #9 from AdamRJensen/sphinx
Browse files Browse the repository at this point in the history
Setup sphinx and automatic documentation
  • Loading branch information
AdamRJensen authored Feb 15, 2022
2 parents f8644c7 + 184a464 commit 6428f52
Show file tree
Hide file tree
Showing 25 changed files with 1,999 additions and 1,577 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.ipynb_checkpoints
.vscode
*/.ipynb_checkpoints/*
__pycache__/*
test_file.csv
__pycache__/

# Distribution / packaging
*/build/
*.egg-info/

# generated documentation
docs/source/generated
18 changes: 18 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

conda:
environment: docs/environment.yml

build:
image: latest

# This part is necessary otherwise the project is not built
python:
version: 3.7
install:
- method: pip
path: .

# By default readthedocs does not checkout git submodules
submodules:
include: all
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2021, Adam R. Jensen
Copyright (c) 2021-2022, twoaxistracking Development Team
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# Open source code for calculating self-shading of two-axis tracking solar collectors
This repository contains Python code for simulation self-shading in fields of two-axis solar trackers.
"twoaxistracking" is a python package for simulating self-shading in fields of two-axis trackers.

The two main functions are `generate_field_layout` and `two_axis_shading_fraction`. The function `generate_field_layout` calculates the collector locations for a user-defined regular field layout. For an introduction to regular field layouts and the defining parameters, please see the paper by [Cumpston and Pye (2014)](https://doi.org/10.1016/j.solener.2014.06.012).
## Documentation
The documentation can be found at [readthedocs](https://twoaxistracking.readthedocs.io/).

The function `two_axis_shading_fraction` is used to calculate the shading fraction based on a specific field layout, aperture geometry, and solar position. Check out the [example tutorial](https://github.com/AdamRJensen/two_axis_tracker_shading/blob/main/notebooks/Example%20time%20series%20generation.ipynb) to get started! Alternatively, each function is documented according to the numpydoc style guide.
## Installation and dependencies
The package can be installed using pip:

pip install twoaxistracking

## Dependencies
The main non-standard dependency is `shapely`, which handles the geometric operations. It is recommended to install `shapely` using conda, which can be done by executing the following command in an Anaconda Prompt:

conda install shapely

The solar modeling library `pvlib` is recommended for calculating the solar position and can similarly be installed by the command:
The solar modeling library `pvlib` is recommended for calculating the solar position and can be installed by the command:

conda install -c conda-forge pvlib-python
## Citing
If you use the package in published work, please cite:
> Adam R. Jensen et al. 2022.
> "Self-shading of two-axis tracking solar collectors: Impact of field layout, latitude, and aperture shape."
> Accepted in Solar Energy.
## Contributing
Contributions to the repository, e.g., bug fixes and improvements to speed up the code are more than welcome.


## License
BSD 3-clause.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 15 additions & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: readthedocs
channels:
- defaults
- conda-forge
dependencies:
- python=3.7
- pandas
- matplotlib
- numpy
- shapely # Should be installed with conda
- sphinx
- pip:
- pvlib
- myst-nb
- sphinx-book-theme
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
1 change: 1 addition & 0 deletions docs/source/_static/twoaxistracking_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))

# -- Project information -----------------------------------------------------

project = 'Two-axis tracking'
copyright = '2021-2022, twoaxistracking Development Team'
author = 'twoaxistracking Development Team'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'myst_nb', # markdown and jupyter-notebook parsing
'sphinx.ext.autodoc', # generate documentation from docstrings
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon', # parsing of Numpy docstrings
]

# Add any paths that contain templates here, relative to this directory.
# templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_book_theme'
html_title = 'Two-axis tracking'
html_logo = "_static/twoaxistracking_logo.svg"
html_favicon = "_static/twoaxistracking_logo.svg"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
html_show_copyright = False

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None),
'matplotlib': ('https://matplotlib.org/stable', None),
'shapely': ('https://shapely.readthedocs.io/en/stable', None),
}

# Number of seconds for a cell to execute before timeout (default=30)
nbsphinx_timeout = 60
11 changes: 11 additions & 0 deletions docs/source/documentation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. currentmodule:: twoaxistracking


Code documentation
==================

.. autosummary::
:toctree: generated/

shaded_fraction
generate_field_layout
35 changes: 35 additions & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Simulating two-axis tracking solar collectors

`twoaxistracking` is a python package for simulating two-axis tracking solar collectors, particularly self-shading.

For a quick introduction to the package, check out the [intro tutorial](../notebooks/intro_tutorial) which demonstrates the main functionality. For further details, check out the [code documentation](../documentation).

Note, in the photovoltaics community, two-axis trackers are also commonly referred to as dual-axis trackers (DAT).


## Contributing
Contributions to the repository, e.g., bug fixes, feature request are more than welcome!


## License
[BSD 3-clause](https://github.com/AdamRJensen/twoaxistracking/blob/main/LICENSE).


## Citing
If you use the package in published work, please cite:
> Adam R. Jensen et al. 2022.
> "Self-shading of two-axis tracking solar collectors: Impact of field layout, latitude, and aperture shape."
> Solar Energy (2022). [https://doi.org/10.1016/j.solener.2022.02.023](https://doi.org/10.1016/j.solener.2022.02.023)

```{toctree}
:maxdepth: 1
:hidden:
notebooks/intro_tutorial
installation
documentation
whatsnew
notebooks/reference_dataset
notebooks/field_layout_discretization
```
13 changes: 13 additions & 0 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Installation

The package can be installed from [PyPi](https://pypi.org/) with the following command:

pip install twoaxistracking

The main non-standard dependency is `shapely`, which handles the geometric operations (i.e., shading calculations). It is highly recommended to install `shapely` using conda, which can be done by executing the following command in an Anaconda Prompt:

conda install shapely

The solar energy modeling library `pvlib` is recommended for calculating the solar position and can be installed by the command:

pip install pvlib
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Numerical investigation of self-shading\n",
"# Field layout discretization\n",
"\n",
"This notebook demonstrates how to uniformly discretize the field layout parameters.\n",
"\n",
Expand Down Expand Up @@ -56,7 +56,7 @@
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"100.0\" height=\"100.0\" viewBox=\"-0.54 -0.54 1.08 1.08\" preserveAspectRatio=\"xMinYMin meet\"><g transform=\"matrix(1,0,0,-1,0,0.0)\"><path fill-rule=\"evenodd\" fill=\"#66cc99\" stroke=\"#555555\" stroke-width=\"0.0216\" opacity=\"0.6\" d=\"M 0.5,-0.5 L 0.5,0.5 L -0.5,0.5 L -0.5,-0.5 L 0.5,-0.5 z\" /></g></svg>"
],
"text/plain": [
"<shapely.geometry.polygon.Polygon at 0x28aed11d160>"
"<shapely.geometry.polygon.Polygon at 0x24f35d4cee0>"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -242,14 +242,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Visualization of layout discretization\n",
"The following plots illustrate the discrete aspect ratios and offsets for GCR=0.2 and GCR=0.3. Note, each point shown is simulated for the all discrete rotations."
"## Visualization of layout discretization\n",
"The following plot illustrates the discrete aspect ratios and offsets for GCR=0.2 and GCR=0.3. Note, each point shown is simulated for the all discrete rotations."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"tags": [
"hide-input"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -292,7 +296,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -306,7 +310,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.7.11"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 6428f52

Please sign in to comment.