Skip to content

Commit

Permalink
adding exoplanets example to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dfm committed Oct 4, 2012
1 parent 191cdf5 commit 07f2ebc
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/_static/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"wordy": [230, 105],
"weaklensing": [200, 85],
"mrf": [ 18, 18],
"exoplanets": [117, 140],
"badfont": [ 15, 10]
}
Binary file added docs/_static/examples/exoplanets-thumb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/exoplanets.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions docs/examples/exoplanets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.. _exoplanets:


The Fergus model of exoplanet detection
=======================================

.. figure:: /_static/examples/exoplanets.png


The Fergus model of exoplanet detection
=======================================

Besides being generally awesome, this example also demonstrates how you can
color the nodes and add arbitrary labels to the figure.



::

from matplotlib import rc
rc("font", family="serif", size=12)
rc("text", usetex=True)
import daft
# Colors.
p_color = {"ec": "#46a546"}
s_color = {"ec": "#f89406"}
pgm = daft.PGM([3.6, 3.5], origin=[0.7, 0])
pgm.add_node(daft.Node("phi", r"$\phi$", 1, 3, plot_params=s_color))
pgm.add_node(daft.Node("speckle_coeff", r"$z_i$", 2, 3, plot_params=s_color))
pgm.add_node(daft.Node("speckle_img", r"$x_i$", 2, 2, plot_params=s_color))
pgm.add_node(daft.Node("spec", r"$s$", 4, 3, plot_params=p_color))
pgm.add_node(daft.Node("shape", r"$g$", 4, 2, plot_params=p_color))
pgm.add_node(daft.Node("planet_pos", r"$\mu_i$", 3, 3, plot_params=p_color))
pgm.add_node(daft.Node("planet_img", r"$p_i$", 3, 2, plot_params=p_color))
pgm.add_node(daft.Node("pixels", r"$y_i ^j$", 2.5, 1, observed=True))
# Edges.
pgm.add_edge("phi", "speckle_coeff")
pgm.add_edge("speckle_coeff", "speckle_img")
pgm.add_edge("speckle_img", "pixels")
pgm.add_edge("spec", "planet_img")
pgm.add_edge("shape", "planet_img")
pgm.add_edge("planet_pos", "planet_img")
pgm.add_edge("planet_img", "pixels")
# And a plate.
pgm.add_plate(daft.Plate([1.5, 0.2, 2, 3.2], label=r"exposure $i$",
shift=-0.1))
pgm.add_plate(daft.Plate([2, 0.5, 1, 1], label=r"pixel $j$",
shift=-0.1))
# Render and save.
pgm.render()
pgm.figure.savefig("exoplanets.pdf")
pgm.figure.savefig("exoplanets.png", dpi=150)

1 change: 0 additions & 1 deletion examples/exoplanets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import daft


# Colors.
p_color = {"ec": "#46a546"}
s_color = {"ec": "#f89406"}
Expand Down

0 comments on commit 07f2ebc

Please sign in to comment.