Skip to main content

PyFluxconserving

Fully based on a Fortran legacy package to easily compute the flux-density conservation

Obs.: A Fortran legacy Interpolation routines also furnished in this package
email: antineutrinomuon@gmail.com

linkedin: https://www.linkedin.com/in/jean-michel-gomes/

github repository: PyFluxconserving

last stable version: 0.0.16

© Copyright ®

J.G. - Jean Gomes @ 2025





RESUME

Original Fortran 2003+ legacy routines date back to 2003–2004. Please refer to the LICENSE.txt file. These routines have been converted into Python libraries.

When analysing astronomical spectra, astronomers often bin the data to increase the signal-to-noise ratio and mitigate the effects of noise. Binning refers to the process of averaging the intensity of adjacent spectral channels, or pixels, to produce a new, coarser dataset.

During binning, it is crucial to maintain the principle of flux density conservation. This means that the total energy emitted by the object, and consequently its flux density, must remain constant after binning.

To conserve flux density, the intensity of each binned pixel should be scaled according to the number of pixels it represents. For instance, if two adjacent pixels are binned together, the intensity of the resulting bin should equal 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 object's flux density remains unchanged.

It is important to note that binning can introduce errors in spectral data, especially if the signal-to-noise ratio is low or if the binning is too coarse. Nevertheless, this procedure is often necessary, as the observed spectrum of an astronomical source is generally non-linear. Astronomers usually choose a binning size that balances the need for a high signal-to-noise ratio with the requirement to maintain spectral resolution and minimise significant errors in the data.

In summary, flux density conservation is a key consideration when binning astronomical spectra. Astronomers must scale the intensity of each binned pixel to ensure that the total energy emitted by the object is preserved.

Note: SpectRes by A. Carnall is not included in this distribution but is provided for comparison: https://github.com/ACCarnall/SpectRes . To install it for comparison, please refer to the repository. 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
pip install --user ninja (optional)
pip install --user meson (optional)
rm -rf build *.egg-info PyFluxconserving
python setup.py build_ext --inplace
pip install -e .

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 NumberOption: Interpolation SchemesBrief Description
0)AkimaSplineAkima 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)InterpoladoBased on a linear interpolation within a table of pair values.

2)LINdexerpolBased on a linear interpolation within a table of pair values using indexing. The references are the same as in 1).
3)LINinterpolBased on a linear interpolation within a table of pair values. The references are the same as in 1).
4)SPLINE1DArrThis 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)SPLINE3DForThis function evaluates the cubic spline interpolation. The same references as in 4).

STRUCTURE

#################################################
workspace
├── version.txt
├── .github
│   └── workflows
│       ├── main.yml
│       └── pylint.yml
├── src
│   ├── fortran
│   │   ├── Interpolado.compile
│   │   ├── SPLINE3DFor.cpython-310-x86_64-linux-gnu.so
│   │   ├── LINdexerpol.cpython-311-darwin.so
│   │   ├── SPLINE3DFor.cpython-310-darwin.so
│   │   ├── LINinterpol.compile
│   │   ├── AkimaSpline.cpython-311-darwin.so
│   │   ├── Interpolado.f90
│   │   ├── FluxConSpec.cpython-311-darwin.so
│   │   ├── Interpolado.cpython-310-x86_64-linux-gnu.so
│   │   ├── SPLINE1DArr.f90
│   │   ├── SPLINE1DFlt.f90
│   │   ├── Interpolado.cpython-39-x86_64-linux-gnu.so
│   │   ├── FluxConSpec.cpython-310-x86_64-linux-gnu.so
│   │   ├── SPLINE1DArr.cpython-39-darwin.so
│   │   ├── SPLINE1DFlt.cpython-310-x86_64-linux-gnu.so
│   │   ├── AkimaSpline.cpython-312-x86_64-linux-gnu.so
│   │   ├── SPLINE1DArr.cpython-310-darwin.so
│   │   ├── LINdexerpol.cpython-310-x86_64-linux-gnu.so
│   │   ├── AkimaSpline.cpython-310-darwin.so
│   │   ├── Interpolado.cpython-38-x86_64-linux-gnu.so
│   │   ├── SPLINE3DFor.f90
│   │   ├── LINinterpol.cpython-311-x86_64-linux-gnu.so
│   │   ├── SPLINE3DFor.cpython-39-darwin.so
│   │   ├── SPLINE1DFlt.compile
│   │   ├── FluxConSpec.f90
│   │   ├── FluxConSpec.cpython-39-x86_64-linux-gnu.so
│   │   ├── FluxConSpec.cpython-310-darwin.so
│   │   ├── SPLINE3DFor.cpython-311-darwin.so
│   │   ├── LINinterpol.f90
│   │   ├── SPLINE1DFlt.cpython-39-x86_64-linux-gnu.so
│   │   ├── AkimaSpline.compile
│   │   ├── SPLINE3DFor.compile
│   │   ├── AkimaSpline.cpython-39-darwin.so
│   │   ├── LINinterpol.cpython-310-darwin.so
│   │   ├── FluxConSpec.cpython-39-darwin.so
│   │   ├── LINinterpol.cpython-310-x86_64-linux-gnu.so
│   │   ├── LINdexerpol.f90
│   │   ├── SPLINE1DFlt.cpython-311-darwin.so
│   │   ├── SPLINE1DFlt.cpython-39-darwin.so
│   │   ├── README.txt
│   │   ├── SPLINE3DFor.cpython-38-x86_64-linux-gnu.so
│   │   ├── FluxConSpec.compile
│   │   ├── DataTypes.f90
│   │   ├── LINdexerpol.compile
│   │   ├── Interpolado.cpython-312-x86_64-linux-gnu.so
│   │   ├── LINdexerpol.cpython-38-x86_64-linux-gnu.so
│   │   ├── SPLINE1DArr.compile
│   │   ├── LINdexerpol.cpython-310-darwin.so
│   │   ├── SPLINE1DFlt.cpython-38-x86_64-linux-gnu.so
│   │   ├── LINinterpol.cpython-311-darwin.so
│   │   ├── AkimaSpline.cpython-38-x86_64-linux-gnu.so
│   │   ├── FluxConSpec.cpython-38-x86_64-linux-gnu.so
│   │   ├── SPLINE3DFor.cpython-39-x86_64-linux-gnu.so
│   │   ├── SPLINE1DArr.cpython-311-darwin.so
│   │   ├── AkimaSpline.f90
│   │   ├── SPLINE1DFlt.cpython-310-darwin.so
│   │   ├── LINdexerpol.cpython-39-darwin.so
│   │   ├── LINinterpol.cpython-39-darwin.so
│   │   └── LINdexerpol.cpython-39-x86_64-linux-gnu.so
│   └── python
│       ├── __init__.py
│       ├── PyAkimaSpline.py
│       ├── fluxconserve.py
│       ├── PyInterpolado.py
│       ├── PySPLINE1DArr.py
│       ├── PyLinear__int.py
│       ├── PyLINdexerpol.py
│       ├── califa_cmap_alternative.py
│       ├── PySPLINE3DFor.py
│       ├── fluxconserving.png
│       ├── PyFluxConSpec.py
│       └── PyLINinterpol.py
├── scripts
│   └── update_readme.py
├── build
│   ├── lib.macosx-11.0-arm64-cpython-39
│   │   └── PyFluxconserving
│   │       ├── __init__.py
│   │       ├── PyAkimaSpline.py
│   │       ├── fluxconserve.py
│   │       ├── PyInterpolado.py
│   │       ├── PySPLINE1DArr.py
│   │       ├── PyLinear__int.py
│   │       ├── PyLINdexerpol.py
│   │       ├── flib.cpython-39-darwin.so
│   │       ├── califa_cmap_alternative.py
│   │       ├── PySPLINE3DFor.py
│   │       ├── PyFluxConSpec.py
│   │       └── PyLINinterpol.py
│   ├── src.macosx-11.0-arm64-3.9
│   │   ├── build
│   │   │   └── src.macosx-11.0-arm64-3.9
│   │   │       └── PyFluxconserving
│   │   │           ├── fortranobject.c
│   │   │           └── fortranobject.h
│   │   ├── numpy
│   │   │   └── distutils
│   │   │       └── include
│   │   │           └── npy_cpu_dispatch_config.h
│   │   └── PyFluxconserving
│   │       ├── flib-f2pywrappers.f
│   │       ├── flibmodule.c
│   │       └── flib-f2pywrappers2.f90
│   └── temp.macosx-11.0-arm64-cpython-39
│       ├── src
│       │   └── fortran
│       │       ├── LINdexerpol.o
│       │       ├── DataTypes.o
│       │       ├── LINinterpol.o
│       │       ├── FluxConSpec.o
│       │       ├── AkimaSpline.o
│       │       ├── SPLINE1DArr.o
│       │       ├── Interpolado.o
│       │       └── SPLINE3DFor.o
│       ├── build
│       │   └── src.macosx-11.0-arm64-3.9
│       │       ├── build
│       │       │   └── src.macosx-11.0-arm64-3.9
│       │       │       └── PyFluxconserving
│       │       │           ├── fortranobject.o
│       │       │           └── fortranobject.o.d
│       │       └── PyFluxconserving
│       │           ├── flib-f2pywrappers2.o
│       │           ├── flibmodule.o
│       │           ├── flibmodule.o.d
│       │           └── flib-f2pywrappers.o
│       ├── __pycache__
│       │   └── ccompiler_opt_cache_ext.cpython-39.pyc
│       ├── ccompiler_opt_cache_ext.py
│       └── PyFluxconserving
│           └── moddatatype.mod
├── dist
│   ├── pyfluxconserving-0.1.16-py3-none-any.whl
│   └── pyfluxconserving-0.1.16.tar.gz
├── requirements.txt
├── requirements.py
├── README.md
├── setup.py
├── tutorials
│   ├── PyFluxconserving Example.ipynb
│   ├── .virtual_documents
│   │   └── PyFluxconserving Example.ipynb
│   └── .ipynb_checkpoints
│       ├── pyfluxconserving Example-checkpoint.ipynb
│       └── PyFluxconserving Example-checkpoint.ipynb
├── figures
│   ├── PyFluxconserving_.png
│   └── PyFluxconserving.png
├── showdown.min.js
├── index.html
├── LICENSE.txt
├── PyFluxconserving
│   ├── __init__.py
│   ├── PyAkimaSpline.py
│   ├── fluxconserve.py
│   ├── PyInterpolado.py
│   ├── PySPLINE1DArr.py
│   ├── PyLinear__int.py
│   ├── __pycache__
│   │   ├── PyFluxConSpec.cpython-312.pyc
│   │   ├── califa_cmap_alternative.cpython-312.pyc
│   │   ├── __init__.cpython-312.pyc
│   │   └── fluxconserve.cpython-312.pyc
│   ├── flib.pyf
│   ├── flib.cpython-312-x86_64-linux-gnu.so
│   ├── PyLINdexerpol.py
│   ├── califa_cmap_alternative.py
│   ├── PySPLINE3DFor.py
│   ├── PyFluxConSpec.py
│   └── PyLINinterpol.py
├── README_setup.txt
├── .git
│   ├── logs
│   │   ├── HEAD
│   │   └── refs
│   │       ├── remotes
│   │       │   └── origin
│   │       │       └── main
│   │       └── heads
│   │           └── main
│   ├── config
│   ├── HEAD
│   ├── refs
│   │   ├── remotes
│   │   │   └── origin
│   │   │       └── main
│   │   ├── heads
│   │   │   └── main
│   │   └── tags
│   ├── config.worktree
│   ├── FETCH_HEAD
│   ├── description
│   ├── hooks
│   │   ├── sendemail-validate.sample
│   │   ├── pre-receive.sample
│   │   ├── fsmonitor-watchman.sample
│   │   ├── prepare-commit-msg.sample
│   │   ├── post-update.sample
│   │   ├── pre-rebase.sample
│   │   ├── push-to-checkout.sample
│   │   ├── pre-merge-commit.sample
│   │   ├── pre-applypatch.sample
│   │   ├── pre-commit.sample
│   │   ├── commit-msg.sample
│   │   ├── applypatch-msg.sample
│   │   ├── pre-push.sample
│   │   └── update.sample
│   ├── index
│   ├── objects
│   │   ├── pack
│   │   │   ├── pack-46f3154c766289426b0cda7512267f9284038e5e.rev
│   │   │   ├── pack-46f3154c766289426b0cda7512267f9284038e5e.idx
│   │   │   └── pack-46f3154c766289426b0cda7512267f9284038e5e.pack
│   │   └── info
│   ├── shallow
│   └── info
│       └── exclude
├── pyfluxconserving
│   └── meta.yaml
├── tree.out
└── PyFluxconserving.egg-info
    ├── PKG-INFO
    ├── dependency_links.txt
    ├── top_level.txt
    └── SOURCES.txt

53 directories (0 symlink), 179 files (0 symlink)
#################################################
Generated: treehue_colored @2025 - © Jean Gomes -
#################################################


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.

Metadata

Release files for PyFluxconserving 0.1.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyFluxconserving 0.1.17
File Size Uploaded
pyfluxconserving-0.1.17.tar.gz 100.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyFluxconserving 0.1.17
File Interpreter ABI Platform
pyfluxconserving-0.1.17-py3-none-any.whl Python 3 none any Details

Total release size: 195.9 kB

Release files / pyfluxconserving-0.1.17.tar.gz

Download URL pyfluxconserving-0.1.17.tar.gz
Size 100.2 kB
Tags Source
SHA-256 checksum
How to use checksums
020c7c7aa8ce44ab8a1ef75b22427f77c8ac70934ed021cfa54ec0313bdb8cf4
BLAKE2b-256 checksum
How to use checksums
3b9d5d5c6bbafd21917cc6e42ff3f689ee44d4fe4ba1830e519b026de94efcd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / pyfluxconserving-0.1.17-py3-none-any.whl

Download URL pyfluxconserving-0.1.17-py3-none-any.whl
Size 95.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd3dfc985acc02971770759d052fef8fbde24de32057f97a1b3182bb379939d7
BLAKE2b-256 checksum
How to use checksums
beb48a310322577c644876a6d3c671f88ca888b397bcc069fbbb21813b658a70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.1.17 This release

2 release files

0.1.16

2 release files

0.0.14

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page