Skip to content

Installation

SpectraFit can be currently only installed directly from the GitHub repository. It is important that poetry is installed first, because the setup.py is not explicitly defined, because it is indirectly available in the pyproject.toml file.

via GitHub

Bash
pip install git+https://github.com/Anselmoo/SpectraFit.git

via PyPi

Bash
pip install spectrafit

With extensions

For the jupyter support, the following command can be used:

Bash
pip install spectrafit[jupyter-dash]

For the graph visualization, the following command can be used:

Bash
pip install spectrafit[graph]

For all extensions, the following command can be used:

Bash
pip install spectrafit[all]

via Environment

To keep the system environment clean, the installation is done via the:

PIPX allows to install and run packages in a isolated environment.

Installation:

Bash
# install pipx for macOS
brew install pipx
# install pipx for Linux or Windows
pip install pipx
pipx install --upgrade pipx
# install spectrafit for python 3.7
pipx install spectrafit --python python3.7
# install spectrafit for python 3.8
pipx install spectrafit --python python3.8
# install spectrafit for python 3.9
pipx install spectrafit --python python3.9

spectrafit --help

Conda is a package manager for Python. It is a tool for installing and managing packages, environments, and virtualenvs. SpectraFit is available as conda-forge.

Example:

Bash
conda install -c conda-forge spectrafit

spectrafit --help

For include the jupyter support, the following command can be used:

Bash
conda install -c conda-forge spectrafit-jupyter

# To test
python -c "from spectrafit.plugins.notebook import SpectraFitNotebook"

For include the graph support, the following command can be used:

Bash
conda install -c conda-forge spectrafit-graph

# To test
python -c "from spectrafit.plugins.graph import SpectraFitGraph"
For include the all support, the following command can be used:

Bash
conda install -c conda-forge spectrafit-all

# To test
python -c "from spectrafit.plugins.notebook import SpectraFitNotebook"
python -c "from spectrafit.plugins.graph import SpectraFitGraph"

Extended documentation about the installation of SpectraFit via conda can be found here. In general, the following command can be useful for working with conda:

Bash
conda config --add channels conda-forge
conda config --set channel_priority strict

For installing SpectraFit via Poetry, first SpectraFit has to be downloaded or cloned from the GitHub repository. Optionally, the SpectraFit repo has to be unpacked. Next, poetry has to be installed via pip:

Bash
pip install poetry

or via conda:

Bash
conda install -c conda-forge poetry
Installation:

Bash
poetry install -E jupyter
Usage:

Bash
poetry run spectrafit --help

or using the poetry shell:

Bash
poetry shell
spectrafit --help

Result:

Bash
    usage: spectrafit [-h] [-o OUTFILE] [-i INPUT] [-ov] [-e0 ENERGY_START]
                    [-e1 ENERGY_STOP] [-s SMOOTH] [-sh SHIFT] [-c COLUMN COLUMN]
                    [-sep { ,,,;,:,|, ,s+}] [-dec {.,,}] [-hd HEADER]
                    [-g {0,1,2}] [-auto] [-np] [-v] [-vb {0,1,2}]
                    infile

    Fast Fitting Program for ascii txt files.

    ...

Plugins

The SpectraFit package is designed to be extended by plugins. Currently available plugins are:

  • Input-File-Converter (built-in)
  • Jupyter-Notebook-Interface (pip install spectrafit[jupyter])
  • Elastic-Line-Alignment (in progress)

via Docker

About Docker-Image

Since version 0.12.0, the SpectraFit package is available as a Docker-Image. The Docker-Image is based on an modified Jupyter-Scipy-Image and contains the SpectraFit package and the Jupyter-Notebook interface.

The Docker-Image can be installed for both amd64 aka x86_64 or arm64 and used via:

Bash
docker pull ghcr.io/anselmoo/spectrafit:latest
docker run -it -p 8888:8888 spectrafit:latest

or just via:

Bash
docker run -it -p 8888:8888 ghcr.io/anselmoo/spectrafit:latest

Docker-Image

To include the home directory of the host system, the following command can be used:

Bash
docker run -it -p 8888:8888 -v $HOME:/home/user/work spectrafit:latest

or via:

Bash
docker run -it -p 8888:8888 -v $HOME:/home/user/work ghcr.io/anselmoo/spectrafit:latest

see also: spectrafit

About cosign

The cosign is a tool for signing and verifying container images as part of the sigstore project.The cosign can be used to sign the SpectraFit container image. The cosign can be installed via:

Bash
# install cosign for macOS and Linux
brew install cosign
# install cosign via go
go install github.com/sigstore/cosign/v2/cmd/cosign@latest

To verify the SpectraFit container image, SpectraFit's public key is required and can be found under: github.com/Anselmoo/spectrafit/blob/main/cosign.pub. You can save the public key to a file named cosign.pub:

Bash
cat cosign.pub
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE/6fPQhwVsFvcfGtSFBIwdHbTxkF3
KaNOdpXBpmyrM/y1TM5YgTYl5mVq7km/LPukbXslcrVX1dT5H+FUP6+onQ==
-----END PUBLIC KEY-----
Then, cosign can be used to verify the SpectraFit container image:

Bash
cosign verify --key cosign.pub  ghcr.io/anselmoo/spectrafit:latest

# or export to json
cosign verify  --key cosign.pub  ghcr.io/anselmoo/spectrafit:latest > cosign_verify.json

and the output can be saved to a file named cosign_verify.json.

Bash
cat cosign_verify.json
[
{
    "critical": {
        "identity": {
            "docker-reference": "ghcr.io/anselmoo/spectrafit"
        },
        ...