Skip to content

Commit

Permalink
Add updated animation with buttons to doc; fix plotting docs build.
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-j committed Nov 30, 2020
1 parent 28cd655 commit 5263121
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 22 deletions.
17 changes: 17 additions & 0 deletions doc/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
div.initial {}

div.itemBox {
display: none;

}

.item_image {
width: 70vw;
height: auto;
}

button {
font-size: 1.5vw;
border-radius: 0.25vw;
color: white;
}
Binary file added doc/_static/images/animation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/images/nband7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions doc/animate_nbands.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@



<div style="margin:auto;">
<p>
<h2 align="center">
<br> &rarr;
<button type="button" style="background-color: #9e9a9a;" id ="button1" href="javascript:alert('t');return false"
alt="n1" onclick="myFunction('1');">One band</button>
<button type="button" style="background-color: #9e9a9a;" id ="button2" href="javascript:alert('t');return false"
alt="n2" onclick="myFunction('2');">Two bands</button>
<button type="button" style="background-color: #9e9a9a;" id ="button3" href="javascript:alert('t');return false"
alt="n3" onclick="myFunction('3');">Optical</button>
<button type="button" style="background-color: #9e9a9a;" id ="button4" href="javascript:alert('t');return false"
alt="n4" onclick="myFunction('4');">Opt/NIR</button>
<button type="button" style="background-color: #9e9a9a;" id ="button5" href="javascript:alert('t');return false"
alt="n5" onclick="myFunction('5');">UV/Opt/NIR</button>
<button type="button" style="background-color: #9e9a9a;" id ="button6" href="javascript:alert('t');return false"
alt="n6" onclick="myFunction('6');">UV/Opt/NIR/MIR</button>
<button type="button" style="background-color: #9e9a9a;" id ="button7" href="javascript:alert('t');return false"
alt="n7" onclick="myFunction('7');">All Bands</button>
<button type="button" style="background-color: #228B22;" id ="button0" href="javascript:alert('t');return false"
alt="mov" onclick="myFunction('0');">Movie</button>
<h2> </div>
</p>

<div class="initial" id="item0" align='center'>
<img src="_static/images/animation.gif" alt="First example image" class="item_image" />
</div>
<div class="itemBox" id="fig1" align='center'>
<img src="_static/images/nband1.png" alt="Second example image" class="item_image" id="extra"/>
</div>

</div>

<script type="text/javascript">
function myFunction(itemNo) {

var item = "item" + itemNo;
var buttonName = "button" + itemNo;

// turn everything off
var elements = document.getElementsByTagName("button");
for (var i = 0; i < elements.length; i++) {
elements[i].style.backgroundColor = "#9e9a9a";
}
var x = document.getElementsByClassName("initial")[0];
x.style.display = "none";

// Turn the requested thing on
var x = document.getElementById(buttonName);
x.style.backgroundColor = "#228B22";

// Change the image source
var element = document.getElementsByClassName("itemBox")[0];
var image = element.getElementsByClassName("item_image")[0];
if (itemNo == "0"){
image.src = "_static/images/animation.gif";
} else {
image.src = "_static/images/nband"+itemNo+".png";
}
element.style.display = "block";

}
</script>
6 changes: 3 additions & 3 deletions doc/api/plotting_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ prospect.plotting.utils
:members: sample_prior, sample_posterior

prospect.plotting.sfh
-----------------------
---------------------

.. automodule:: prospect.plotting.sfh
:members: sfh_quantiles, parametric_sfr, nonpar_recent_sfr, parametric_mwa, nonpar_mwa

prospect.plotting.corner
-----------------------
------------------------

.. automodule:: prospect.plotting.utils
.. automodule:: prospect.plotting.corner
:members: quantile, marginal, corner

1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
# html_short_title = None

html_static_path = ["_static"]
html_css_files = ['css/custom.css']

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
Expand Down
24 changes: 15 additions & 9 deletions doc/demo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ You can check out the Jupyter notebook demo at

* `InteractiveDemo <https://github.com/bd-j/prospector/blob/main/demo/InteractiveDemo.ipynb>`_

Also, below is an example of inference from an increasing number of photometric bands.
Model parameters and SEDs are inferred (in grey) from a changing number of mock
photometric bands. The mock is generated at the parameters marked in blue. This
shows how with a small amount of data most posteriors are determined by the
prior (dashed red) but that as the number of bands increases, the data are more
infomative and the posterior distributions are narrower than the prior.

.. image:: images/animation.gif
:align: center
Interactive Figure
------------------

Also, below is an example of inference from an increasing number of photometric
bands. Model parameters and SEDs are inferred (in blue) from a changing number
of mock photometric bands (grey points). The mock is generated at the parameters
and with the SED marked in black. This shows how with a small amount of data
most posteriors are determined by the prior (dotted green) but that as the
number of bands increases, the data are more infomative and the posterior
distributions are narrower than the prior.

Click the buttons show the inference for different filter sets:

.. raw:: html
:file: animate_nbands.html
10 changes: 5 additions & 5 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ simultaneously. See


What bins should I use for the non-parametric SFH?
-------------------------------------------------
--------------------------------------------------
Deciding on the "optimal" number of bins to use in such non-parametric SFHs is a
difficult question. The pioneering work of
`ocvirk06 <https://ui.adsabs.harvard.edu/abs/2006MNRAS.365...46O/abstract>`_
Expand Down Expand Up @@ -186,7 +186,7 @@ large samples of objects.


What settings should I use for `dynesty`?
--------------------------------------
-----------------------------------------
The default `dynesty` settings in |Codename| are optimized for a
low-dimensional (N=4-7) model. Higher-dimensional models with more complex
likelihood spaces will likely require more advanced `dynesty` settings to
Expand Down Expand Up @@ -214,7 +214,7 @@ sampling has converged to the correct *distribution*


How do I use `emcee` in |Codename|?
-------------------------------------
-----------------------------------
For each parameter, an initial value (``"init"`` in the parameter specification)
must be given. The ensemble of walkers is initialized around this value, with a
Gaussian spread that can be specified separately for each parameter. Each
Expand Down Expand Up @@ -315,13 +315,13 @@ This is a general question for MC sampling techniques.


Why isn't the posterior PDF centered on the highest posterior probability sample?
---------------------------------------------------------------------
---------------------------------------------------------------------------------

How do I interpret the `lnprobability` or `lnp` values? Why do I get `lnp > 0`?
-------------------------------------------------------------------------------

How do I know if Prospector is "working"?
---------------------------------------
-----------------------------------------



Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
numpy >= 1.16
scipy >= 1.1.0
matplotlib >= 3.0
sphinx>=1.7.5
11 changes: 7 additions & 4 deletions prospect/plotting/corner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import numpy as np
from scipy.ndimage import gaussian_filter as norm_kde

import matplotlib.pyplot as pl
from matplotlib.ticker import MaxNLocator, NullLocator
from matplotlib.ticker import ScalarFormatter
from matplotlib.colors import LinearSegmentedColormap, colorConverter
try:
import matplotlib.pyplot as pl
from matplotlib.ticker import MaxNLocator, NullLocator
from matplotlib.ticker import ScalarFormatter
from matplotlib.colors import LinearSegmentedColormap, colorConverter
except(ImportError):
pass


__all__ = ["allcorner", "show_extras", "prettify_axes", "corner",
Expand Down
5 changes: 4 additions & 1 deletion prospect/plotting/figuremaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"""

import numpy as np
import matplotlib.pyplot as pl
try:
import matplotlib.pyplot as pl
except(ImportError):
pass

from ..io import read_results as reader
from ..io.write_results import chain_to_struct, dict_to_struct
Expand Down

0 comments on commit 5263121

Please sign in to comment.