FluxConserving is a set of Fortran 2003+ legacy routines with Python. There are some options for the flux-conserving algorithm. It also includes interpolation scripts.
Project description
pyfluxconserving
Fully based on a Fortran legacy package to easily compute the flux-density conservation
Obs.: A Fortran legacy Interpolation routines also furnished
email: antineutrinomuon@gmail.com, jean@astro.up.pt
github repository: pyfluxconserving
last stable version: 0.0.12
© Copyright ®
J.G. - Jean Gomes @ 2023
RESUME
Original Fortran 2003+ routines date back to 2003-2004. Read the LICENSE.txt file. When analyzing astronomical spectra, astronomers often bin the data to increase the signal-to-noise ratio and reduce the effects of noise in the data. Binning refers to the process of averaging the intensity of adjacent spectral channels, or pixels, to produce a new, coarser set of data.
In the process of binning, it is important to ensure that the principle of flux density conservation is maintained. This means that the total energy emitted by the object, and hence its flux density, must remain constant after binning.
To conserve flux density, the intensity of each binned pixel should be scaled by the number of pixels it represents. For example, if two adjacent pixels are binned together, the intensity of the resulting bin should be the sum of the intensities of the two original pixels, divided by two. This ensures that the total energy in the bin is conserved, and that the flux density of the object remains the same.
It's worth noting that binning can introduce errors in the spectral data, especially if the signal-to-noise ratio is low or if the binning is too coarse. In general, astronomers choose a binning size that balances the need for a high signal-to-noise ratio with the desire to maintain the spectral resolution and avoid introducing significant errors in the data.
In summary, the principle of flux density conservation is important to consider when binning astronomical spectra, and astronomers need to scale the intensity of each binned pixel to ensure that the total energy emitted by the object is conserved. SpectRes from A. Carnall is NOT part of the distribution, but used as a comparison: https://github.com/ACCarnall/SpectRes. If you want to install for comparison then:
pip install spectres
However, it is not necessary for the usage of this package. Accompanying there are several routines for interpolations.
INSTALLATION
You can easily install pyfluxconserving by using pip - PyPI - The Python Package Index:
pip install pyfluxconserving
or by using a generated conda repository https://anaconda.org/neutrinomuon/pyfluxconserving:
conda install -c neutrinomuon pyfluxconserving
OBS.: Linux, OS-X and Windows pre-compilations available in conda.
You can also clone the repository and install by yourself in your machine:
git clone https://github.com/neutrinomuon/pyfluxconserving python setup.py install
METHOD & REFERENCES
Here, the method used is with the Cumulative function to produce a new flux-conserved, some options can be chosen for the interpolation:
Integer Number | Option: Interpolation Schemes | Brief Description |
0) | AkimaSpline | Akima Spline interpolation. The Akima spline is a C1 differentiable function (that is, has a continuous first
derivative) but, in general, will have a discontinuous second derivative at the knot points.
De Boor, C. (1978). A Practical Guide to Splines. Springer-Verlag. ISBN: 978-0-387-95366-3. Link: https://www.springer.com/gp/book/9780387953663 Forsythe, G.E. (1979) Computer Methods for Mathematical Computations. Prentice-Hall, Inc. DOI: 10.1002/zamm.19790590235. Link: https://onlinelibrary.wiley.com/doi/10.1002/zamm.19790590235 Bartels, R.H., Beatty, J.C., and Barsky, B.A. (1987). An Introduction to Splines for Use in Computer Graphics and Geometric Modeling. Morgan Kaufmann Publishers. Link: https://www.osti.gov/biblio/5545263 Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press. ISBN: 978-0521880688. Link: http://numerical.recipes/ Cheney, W. and Kincaid, D. (2008). Numerical Mathematics and Computing (6th ed.). Brooks/Cole. ISBN: 978-0495114758. Link: https://www.amazon.com/Numerical-Mathematics-Computing-Ward-Cheney/dp/0495114758 Burden, R. L., & Faires, J. D. (2010). Numerical Analysis (9th ed.). Brooks/Cole. ISBN: 978-0538733519. Link: https://www.amazon.com/Numerical-Analysis-Richard-L-Burden/dp/0538733519 |
1) | Interpolado | Based on a linear interpolation within
a table of pair values.
Atkinson, K. E. (1991). An introduction to numerical analysis (2nd ed.). John Wiley & Sons. ISBN: 978-0-471-62489-9. Link: https://www.wiley.com/en-us/An+Introduction+to+Numerical+Analysis%2C+2nd+Edition-p-9780471624899 Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press. ISBN: 978-0521880688. Link: http://numerical.recipes/ Chapra, S. C., & Canale, R. P. (2010). Numerical methods for engineers (6th ed.). McGraw-Hill. ISBN: 978-0073401065. Link: https://www.amazon.com/Numerical-Methods-Engineers-Steven-Chapra/dp/0073401064 Burden, R. L., Faires, J. D. & A.M. Burden (2015). Numerical analysis (10th ed.) (9th ed.). Cengage Learning. ISBN: 978-1305253667. Link: https://www.amazon.com/Numerical-Analysis-Richard-L-Burden/dp/1305253663 |
2) | LINdexerpol | Based on a linear interpolation within a table of pair values using indexing. The references are the same as in 1). |
3) | LINinterpol | Based on a linear interpolation within a table of pair values. The references are the same as in 1). |
4) | SPLINE1DArr | This is a Fortran 2003 subroutine
called SPLINE1DArr that takes an array of values x to interpolate from the
arrays t and y. It has ten input arguments, six output arguments, and two
optional arguments. The interpolation is linear.
De Boor, C. (1978). A Practical Guide to Splines. Springer-Verlag. ISBN: 978-0-387-95366-3. Link: https://www.springer.com/gp/book/9780387953663 Bartels, R.H., Beatty, J.C., and Barsky, B.A. (1998). An Introductionto Splines for Use in Computer Graphics and Geometric Modeling. Morgan Kaufmann Publishers. ISBN: 978-1558604000. Link: https://www.amazon.com/Introduction-Computer-Graphics-Geometric-Modeling/dp/1558604006 Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical Recipes: The Art of Scientific Computing (3rd ed.). Cambridge University Press. ISBN: 978-0521880688. Link: http://numerical.recipes/ Cheney, W. and Kincaid, D. (2007). Numerical Mathematics and Computing (6th ed.). Brooks/Cole. ISBN: 978-0495114758. Link: https://www.amazon.com/Numerical-Mathematics-Computing-Ward-Cheney/dp/0495114758 |
5) | SPLINE3DFor | This function evaluates the cubic spline interpolation. The same references as in 4). |
STRUCTURE
The main structure of the directories and files are:
pyfluxconserving ├── dist │ ├── pyfluxconserving-0.0.4.tar.gz │ ├── pyfluxconserving-0.0.7.tar.gz │ ├── pyfluxconserving-0.0.3.tar.gz │ ├── pyfluxconserving-0.0.6.tar.gz │ ├── pyfluxconserving-0.0.8.tar.gz │ ├── pyfluxconserving-0.0.9.tar.gz │ ├── pyfluxconserving-0.0.1.tar.gz │ ├── pyfluxconserving-0.0.2.tar.gz │ ├── pyfluxconserving-0.0.10.tar.gz │ ├── pyfluxconserving-0.0.11.tar.gz │ └── pyfluxconserving-0.0.5.tar.gz ├── README.md ├── .#README.md ├── showdown.min.js ├── scripts │ └── update_readme.py ├── index.html ├── LICENSE.txt ├── setup.py ├── pyfluxconserving │ ├── calculate_sha256.py │ ├── meta.yaml │ └── README.txt ├── tutorials │ ├── pyfluxconserving.png │ ├── .ipynb_checkpoints │ │ └── pyfluxconserving Example-checkpoint.ipynb │ └── pyfluxconserving Example.ipynb ├── pyfluxconserving.egg-info │ ├── PKG-INFO │ ├── dependency_links.txt │ ├── SOURCES.txt │ ├── top_level.txt │ └── requires.txt ├── src │ ├── python │ │ ├── PyFluxConSpec.py │ │ ├── califa_cmap_alternative.py │ │ ├── PyLinear__int.py │ │ ├── PyLINinterpol.py │ │ ├── fluxconserve.py │ │ ├── __init__.py │ │ ├── PySPLINE1DArr.py │ │ ├── PySPLINE3DFor.py │ │ ├── fluxconserving.png │ │ ├── PyAkimaSpline.py │ │ ├── PyInterpolado.py │ │ └── PyLINdexerpol.py │ └── fortran │ ├── SPLINE3DFor.cpython-39-darwin.so │ ├── LINdexerpol.cpython-311-darwin.so │ ├── SPLINE3DFor.cpython-310-darwin.so │ ├── LINdexerpol.f90 │ ├── LINinterpol.cpython-39-darwin.so │ ├── SPLINE3DFor.cpython-39-x86_64-linux-gnu.so │ ├── SPLINE1DFlt.cpython-39-x86_64-linux-gnu.so │ ├── SPLINE3DFor.compile │ ├── FluxConSpec.compile │ ├── FluxConSpec.cpython-39-darwin.so │ ├── SPLINE1DArr.compile │ ├── SPLINE1DFlt.cpython-39-darwin.so │ ├── AkimaSpline.cpython-310-darwin.so │ ├── Interpolado.cpython-39-x86_64-linux-gnu.so │ ├── Interpolado.cpython-38-x86_64-linux-gnu.so │ ├── SPLINE1DFlt.f90 │ ├── FluxConSpec.cpython-39-x86_64-linux-gnu.so │ ├── SPLINE1DFlt.cpython-310-darwin.so │ ├── FluxConSpec.cpython-311-darwin.so │ ├── AkimaSpline.f90 │ ├── SPLINE1DArr.f90 │ ├── SPLINE1DFlt.cpython-311-darwin.so │ ├── FluxConSpec.cpython-38-x86_64-linux-gnu.so │ ├── AkimaSpline.cpython-39-darwin.so │ ├── SPLINE1DFlt.cpython-38-x86_64-linux-gnu.so │ ├── SPLINE3DFor.cpython-38-x86_64-linux-gnu.so │ ├── AkimaSpline.compile │ ├── DataTypes.f90 │ ├── SPLINE1DArr.cpython-39-darwin.so │ ├── LINdexerpol.cpython-310-darwin.so │ ├── LINdexerpol.compile │ ├── SPLINE3DFor.f90 │ ├── SPLINE1DFlt.compile │ ├── Interpolado.f90 │ ├── LINinterpol.cpython-311-darwin.so │ ├── SPLINE1DArr.cpython-310-darwin.so │ ├── FluxConSpec.cpython-310-x86_64-linux-gnu.so │ ├── LINinterpol.cpython-310-darwin.so │ ├── SPLINE1DFlt.cpython-310-x86_64-linux-gnu.so │ ├── LINinterpol.compile │ ├── SPLINE1DArr.cpython-311-darwin.so │ ├── SPLINE3DFor.cpython-311-darwin.so │ ├── LINinterpol.compile~ │ ├── FluxConSpec.cpython-310-darwin.so │ ├── FluxConSpec.f90 │ ├── Interpolado.cpython-310-x86_64-linux-gnu.so │ ├── LINdexerpol.cpython-310-x86_64-linux-gnu.so │ ├── README.txt │ ├── Interpolado.compile │ ├── SPLINE3DFor.cpython-310-x86_64-linux-gnu.so │ ├── LINdexerpol.cpython-39-darwin.so │ ├── LINinterpol.f90 │ ├── LINdexerpol.cpython-39-x86_64-linux-gnu.so │ ├── LINdexerpol.cpython-38-x86_64-linux-gnu.so │ └── AkimaSpline.cpython-311-darwin.so ├── version.txt └── build ├── lib.linux-x86_64-3.9 │ └── pyfluxconserving ├── lib.macosx-11.1-arm64-cpython-39 │ └── pyfluxconserving ├── temp.macosx-11.1-arm64-cpython-39 │ ├── __pycache__ │ ├── pyfluxconserving │ ├── ccompiler_opt_cache_ext.py │ ├── src │ └── build ├── src.linux-x86_64-3.9 │ ├── pyfluxconserving │ ├── build │ └── numpy ├── temp.linux-x86_64-3.9 │ ├── __pycache__ │ ├── pyfluxconserving │ ├── ccompiler_opt_cache_ext.py │ ├── src │ └── build └── src.macosx-11.1-arm64-3.9 ├── pyfluxconserving ├── build └── numpy 32 directories, 99 files
PyFluxConSPec.py is a python wrapper to the library in fortran called
pyfluxconserving.flib. The fortran directory can be compiled separately for
each individual subroutine.
ISSUES AND CONTRIBUTIONS
If you encounter any issues with this project, please feel free to submit an issue on the GitHub repository. We appreciate your feedback and are committed to improving the quality of our codebase.
If you'd like to contribute to this project, we welcome pull requests from the community. Before submitting a pull request, please make sure to fork the repository and create a new branch for your changes. Once your changes are complete, submit a pull request and we'll review your code as soon as possible.
For any questions or concerns about contributing, please contact the project maintainer at antineutrinomuon@gmail.com. Thank you for your interest in contributing to our project!
LICENSE
This software is provided "AS IS" (see DISCLAIMER below). Permission to use, for non-commercial purposes is granted. Permission to modify for personal or internal use is granted, provided this copyright and disclaimer are included in ALL copies of the software. All other rights are reserved. In particular, redistribution of the code is not allowed without explicit permission by the author.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
File details
Details for the file pyfluxconserving-0.0.12.tar.gz
.
File metadata
- Download URL: pyfluxconserving-0.0.12.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 pkginfo/1.8.2 readme-renderer/27.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.4.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b07df92351052c624339b1ce012c3d712f8fd5b2deca591b19664467985568f |
|
MD5 | 09d2d76f75cdd3dfa08a385ea387b76b |
|
BLAKE2b-256 | b7d4eee010faa485e87f74f75fc657564b5257ac96795eb9fe28d6225a992c67 |