Skip to content

PyFluxconserving is a set of Fortran 2003+ legacy routines with Python. There are some options for the flux-conserving algorithm. It also includes interpolation scripts.

License

Notifications You must be signed in to change notification settings

neutrinomuon/PyFluxconserving

Repository files navigation

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, jean@astro.up.pt

github repository: PyFluxconserving

last stable version: 0.0.15

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

66 directories (0 symlink), 172 files (0 symlink)
#################################################
Generated: treehue_colored @2024 - © 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.

About

PyFluxconserving is a set of Fortran 2003+ legacy routines with Python. There are some options for the flux-conserving algorithm. It also includes interpolation scripts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published