Skip to main content

A class that performs linear interpolation

Project description

GitHub release; latest by date GitHub Release Date Test Status Documentation Status Code coverage
PyPI - Version PyPI - Format PyPI - Downloads PyPI - Python Version
GitHub commits since latest release GitHub commit activity GitHub last commit
Number of GitHub open issues Number of GitHub closed issues Number of GitHub open pull requests Number of GitHub closed pull requests
GitHub License Number of GitHub stars GitHub forks

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

rms_tabulation-1.0.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

rms_tabulation-1.0.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file rms_tabulation-1.0.0.tar.gz.

File metadata

  • Download URL: rms_tabulation-1.0.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for rms_tabulation-1.0.0.tar.gz
Algorithm Hash digest
SHA256 daaaa22d8db11eb5b81185d4083ead4778cfbc5c52c38a6415a850dd5f5c98d5
MD5 0035517af2fa3bdbbdd51febece5aab5
BLAKE2b-256 ffe95de5758733efea8ec9c1b6aa16515d712e27471c6c37832b63ea82247a35

See more details on using hashes here.

File details

Details for the file rms_tabulation-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rms_tabulation-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1172dbe2102c2739e10c437ec6fe50f8e89ad40577798b8cb99976c03f2724b0
MD5 ca99e19494c70f911d95ca9a3fca46a2
BLAKE2b-256 bef87c272bc08b449396fbdc4d653abb6cbffaf4bdba8a246535305452977b49

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page