Flux-conserving legacy routines in Fortran and Python
Project description
FluxConserving
A fortran legacy package to easy compute the flux-density conservation
ObS.: A fortran legacy Interpolation routines also furnished
email: antineutrinomuon@gmail.com, jean@astro.up.pt
© Copyright ®
J.G. - Jean Gomes
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.
Accompanying there are several routines for interpolations.
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/FluxConserving
python setup.py install
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.
|
1) | Interpolado | Based on a linear interpolation within
a table of pair values.
|
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). |
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.
|
5) | SPLINE3DFor | This function evaluates the cubic spline interpolation. The same references as in 4) |
The main structure of the directories and files are:
FluxConserving
├── dist
│ └── pyfluxconserving-0.0.1.tar.gz
├── README.md
├── LICENSE.txt
├── setup.py
├── tutorials
│ ├── fluxconserving.png
│ └── Flux-Conserving 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
│ │ ├── PySPLINECubic.py
│ │ ├── fluxconserve.py
│ │ ├── __init__.py
│ │ ├── PySPLINE1DArr.py
│ │ ├── PySPLINE3DFor.py
│ │ ├── fluxconserving.png
│ │ ├── PyAkimaSpline.py
│ │ ├── PySPLINE3DAlt.py
│ │ ├── PyInterpolado.py
│ │ └── PyLINdexerpol.py
│ └── fortran
│ ├── LINdexerpol.f90
│ ├── SPLINE3DFor.cpython-39-x86_64-linux-gnu.so
│ ├── SPLINE1DFlt.cpython-39-x86_64-linux-gnu.so
│ ├── SPLINE3DFor.compile
│ ├── FluxConSpec.compile
│ ├── SPLINE1DArr.compile
│ ├── Interpolado.cpython-39-x86_64-linux-gnu.so
│ ├── Interpolado.cpython-38-x86_64-linux-gnu.so
│ ├── SPLINE1DFlt.f90
│ ├── AkimaSpline.f90
│ ├── SPLINE1DArr.f90
│ ├── SPLINE1DFlt.cpython-38-x86_64-linux-gnu.so
│ ├── SPLINE3DFor.cpython-38-x86_64-linux-gnu.so
│ ├── AkimaSpline.compile
│ ├── DataTypes.f90
│ ├── LINdexerpol.compile
│ ├── SPLINE3DFor.f90
│ ├── SPLINE1DFlt.compile
│ ├── Interpolado.f90
│ ├── SPLINE1DFlt.cpython-310-x86_64-linux-gnu.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
│ ├── LINinterpol.f90
│ ├── LINdexerpol.cpython-39-x86_64-linux-gnu.so
│ └── LINdexerpol.cpython-38-x86_64-linux-gnu.so
├── version.txt
└── build
├── lib.linux-x86_64-3.9
│ └── pyfluxconserving
├── src.linux-x86_64-3.9
│ ├── pyfluxconserving
│ ├── build
│ └── numpy
└── temp.linux-x86_64-3.9
├── pyfluxconserving
├── ccompiler_opt_cache_ext.py
├── src
├── .libs
└── build
18 directories, 56 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.
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.3.tar.gz
.
File metadata
- Download URL: pyfluxconserving-0.0.3.tar.gz
- Upload date:
- Size: 42.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e3d12a7e10c71ff55c64857874d5c122515e001e99905b8fdb4fb000984aac5 |
|
MD5 | 37c99804182bf9df832f5127d889418d |
|
BLAKE2b-256 | 683364e8871228c88cfb3f6faf66c34ec174494ade13f5ab17cbf1d83432656d |