Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes from 5/19 meeting #378

Closed
wants to merge 78 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d095315
updates to saving and loading and their tests
smattis Apr 7, 2020
1130367
updates to saving, loading, and copying
smattis Apr 8, 2020
a64c57a
many updates for v3
smattis Apr 10, 2020
80b6ac7
updates to data consistent stuff
smattis Apr 15, 2020
5bdd7a7
many new data consistent features
smattis Apr 16, 2020
fc60fcb
new features for pdfs
smattis Apr 17, 2020
d69b1db
new compare features and simplifies plotting
smattis Apr 18, 2020
973d18c
compareP works
smattis Apr 18, 2020
cee97a2
adds quadrature for marginals
smattis Apr 19, 2020
8586ea9
adds euclidian norm
smattis Apr 19, 2020
c79c746
compareP and its tests finished
smattis Apr 20, 2020
9b790b2
adds test problem setups
smattis Apr 20, 2020
bfc9588
updating tests
smattis Apr 21, 2020
47c1c06
removes adaptive sampling
smattis Apr 21, 2020
363d831
remove adaptive sampling examples
smattis Apr 21, 2020
d81511c
update __init__ files
smattis Apr 21, 2020
7e7550c
minor updates for tests
smattis Apr 21, 2020
7f6d947
new docs and test fixes
smattis Apr 21, 2020
9fdd09a
updates docs and tests for basicSampling
smattis Apr 21, 2020
11e13f4
updates docstrings
smattis Apr 22, 2020
c380862
adds new tests
smattis Apr 22, 2020
86f3ec5
docstrings and tests forme useLUQ.py
smattis Apr 22, 2020
003d6c2
update docstrings and tests for plotting
smattis Apr 22, 2020
aeb03f7
tests pass in serial and parallel
smattis Apr 22, 2020
437fbbd
modify tests to remove warnings
smattis Apr 22, 2020
5c90251
adds selkov example
smattis Apr 22, 2020
e1cf270
selkov example and update tests
smattis Apr 23, 2020
0c51aae
update copyright
smattis Apr 23, 2020
476a334
update travis for fork
smattis Apr 30, 2020
10f1aa0
Merge remote-tracking branch 'origin/master' into v3-steve
smattis Apr 30, 2020
74f6438
increase test coverage
smattis Apr 30, 2020
67d69b8
test using pytest
smattis May 4, 2020
502cd04
test using pytest
smattis May 4, 2020
ea41914
update tests for use with pytest
smattis May 4, 2020
a939ebb
update travis to test in parallel and without mpi4py
smattis May 4, 2020
9426267
remove coverage from parallel tests
smattis May 5, 2020
9324fe4
add ability for pip installation
smattis May 9, 2020
4973112
add LUQ to travis and tests
smattis May 9, 2020
f18ac96
increase test coverage for plotting
smattis May 9, 2020
7b0c5d4
modify plotting
smattis May 9, 2020
ca9e834
change matplotlib version requirement
smattis May 10, 2020
4f2edbc
working on examples
smattis May 13, 2020
6a2d8be
updates to comparison
smattis May 14, 2020
460edf1
updates to examples
smattis May 14, 2020
dcc8595
adds data consistent linear example
smattis May 14, 2020
4a1f435
adds nonlinear example
smattis May 14, 2020
3132d27
data consistent example
smattis May 14, 2020
65fd069
update copyrights
smattis May 14, 2020
5e097f8
Update README.md
smattis May 15, 2020
6471b48
Update README.md
smattis May 15, 2020
1e8d441
Update README.md
smattis May 15, 2020
1331441
Update README.md
smattis May 15, 2020
74cfeb1
Update README.md
smattis May 15, 2020
9a725e3
Update README.md
smattis May 15, 2020
94169f3
working on docs
smattis May 15, 2020
2bc6e58
Update README.md
smattis May 16, 2020
9108e86
working on docs
smattis May 16, 2020
c11c1da
Merge remote-tracking branch 'origin/v3-steve' into v3-steve
smattis May 16, 2020
9e34c32
re-add adcirc examples
smattis May 16, 2020
89fe719
update copyrights
smattis May 16, 2020
b653bc4
update docs
smattis May 16, 2020
3329138
Update README.md
smattis May 16, 2020
a4858da
update travis and version
smattis May 16, 2020
95f3504
fix bug
smattis May 16, 2020
ac9ae8b
Update README.md
smattis May 17, 2020
f2ce967
Update README.md
smattis May 17, 2020
17a74b1
Update README.md
smattis May 17, 2020
36b85ff
Update README.md
smattis May 17, 2020
7e00851
remove notebooks
smattis May 17, 2020
a237ce9
remove 2 ADCIRC examples
smattis May 17, 2020
c8e6d04
fix merge
smattis May 17, 2020
0b64fea
adds weighted samples
smattis May 19, 2020
1863d4d
deprecate function
smattis May 19, 2020
c2b6630
bug fix
smattis May 19, 2020
601932a
initial changes from meeting
smattis May 20, 2020
d4caf2d
fixes tests
smattis May 20, 2020
3605e52
fix bugs
smattis May 20, 2020
b077f95
rename dataConsistent to calculateR
smattis May 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ before_install:
- sudo apt-get install gfortran libblas-dev liblapack-dev mpich libmpich-dev

install:
- pip install matplotlib mpi4py nose codecov Sphinx sphinx_rtd_theme
- python setup.py install
- pip install .
- pip install codecov pytest-cov Sphinx sphinx_rtd_theme
- pip install git+https://github.com/CU-Denver-UQ/LUQ

script:
- nosetests --with-coverage --cover-package=bet --cover-erase --cover-html
- mpirun -n 2 nosetests
- pytest --cov=./bet/ ./test/
- mpirun -n 2 pytest ./test/
- pip uninstall -y mpi4py
- nosetests
- pytest ./test/
- sphinx-apidoc -f -o doc bet
- cd doc/
- make html
Expand All @@ -32,8 +33,6 @@ notifications:
email:
recipients:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
on_success: change
on_failure: always
Expand All @@ -42,6 +41,7 @@ notifications:
branches:
only:
- master
- v3-dev

# Push the results back to codecov
after_success:
Expand Down
87 changes: 56 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
BET
===
# BET
[![Build Status](https://travis-ci.org/UT-CHG/BET.svg?branch=master)](https://travis-ci.org/UT-CHG/BET) [![DOI](https://zenodo.org/badge/18813599.svg)](https://zenodo.org/badge/latestdoi/18813599) [![codecov](https://codecov.io/gh/UT-CHG/BET/branch/master/graph/badge.svg)](https://codecov.io/gh/UT-CHG/BET) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/UT-CHG/BET/master)

BET is a Python package for measure-theoretic and data-consistent stochastic forward and inverse problems. The package is very flexible and is applicable to a wide variety of problems.

BET is in active development. Hence, some features are still being added and you may find bugs we have overlooked. If you find something please report these problems to us through GitHub so that we can fix them. Thanks!
BET is an initialism of Butler, Estep and Tavener, the primary authors of a [series](https://epubs.siam.org/doi/abs/10.1137/100785946) [of](https://epubs.siam.org/doi/abs/10.1137/100785958) [papers](https://epubs.siam.org/doi/abs/10.1137/130930406) that introduced the mathematical framework for measure-theoretic stochastic inversion, for which BET included a computational implementation. However, since it's initial inception it has grown to include a broad range of [data-](https://iopscience.iop.org/article/10.1088/1361-6420/ab8f83/meta)[consistent](https://epubs.siam.org/doi/abs/10.1137/16M1087229) [methods](https://onlinelibrary.wiley.com/doi/abs/10.1002/nme.6078). It has been applied to a wide variety of application problems, many of which can be found [here](https://scholar.google.com/scholar?oi=bibs&hl=en&cites=915741139550333528,6038673497778212734,182199236207122617).

Please note that we are using continuous integration and issues for bug tracking.
## Installation
The current development branch of BET can be installed from GitHub, using ``pip``:

pip install git+https://github.com/UT-CHG/BET

Another option is to clone the repository and install BET using
``python setup.py install``


## Dependencies
BET is tested on Python 3.6 and 3.7 (but should work on most recent Python 3 versions) and depends on [NumPy](http://www.numpy.org/), [SciPy](http://www.scipy.org/), [matplotlib](http://matplotlib.org/), [pyDOE](https://pythonhosted.org/pyDOE/), [pytest](https://docs.pytest.org/), and [mpi4py](https://mpi4py.readthedocs.io/en/stable/) (optional) (see [requirements.txt](requirements.txt) for version information). For some optional features [LUQ](https://github.com/CU-Denver-UQ/LUQ) is also required.

## License
[GNU Lesser General Public License (LGPL)](LICENSE.txt)

## Citing BET
Please include the citation:

Lindley Graham, Steven Mattis, Scott Walsh, Troy Butler, Michael Pilosov, and Damon McDougall. “BET: Butler, Estep, Tavener Method V2.0.0”. Zenodo, August 10, 2016. [doi:10.5281/zenodo.59964](https://doi.org/10.5281/zenodo.59964)

## Butler, Estep, Tavener method
or in BibTEX:

This code has been documented with sphinx. the documentation is available online at http://ut-chg.github.io/BET. to build documentation run
@software{BET,
author = {Lindley Graham and
Steven Mattis and
Scott Walsh and
Troy Butler and
Michael Pilosov and
Damon McDougall},
title = {BET: Butler, Estep, Tavener Method v2.0.0},
month = aug,
year = 2016,
publisher = {Zenodo},
version = {v2.0.0},
doi = {10.5281/zenodo.59964},
url = {https://doi.org/10.5281/zenodo.59964}
}

## Documentation

This code has been documented with sphinx. the documentation is available online at http://ut-chg.github.io/BET. To build documentation run
``make html`` in the ``doc/`` folder.

To build/update the documentation use the following commands::
Expand All @@ -25,41 +61,30 @@ To change the build location of the documentation you will need to update ``doc/
You will need to run sphinx-apidoc and reinstall bet anytime a new module or method in the source code has been added.
If only the `*.rst` files have changed then you can simply run ``make html`` twice in the doc folder.

Useful scripts are contained in ``examples/``, as are the following sets of example Jupyter Notebooks:
## Examples
Examples scripts are contained in [here](examples/).

- [Plotting](./examples/plotting/Plotting_Examples.ipynb)
(this allows execution any of the following examples and plots the associated results)
- [Contaminant Transport](./examples/contaminantTransport/contaminant.ipynb)
- [Validation Example](./examples/validationExample/linearMap.ipynb)
- [Linear (QoI) Sensitivity](./examples/sensitivity/linear_sensitivity.ipynb)
- [Linear Map](./examples/linearMap/linearMapUniformSampling.ipynb)

Furthermore, the `examples/templates` directory contains a [notebook](./examples/templates/Example_Notebook_Template.ipynb) that serves as a template for the examples.
You can also try out BET in your browser using [Binder](https://mybinder.org/v2/gh/UT-CHG/BET/master).

Tests
-----
## Testing

To run tests in serial call::
To run the tests in the root directory with `pytest` in serial call::

nosetests
pytest ./test/

To run tests in parallel call::
Some features of BET have the ability to work in parallel. To run tests in parallel call::

mpirun -np nproc nosetests
mpirun -np NPROC pytest ./test/

Make you to have a working MPI environment (we recommend [mpich](http://www.mpich.org/downloads/)).
Make sure to have a working MPI environment (we recommend [mpich](http://www.mpich.org/downloads/)) if you want to use parallel features.


Dependencies
------------
(Note: you may need to set `~/.config/matplotlib/matplotlibrc` to include `backend:agg` if there is no `DISPLAY` port in your environment).

`bet` requires the following packages:
## Contributors
See the [GitHub contributors page](https://github.com/UT-CHG/BET/graphs/contributors).

1. [numpy](http://www.numpy.org/)
2. [scipy](http://www.scipy.org/)
3. [nose](https://nose.readthedocs.org/en/latest/)
4. [pyDOE](https://pythonhosted.org/pyDOE/)
5. [matplotlib](http://matplotlib.org/)
## Contact
BET is in active development. Hence, some features are still being added and you may find bugs we have overlooked. If you find something please report these problems to us through GitHub so that we can fix them. Thanks!

(Note: you may need to set `~/.config/matplotlib/matplotlibrc` to include `backend:agg` if there is no `DISPLAY` port in your environment).
Please note that we are using continuous integration and issues for bug tracking.
2 changes: 1 addition & 1 deletion bet/Comm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2014-2019 The BET Development Team
# Copyright (C) 2014-2020 The BET Development Team

"""
This module provides a workaround for people without mpi4py installed
Expand Down
30 changes: 9 additions & 21 deletions bet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2014-2019 The BET Development Team
# Copyright (C) 2014-2020 The BET Development Team

"""
Butler, Estep, Tavener Method
Expand All @@ -7,26 +7,14 @@
measure-theoretic. It is named for the developers of the key algorithm in
:mod:`bet.calculateP.calculateP`.

Comm :mod:`~bet.Comm` provides a work around for users who do not which to
install :program:``mpi4py``.

util :mod:`~bet.util` provides some general use methods for creating grids,
checking/fixing dimensions, and globalizing arrays.

calculateP :mod:`~bet.calculateP` provides tools to approximate probabilities.

sampling :mod:`~bet.sampling` provides various sampling algorithms.

sensitivity :mod:`~bet.sensitivity` provides tools for approximating
derivatives and optimally choosing quantities of interest.

postProcess :mod:`~bet.postProcess` provides plotting tools and tools to sort
samples by probabilities.

sample :mod:`~bet.sample` provides data structures to store sets of samples and
their associated arrays.

surrogates :mod:`~bet.surrogates` provides methods for generating and using
* :mod:`~bet.Comm` provides a work around for users who do not which to install :program:``mpi4py``.
* :mod:`~bet.util` provides some general use methods for creating grids, checking/fixing dimensions, and globalizing arrays.
* :mod:`~bet.calculateP` provides tools to approximate probabilities.
* :mod:`~bet.sampling` provides various sampling algorithms.
* :mod:`~bet.sensitivity` provides tools for approximating derivatives and optimally choosing quantities of interest.
* :mod:`~bet.postProcess` provides plotting tools and tools to sort samples by probabilities.
* :mod:`~bet.sample` provides data structures to store sets of samples and their associated arrays.
* :mod:`~bet.surrogates` provides methods for generating and using
surrogate models.

"""
Expand Down
17 changes: 7 additions & 10 deletions bet/calculateP/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Copyright (C) 2014-2019 The BET Development Team
# Copyright (C) 2014-2020 The BET Development Team

r"""
This subpackage provides classes and methods for calulating the
This subpackage provides classes and methods for calculating the
probability measure :math:`P_{\Lambda}`.

* :mod:`~bet.calculateP.calculateP` provides methods for approximating
probability densities
* :mod:`~bet.calculateP.simpleFunP` provides methods for creating simple
function approximations of probability densisties
* :mod:`~bet.calculateP.indicatorFunctions` provides methods for creating
indicator functions for use by various other classes.
* :mod:`~bet.calculateP.calculateP` provides methods for approximating probability densities in the measure-theoretic framework.
* :mod:`~bet.calculateP.simpleFunP` provides methods for creating simple function approximations of probability densities for the measure-theoretic framework.
* :mod:`~bet.calculateP.calculateR` provides methods for data-consistent stochastic inversion.
* :mod:`~bet.calculateP.calculateError` provides methods for approximating numerical and sampling errors.
"""
__all__ = ['calculateP', 'simpleFunP', 'indicatorFunctions',
'calculateError']
__all__ = ['calculateP', 'simpleFunP', 'calculateError', 'calculateR']
18 changes: 7 additions & 11 deletions bet/calculateP/calculateError.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Copyright (C) 2014-2019 The BET Development Team
# Copyright (C) 2014-2020 The BET Development Team

r"""
This module provides methods for calulating error estimates of
This module provides methods for calculating error estimates of
the probability measure for calculate probability measures. See
`Butler et al. 2015. <http://arxiv.org/pdf/1407.3851>`.

* :meth:`~bet.calculateErrors.cell_connectivity_exact` calculates
the connectivity of cells.
* :meth:`~bet.calculateErrors.boundary_sets` calculates which cells are
on the boundary and strictly interior for contour events.
* :class:`~bet.calculateErrors.sampling_error` is for calculating error
estimates due to sampling
* :class:`~bet.calculateErrors.model_error` is for calculating error
estimates due to error in solution of QoIs
* :mod:`~bet.calculateErrors.cell_connectivity_exact` calculates the connectivity of cells.
* :mod:`~bet.calculateErrors.boundary_sets` calculates which cells are on the boundary and strictly interior for contour events.
* :class:`~bet.calculateErrors.sampling_error` is for calculating error estimates due to sampling.
* :class:`~bet.calculateErrors.model_error` is for calculating error estimates due to error in solution of QoIs

"""

Expand Down Expand Up @@ -51,7 +47,7 @@ def cell_connectivity_exact(disc):
msg = "The argument must be of type bet.sample.discretization."
raise wrong_argument_type(msg)

if not isinstance(disc._input_sample_set, samp.voronoi_sample_set):
if not isinstance(disc.get_input_sample_set(), samp.voronoi_sample_set):
msg = "disc._input_sample_set must be of type bet.sample.voronoi"
msg += "_sample_set defined with the 2-norm"
raise wrong_argument_type(msg)
Expand Down
26 changes: 14 additions & 12 deletions bet/calculateP/calculateP.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# Copyright (C) 2014-2019 The BET Development Team
# Copyright (C) 2014-2020 The BET Development Team

r"""
This module provides methods for calulating the probability measure
This module provides methods for calculating the probability measure
:math:`P_{\Lambda}`.

* :mod:`~bet.calculateP.prob_on_emulated_samples` provides a skeleton class and
calculates the probability for a set of emulation points.
* :mod:`~bet.calculateP.calculateP.prob` estimates the
probability based on pre-defined volumes.
* :mod:`~bet.calculateP.calculateP.prob_with_emulated` estimates the
probability using volume emulation.
* :mod:`~bet.calculateP.calculateP.prob_from_sample_set` estimates the
probability based on probabilities from another sample set on the same
space.
* :mod:`~bet.calculateP.prob_on_emulated_samples` provides a skeleton class and calculates the probability for a set of emulation points.
* :mod:`~bet.calculateP.calculateP.prob` estimates the probability based on pre-defined volumes.
* :mod:`~bet.calculateP.calculateP.prob_with_emulated` estimates the probability using volume emulation.
* :mod:`~bet.calculateP.calculateP.prob_from_sample_set` estimates the probability based on probabilities from another
sample set on the same space.

"""
import logging
import numpy as np
from bet.Comm import comm, MPI
import bet.util as util
import bet.sample as samp
import bet.util as util


def prob_on_emulated_samples(discretization, globalize=True):
Expand Down Expand Up @@ -62,6 +58,7 @@ def prob_on_emulated_samples(discretization, globalize=True):
_probabilities[i] / Itemp_sum

discretization._emulated_input_sample_set._probabilities_local = P
discretization._emulated_input_sample_set.set_prob_type('voronoi')
if globalize:
discretization._emulated_input_sample_set.local_to_global()
pass
Expand Down Expand Up @@ -106,6 +103,8 @@ def prob(discretization, globalize=True):
discretization._input_sample_set._probabilities = util.\
get_global_values(P_local)
discretization._input_sample_set._probabilities_local = P_local
discretization._input_sample_set.set_prob_type('voronoi')



def prob_with_emulated_volumes(discretization):
Expand Down Expand Up @@ -203,6 +202,7 @@ def prob_from_sample_set_with_emulated_volumes(set_old, set_new,

# Set probabilities
set_new.set_probabilities(prob_new)
set_new.set_prob_type('voronoi')
return prob_new


Expand Down Expand Up @@ -245,6 +245,7 @@ def prob_from_sample_set(set_old, set_new):

# Set probabilities
set_new.set_probabilities(prob_new)
set_new.set_prob_type('voronoi')
return prob_new


Expand Down Expand Up @@ -295,4 +296,5 @@ def prob_from_discretization_input(disc, set_new):

# Set probabilities
set_new.set_probabilities(prob_new)
set_new.set_prob_type('voronoi')
return prob_new
Loading