From 2947bfcefea928758f872074196e26cadabef8ac Mon Sep 17 00:00:00 2001 From: "Olivier J.N. Bertrand" <bolirev@hotmail.com> Date: Wed, 3 Jan 2018 15:27:10 +0100 Subject: [PATCH] Update the doc of database --- doc/source/example/database/get_posorients.py | 13 ++++++++ .../example/database/load_image_posorient.py | 8 +++-- .../example/database/load_image_rowid.py | 8 +++-- doc/source/moving.rst | 12 ++++--- navipy/database/__init__.py | 33 +++++-------------- 5 files changed, 39 insertions(+), 35 deletions(-) create mode 100644 doc/source/example/database/get_posorients.py diff --git a/doc/source/example/database/get_posorients.py b/doc/source/example/database/get_posorients.py new file mode 100644 index 0000000..89b3f2a --- /dev/null +++ b/doc/source/example/database/get_posorients.py @@ -0,0 +1,13 @@ +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +from navipy.database import DataBaseLoad +import pkg_resources + + +# 1) Connect to the database +mydb_filename = pkg_resources.resource_filename( + 'navipy', 'resources/database.db') +mydb = DataBaseLoad(mydb_filename) +posorients = mydb.posorients +posorients.head(n=5) diff --git a/doc/source/example/database/load_image_posorient.py b/doc/source/example/database/load_image_posorient.py index 6b22ef1..43b4206 100644 --- a/doc/source/example/database/load_image_posorient.py +++ b/doc/source/example/database/load_image_posorient.py @@ -2,11 +2,12 @@ import pandas as pd import numpy as np import matplotlib.pyplot as plt from navipy.database import DataBaseLoad -import os +import pkg_resources # 1) Connect to the database -mydb_filename = os.path.abspath('../database.db') +mydb_filename = pkg_resources.resource_filename( + 'navipy', 'resources/database.db') mydb = DataBaseLoad(mydb_filename) # 2) Define the position-orinetation at which # we want the image @@ -19,7 +20,8 @@ posorient.alpha_0 = np.pi / 2 posorient.alpha_1 = 0 posorient.alpha_2 = 0 # 3) Load the image -image = mydb.read_image(posorient=posorient) +image = mydb.scene(posorient=posorient) +image = image[...,0] # 4) plot the image to_plot_im = image[:, :, :3] to_plot_im -= to_plot_im.min() diff --git a/doc/source/example/database/load_image_rowid.py b/doc/source/example/database/load_image_rowid.py index e67ab2a..fcd1fca 100644 --- a/doc/source/example/database/load_image_rowid.py +++ b/doc/source/example/database/load_image_rowid.py @@ -1,17 +1,19 @@ import numpy as np import matplotlib.pyplot as plt from navipy.database import DataBaseLoad -import os +import pkg_resources # 1) Connect to the database -mydb_filename = os.path.abspath('../database.db') +mydb_filename = pkg_resources.resource_filename( + 'navipy', 'resources/database.db') mydb = DataBaseLoad(mydb_filename) # 2) Define the position-orinetation at which # we want the image rowid = 12 # 3) Load the image -image = mydb.read_image(rowid=rowid) +image = mydb.scene(rowid=rowid) +image = image[...,0] # 4) plot the image to_plot_im = image[:, :, :3] to_plot_im -= to_plot_im.min() diff --git a/doc/source/moving.rst b/doc/source/moving.rst index f6d1353..1163efd 100644 --- a/doc/source/moving.rst +++ b/doc/source/moving.rst @@ -1,11 +1,13 @@ Moving ====== -Moving on a grid ----------------- +.. automodule:: navipy.moving -Moving between grid points --------------------------- -Interpolation of neighbouring images +.. autoclass:: navipy.moving.agent.CyberBeeAgent + :members: +.. autoclass:: navipy.moving.agent.GridAgent + :members: +.. autoclass:: navipy.moving.agent.GraphAgent + :members: diff --git a/navipy/database/__init__.py b/navipy/database/__init__.py index cd90192..c4bd1d6 100644 --- a/navipy/database/__init__.py +++ b/navipy/database/__init__.py @@ -13,11 +13,8 @@ are normalised, so to use the full coding range. How to load a database ---------------------- -.. code-block:: python - - from database import DataBaseLoad - mydb_filename = 'database.db' - mydb = DataBaseLoad(mydb_filename) +.. literalinclude:: example/database/get_posorients.py + :lines: 11 How to load all position-orientation ------------------------------------ @@ -28,10 +25,10 @@ situation, it may be usefull to know all \ position-orientation in the database. More technically \ speaking, loading the full table of position-orientaiton. -.. code-block:: python +.. literalinclude:: example/database/get_posorients.py + :lines: 12-13 - posorients = mydb.get_posorients() - posorients.head() +.. plot:: example/database/get_posorients.py How to load an image -------------------- @@ -44,17 +41,8 @@ the position-orientation can be given. The DataBaseLoader will \ look if this position-orientation has been rendered. If it is \ the case, the image will be returned. -.. code-block:: python - - posorient = pd.Series(index=['x', 'y', 'z', - 'alpha_0', 'alpha_1', 'alpha_2']) - posorient.x = -0.6 - posorient.y = -7.2 - posorient.z = 2.35 - posorient.alpha_0 = np.pi / 2 - posorient.alpha_1 = 0 - posorient.alpha_2 = 0 - image = mydb.read_image(posorient=posorient) +.. literalinclude:: example/database/load_image_posorient.py + :lines: 14-23 .. plot:: example/database/load_image_posorient.py @@ -65,15 +53,12 @@ Indeed each position-orientation can be identified by a unique row \ number. This number is consistant through the entire database. Thus, \ an image can be loaded by providing the row number. -.. code-block:: python - - rowid = 1000 - image = mydb.read_image(rowid=rowid) +.. literalinclude:: example/database/load_image_rowid.py + :lines: 13-15 .. plot:: example/database/load_image_rowid.py - .. todo: channels as part of database """ -- GitLab