No project description provided
Project description
datadrivenquadrature
Data Driven Quadrature is a Python package for quadrature-based integration point selection. In many applications, integrals over high-resolution integration axes are calculated repeatedly and can be extremely computationally expensive. This operation can be simplified by selecting integration points and corresponding weights that approximate the integral (Gaussian quadrature). The simulated annealing technique is modeled off the procedure described in Buehler et al., 2010 and applied again in Czarnecki et al., 2023
This package implements a linear-programing approach to this optimization problem with a simple user-interface.
Contents
Usage
Four functions are available for direct user usage: find_normalization_vector()
, check_params()
, optimize()
, flatten_history()
. Functions, signatures, and descriptions are below. A full (and hopefully helpful) tutorial is included here and a full example can be found here. Note, due to the high volume of data, the example data is not included in this package.
Parameters and Functions
All functions are docstring compatible and information can be printed using the help()
function:
import datadrivenquadrature as ddq
help(ddq.optimize)
Optimization Function Parameters:
x
: Anxarray
dataset including all necessary data and integration axesy_ref
: Precalculated reference integrals as a flat vectorC()
: Cost function using only CVXPY functions to return a CVXPYM()
: Mapping function that returns a matrix of shape (number of integration points, number of integrals) from mapped valuesparams
: A dictionary of parameters used in optimization:integration_list
: List of integration axes. Currently, only one integration axis is supported at a time (REQUIRED)n_points
: Number of integration points to use (REQUIRED)epochs
: Number of epochs to use in optimization (default=100)block_size
: Number of iterations within an epoch (default=50)success
: Number of successes required to move on from a block early (default=25)random_seed
: Random seed for optimizationverbose
: Verbosity level during optimization (default=1)verbose=0
: Do not print anything during optimizationverbose=1
: Only print final summary after optimizationverbose=2
: Print final and epoch summariesverbose=3
: Print all final, epoch, and block summaries
x_sup
: If any additional data needs to be supplied to the mapping function for any reason, it can be passed in through this OPTIONAL parameter
find_normalization_vector()
Returns a normalization vector for all given integration axes
:param x: xarray dataframe containing integration axes
:param integration_axes: list of integration axes in x
:returns: list of normalization tuples (scale, offset) to normalize integration axes to [0, 1]
check_params()
Returns a normalization vector for all given integration axes
:param x: xarray dataframe containing integration axes
:param integration_axes: list of integration axes in x
:returns: list of normalization tuples (scale, offset) to normalize integration axes to [0, 1]
optimize()
User-called function to check validity of inputs and determine optimal point set
:param x: xarray dataset containing integration axes
:param y_ref: numpy multi-dimensional array containing reference/target values
:param C: cost function
:param M: mapping function
:param params: dictionary of user-defined parameters for optimization loop and integration axes
:param x_sup: optional parameter passed to map function
:returns: history object containing 'point_sets', 'weight_sets', 'cost', and 'temperature_history' and 'best' index of optimization
flatten_history()
Flattens history object returned by the optimization loop
:param history: history dictionary returned from an optimization loop
:returns: history dictionary with all multi-dimensional lists fully flattened
Installation
via PyPi
This package is on the PyPi
directory so you can install it using:
pip install datadrivenquadrature
via GitHub
If you would like to change any of the code in the package, you can directly download the package from the repository and find all relevant functions in /datadrivenquarature/main.py
Authors
- Neal Ma (nmadev)
- Paulina Czarnecki (pczarnecki)
- Robert Pincus (RobertPincus)
License
This project is licensed under the MIT License - see the LICENSE file for details.
References
[1] S.A. Buehler, V.O. John, A. Kottayil, M. Milz, P. Eriksson, Efficient radiative transfer simulations for a broadband infrared radiometer—Combining a weighted mean of representative frequencies approach with frequency selection by simulated annealing, Journal of Quantitative Spectroscopy and Radiative Transfer, Volume 111, Issue 4, 2010, Pages 602-615, ISSN 0022-4073, https://doi.org/10.1016/j.jqsrt.2009.10.018.
[2] Czarnecki, P., Polvani, L., & Pincus, R. (2023). Sparse, empirically optimized quadrature for broadband spectral integration. Journal of Advances in Modeling Earth Systems, 15, e2023MS003819. https://doi.org/10.1029/2023MS003819
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file datadrivenquadrature-1.0.1.tar.gz
.
File metadata
- Download URL: datadrivenquadrature-1.0.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af4a0b22be8a3876415c5ecbd967acbf726f49d5d2e72bc5ba43fe679d44735d |
|
MD5 | ebb67fd8064f02e47d3078bbe735983c |
|
BLAKE2b-256 | e98799cbd66ebe137b01632c5c778005f0c97af842ff086f3a0f21ca7dbae8f1 |
File details
Details for the file datadrivenquadrature-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: datadrivenquadrature-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f239f71414ec016546f12cc049ef0f513ab9ebf3d4d2a6ab1b27c18d96c79c58 |
|
MD5 | a849044e72747584243bf08371d0cbae |
|
BLAKE2b-256 | 818c6b09da8b9e8089afdeed5956ceb84b45fe8b8893906144cf6f70b0da9523 |