A class that performs linear interpolation
Project description
Introduction
tabulation
is a Python module that provides the Tabulation
class. The Tabulation
class represents a mathematical function by a sequence of linear interpolations between
points defined by arrays of x and y coordinates.
tabulation
is a product of the PDS Ring-Moon Systems Node.
Installation
The tabulation
module is available via the rms-tabulation
package on PyPI and can be
installed with:
pip install rms-tabulation
Getting Started
The Tabulation
class models a mathematical function by a series of (x,y) points and
performs linear interpolation between them. Although optimized to model filter bandpasses
and spectral flux, the class is sufficiently general to be used in a wide range of
applications.
The mathematical function is treated as equal to zero outside the domain of the x coordinates, with a step at the provided leading and trailing x coordinates. In general, zero values (either supplied or computed) at either the leading or trailing ends are removed. However, if explicitly supplied, one leading and/or trailing zero value is considered significant because it anchors the interpolation of a ramp at the beginning or end of the domain.
A variety of mathematical operations can be performed on Tabulation
objects, including
addition, subtraction, multiplication, division, integration, and finding the X mean,
FWHM, and square width. See the module
documentation for details.
Here are some examples to get you started:
>>> t2 = Tabulation([0, 2, 4], [0, 5, 5]) # Ramp on leading edge
>>> t2.domain()
(0., 4.)
>>> t2([0, 1, 1.9, 2, 3, 3.9, 4, 5, 6])
>>> from tabulation import Tabulation
>>> t1 = Tabulation([2, 4], [10, 10]) # Leading&trailing step function
>>> t1.domain()
(2., 4.)
>>> r1 = t1([0, 1, 1.9, 2, 3, 3.9, 4, 5, 6])
array([ 0., 0., 0., 10., 10., 10., 10., 0., 0.])
>>> t1.x_mean()
3.0
>>> t1.integral()
20.0
>>> t2 = Tabulation([0, 2, 4], [0, 5, 5]) # Ramp on leading edge
>>> t2.domain()
(0., 4.)
>>> r2 = t2([0, 1, 1.9, 2, 3, 3.9, 4, 5, 6])
array([ 0., 2.5, 4.75, 5., 5., 5. , 5., 0., 0.])
>>> t2.x_mean()
2.6666666666666665
>>> t2.integral()
15.0
>>> t3 = t2-t1
>>> t3.domain()
(0.0, 4.0)
>>> r2-r1
array([ 0. , 2.5 , 4.75, -5. , -5. , -5. , -5. , 0. , 0. ])
>>> t3([0, 1, 1.9, 2, 3, 3.9, 4, 5, 6])
array([ 0. , 2.5 , 4.75, -5. , -5. , -5. , -5. , 0. , 0. ])
>>> t3.integral()
-5.000000000000001
Contributing
Information on contributing to this package can be found in the Contributing Guide.
Links
Licensing
This code is licensed under the Apache License v2.0.
Project details
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 rms_tabulation-1.1.0.tar.gz
.
File metadata
- Download URL: rms_tabulation-1.1.0.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac6314c7ebc9cd5855dcfc5cc076af4300774d978c567bc47f8a7d66b134ef16 |
|
MD5 | 079d2f0ade0d6f2fc9594631f44050f6 |
|
BLAKE2b-256 | e1413d211091ce6aed1655bc06248b18b7797863aa40568fffd52a03c106662d |
File details
Details for the file rms_tabulation-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: rms_tabulation-1.1.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94a00d5eff9b2b6b9c34cc3d345a362ec5b14e602ab4d71fd2e7e14501fab74c |
|
MD5 | ddecad674258d6a6bfec018521da11fc |
|
BLAKE2b-256 | 8a813285c19579230dd2662a6a2679afbdb9182c303651f672690aa91f97a9a8 |