Skip to content

Commit

Permalink
documentation overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
jdechalendar committed Mar 3, 2024
1 parent dbb9b9c commit ab43c90
Show file tree
Hide file tree
Showing 26 changed files with 341 additions and 23 deletions.
66 changes: 66 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.. _api:

API reference
=============
This page gives an overview of all public ``gridemissions`` objects.

.. currentmodule:: gridemissions

Data structure
--------------
The main abstraction we use for holding data is :class:`GraphData`

.. autosummary::
:toctree: generated/

GraphData
read_csv
GraphData.to_csv

Accessing data

.. autosummary::
:toctree: generated/

GraphData.get_data
GraphData.get_cols
GraphData.has_field

There are several helper methods to check data consistency.

.. autosummary::
:toctree: generated/

GraphData.check_all
GraphData.check_antisymmetric
GraphData.check_balance
GraphData.check_generation_by_source
GraphData.check_interchange
GraphData.check_nans
GraphData.check_positive

Data cleaning
-------------
.. autosummary::
:toctree: generated/

BasicCleaner
BasicCleaner.process
RollingCleaner
RollingCleaner.process

Data reconciliation
-------------------
.. autosummary::
:toctree: generated/

CvxCleaner
CvxCleaner.process

Consumption-based emissions
---------------------------
.. autosummary::
:toctree: generated/

EmissionsCalc
EmissionsCalc.process
8 changes: 3 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
from os.path import relpath, dirname
import gridemissions

sys.path.insert(0, os.path.abspath("../src/gridemissions"))


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

project = "Grid emissions"
project = "gridemissions"
copyright = "2020, Jacques de Chalendar"
author = "Jacques de Chalendar"

Expand Down Expand Up @@ -52,13 +50,13 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "alabaster"
html_theme = "pydata_sphinx_theme"


# 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"]
html_static_path = []


# based on numpy doc/source/conf.py
Expand Down
30 changes: 30 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. _config:

Configuration
=============
Some configuration is needed for this project, to hold environment variables like data paths, API keys and passwords. The recommended option is to use a configuration file (``config.json``). A default is created for you the first time you import the package, in the folder ``~/.config/gridemissions``. ``~`` stands for your home directory. On Linux, this is what ``$HOME`` evaluates to, on Windows/OSX, this is the directory that contains your Documents, Desktop and Downloads folders.

Alternatively, configuration settings can be read from environment variables, e.g. with

.. code-block:: bash
export GRIDEMISSIONS_CONFIG_DIR_PATH="$HOME/.config/gridemissions_test"
The config.json file
--------------------
Whenever you import the gridemissions module, the key-value pairs stored in ``config.json`` are loaded into a dictionary that then becomes available to you as the dictionary gridemissions.config. These can also be modified at runtime. At a minimum, your ``config.json`` should contain:

* ``DATA_PATH``: path to local data store, by default ``~/data/gridemissions``
* ``TMP_PATH``: for scratch data (e.g. when downloading data), by default ``~/tmp/gridemissions``

Supported Environment Variables
-------------------------------

.. code-block:: bash
GRIDEMISSIONS_CONFIG_DIR_PATH # the configuration directory (default: "$HOME/.config/gridemissions")
GRIDEMISSIONS_LOG_CONFIG_FILE_PATH # the file used to store logging (default: "$HOME/.config/gridemissions/logging.conf")
GRIDEMISSIONS_CONFIG_FILE_PATH: # the configuration file (default: "$HOME/.config/gridemissions/config.json")
GRIDEMISSIONS_DEFAULT_LOGGING_CONF # the default logging configuration (default can be read within ./src/gridemissions/configure.py")
GRIDEMISSIONS_DATA_DIR_PATH # the data directory (default: "$HOME/data/gridemissions")
GRIDEMISSIONS_TMP_DIR_PATH # the temporary data directory (default: "$HOME/tmp/gridemissions")
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.BasicCleaner.process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.BasicCleaner.process
==================================

.. currentmodule:: gridemissions

.. automethod:: BasicCleaner.process
17 changes: 17 additions & 0 deletions docs/generated/gridemissions.BasicCleaner.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gridemissions.BasicCleaner
==========================

.. currentmodule:: gridemissions

.. autoclass:: BasicCleaner


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~BasicCleaner.__init__
~BasicCleaner.process
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.CvxCleaner.process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.CvxCleaner.process
================================

.. currentmodule:: gridemissions

.. automethod:: CvxCleaner.process
17 changes: 17 additions & 0 deletions docs/generated/gridemissions.CvxCleaner.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gridemissions.CvxCleaner
========================

.. currentmodule:: gridemissions

.. autoclass:: CvxCleaner


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~CvxCleaner.__init__
~CvxCleaner.process
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.EmissionsCalc.process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.EmissionsCalc.process
===================================

.. currentmodule:: gridemissions

.. automethod:: EmissionsCalc.process
17 changes: 17 additions & 0 deletions docs/generated/gridemissions.EmissionsCalc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gridemissions.EmissionsCalc
===========================

.. currentmodule:: gridemissions

.. autoclass:: EmissionsCalc


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~EmissionsCalc.__init__
~EmissionsCalc.process
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.check_all.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_all
==================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_all
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_antisymmetric
============================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_antisymmetric
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.check_balance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_balance
======================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_balance
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_generation\_by\_source
=====================================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_generation_by_source
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.check_interchange.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_interchange
==========================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_interchange
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.check_nans.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_nans
===================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_nans
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.check_positive.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.check\_positive
=======================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.check_positive
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.get_cols.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.get\_cols
=================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.get_cols
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.get_data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.get\_data
=================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.get_data
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.has_field.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.has\_field
==================================

.. currentmodule:: gridemissions

.. automethod:: GraphData.has_field
28 changes: 28 additions & 0 deletions docs/generated/gridemissions.GraphData.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
gridemissions.GraphData
=======================

.. currentmodule:: gridemissions

.. autoclass:: GraphData


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~GraphData.__init__
~GraphData.check_all
~GraphData.check_antisymmetric
~GraphData.check_balance
~GraphData.check_generation_by_source
~GraphData.check_interchange
~GraphData.check_nans
~GraphData.check_positive
~GraphData.get_cols
~GraphData.get_data
~GraphData.has_field
~GraphData.to_csv
~GraphData.to_parquet
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.GraphData.to_csv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.GraphData.to\_csv
===============================

.. currentmodule:: gridemissions

.. automethod:: GraphData.to_csv
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.RollingCleaner.process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.RollingCleaner.process
====================================

.. currentmodule:: gridemissions

.. automethod:: RollingCleaner.process
17 changes: 17 additions & 0 deletions docs/generated/gridemissions.RollingCleaner.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gridemissions.RollingCleaner
============================

.. currentmodule:: gridemissions

.. autoclass:: RollingCleaner


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~RollingCleaner.__init__
~RollingCleaner.process
6 changes: 6 additions & 0 deletions docs/generated/gridemissions.read_csv.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gridemissions.read\_csv
=======================

.. currentmodule:: gridemissions

.. autofunction:: read_csv
30 changes: 12 additions & 18 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
.. Grid emissions documentation master file, created by
sphinx-quickstart on Sat Sep 19 15:20:32 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. gridemissions documentation master file
Documentation for the gridemissions project
Documentation for the gridemissions package
===========================================

Introduction
~~~~~~~~~~~~~
The tools in this package power the visualization at `energy.stanford.edu/gridemissions`_, updated hourly. Associated datasets on electricity and emissions are made publicly available. In addition to tools to create the data, the gridemissions package provides a module to retrieve data from the API and methods to load and manipulate the data.

Documentation contents
~~~~~~~~~~~~~~~~~~~~~~
.. toctree::
:maxdepth: 2
:caption: Contents:

Configuration
~~~~~~~~~~~~~
To come.

Workflows
~~~~~~~~~~~~~
To come
config
operations
api

API reference
~~~~~~~~~~~~~
.. autosummary::
:toctree: generated/

api.retrieve
.. _energy.stanford.edu/gridemissions: https://energy.stanford.edu/gridemissions
Loading

0 comments on commit ab43c90

Please sign in to comment.