Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
gplessm committed Dec 16, 2016
2 parents b5dae76 + 495e8af commit 272e225
Show file tree
Hide file tree
Showing 19 changed files with 533 additions and 171 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
60 changes: 43 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,36 +1,68 @@
An oemof extension to use the oemof related postgis database.

To use this extension you have to have access to the oemof postgis database.
See `the documentation`_ for more information!

.. _`the documentation`: https://oemofdb.readthedocs.io


The oemof code will be released in early 2016 but you can try this extension
already with the feedinlib. If you are interested to join the oemof database
project please contact us.

Installation
++++++++++++

Clone the repository to your local system.
Use pypi to install the latest oemof version.

.. code:: bash
pip3 install oemof
If you want to have the developer version clone the repository by

.. code:: bash
git clone git@github.com:oemof/oemof.db.git
Then you can install it using pip3 with the -e flag.
and can install it using pip3 with the -e flag.

.. code:: bash
sudo pip3 install -e <path/to/the/oemof.db/repository/root/directory>
.. _readme#configuration:

Configuration
+++++++++++++
Keep `virtualenvs`_ in mind!

.. _`keyring package`: https://virtualenv.pypa.io

Configuration and usage
+++++++++++++++++++++++

As the purpose of this package is to facilitate usage of the ``oemof``
database, it needs to know how to connect to this database. Being part of
``oemof``, ``oemof.db`` looks for this configuration in the file ``config.ini``
in a directory called ``.oemof`` in your home directory.
``oemof``, as fallback ``oemof.db`` always looks for this configuration in the
file ``config.ini`` in a directory called ``.oemof`` in your home directory.

A particular config-file can either specified and accessed via


.. code-block:: python
from oemof.db import cfg
# only load config file
cfg.load_config(config_file=<you-config-file>)
# access config parameters
cfg.get(<section>, <parameter>)
If you're interested in establishing a database connection and specify config
file connection parameters are stored in use

.. code-block:: python
from oemof.db import cfg
# establish database connection with specified section and config_file
db.connection(section=<section>, config_file=<you-config-file>)
To configure database access this file has to have at least one dedicated
section containing the necessary options, like this:
Expand Down Expand Up @@ -62,9 +94,3 @@ where ``"database"`` and ``"username"`` have the same values as the
corresponding options in ``config.ini``.

.. _`keyring package`: https://pypi.python.org/pypi/keyring

Required packages
+++++++++++++++++

* python3-sqlalchemy
* python3-keyring
7 changes: 0 additions & 7 deletions doc/api/coastdat.rst

This file was deleted.

7 changes: 0 additions & 7 deletions doc/api/config.rst

This file was deleted.

7 changes: 0 additions & 7 deletions doc/api/db.rst

This file was deleted.

9 changes: 3 additions & 6 deletions doc/api/modules.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
oemof_pg
========
oemof
=====

.. toctree::
:maxdepth: 4

coastdat
config
db
tools
oemof
62 changes: 62 additions & 0 deletions doc/api/oemof.db.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
oemof.db package
================

Submodules
----------

oemof.db.coastdat module
------------------------

.. automodule:: oemof.db.coastdat
:members:
:undoc-members:
:show-inheritance:

oemof.db.config module
----------------------

.. automodule:: oemof.db.config
:members:
:undoc-members:
:show-inheritance:

oemof.db.feedin_pg module
-------------------------

.. automodule:: oemof.db.feedin_pg
:members:
:undoc-members:
:show-inheritance:

oemof.db.powerplants module
---------------------------

.. automodule:: oemof.db.powerplants
:members:
:undoc-members:
:show-inheritance:

oemof.db.test_config_changes module
-----------------------------------

.. automodule:: oemof.db.test_config_changes
:members:
:undoc-members:
:show-inheritance:

oemof.db.tools module
---------------------

.. automodule:: oemof.db.tools
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: oemof.db
:members:
:undoc-members:
:show-inheritance:
17 changes: 17 additions & 0 deletions doc/api/oemof.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
oemof package
=============

Subpackages
-----------

.. toctree::

oemof.db

Module contents
---------------

.. automodule:: oemof
:members:
:undoc-members:
:show-inheritance:
7 changes: 0 additions & 7 deletions doc/api/tools.rst

This file was deleted.

8 changes: 4 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@

# General information about the project.
project = u'oemof.db'
copyright = u'2015, oemof developing group'
copyright = u'2015-2016, oemof developing group'
author = u'Uwe Krien, oemof developing group'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.0.8'
version = '0.0.4'
# The full version, including alpha/beta/rc tags.
release = 'beta'
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -277,7 +277,7 @@
epub_title = u'oemof.db'
epub_author = u'Uwe Krien, oemof developing group'
epub_publisher = u'oemof developing group'
epub_copyright = u'2015, oemof developing group'
epub_copyright = u'2015-2016, oemof developing group'

# The basename for the epub file. It defaults to the project name.
#epub_basename = u'pahesmf'
Expand Down
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ These are new features and improvements of note in each release
:local:
:backlinks: top

.. include:: whatsnew/v0004.txt
.. include:: whatsnew/v0003.txt
.. include:: whatsnew/v0002.txt
.. include:: whatsnew/v0001.txt
35 changes: 35 additions & 0 deletions doc/whatsnew/v0004.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
v0.0.4 (December 16, 2016)
++++++++++++++++++++++++++

New features
############

* Create an empty database table with primary key type serial in `tools.py`
* Access grant to users/ group of users, see `grant_db_access` in `tools.py`
* Additional optional keyword argument to specify config file (`issue #21 <https://github.com/oemof/oemof.db/issues/21>`_)
* Ask for password and save store in keyring if not existent (`issue #22 <https://github.com/oemof/oemof.db/issues/22>`_)


Documentation
#############


Testing
#######


Bug fixes
#########

* Add missing keyrings.alt dependency


Other changes
#############


Contributors
############

* Guido Pleßmann
* Uwe Krien
25 changes: 13 additions & 12 deletions examples/feedinlib_example_coastdat.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8

try:
from matplotlib import pyplot as plt
plot_fkt = True
except:
plot_fkt = False
except ImportError:
plt = None

import logging
from shapely import geometry as geopy

from oemof_pg import db
from oemof_pg import coastdat
import oemof.db as db
from oemof.db import coastdat

from feedinlib import powerplants as plants
from feedinlib import models
import feedinlib.powerplants as plants
import feedinlib.models as models

# Feel free to remove or change these lines
import warnings
Expand Down Expand Up @@ -80,12 +79,14 @@
year = 2010

conn = db.connection()
my_weather = coastdat.get_weather(
my_weather_single = coastdat.get_weather(
conn, geopy.Point(loc_berlin['longitude'], loc_berlin['latitude']), year)

geo = geopy.Polygon([(12.2, 52.2), (12.2, 51.6), (13.2, 51.6), (13.2, 52.2)])
multi_weather = coastdat.get_weather(conn, geo, year)

my_weather = multi_weather[0]
# my_weather = my_weather_single

# Initialise different power plants
E126_power_plant = plants.WindPowerPlant(**enerconE126)
Expand All @@ -101,7 +102,7 @@
E126_feedin.name = 'E126'
V90_feedin.name = 'V90'

if plot_fkt:
if plt:
E126_feedin.plot(legend=True)
V90_feedin.plot(legend=True)
plt.show()
Expand All @@ -123,7 +124,7 @@
pv_feedin5.name = 'Advent'

# Output
if plot_fkt:
if plt:
pv_feedin4.plot(legend=True)
pv_feedin5.plot(legend=True)
plt.show()
Expand All @@ -135,7 +136,7 @@
w_model.get_wind_pp_types()
cp_values = models.SimpleWindTurbine().fetch_cp_values(
wind_conv_type='ENERCON E 126 7500')
if plot_fkt:
if plt:
plt.plot(cp_values.loc[0, :][2:55].index,
cp_values.loc[0, :][2:55].values, '*')
plt.show()
Expand Down
Loading

0 comments on commit 272e225

Please sign in to comment.