Skip to main content

SN modeling package

Project description

NaCl

PyPI - Version PyPI - Python Version coverage

:warning: This code is still under development and cannot be considered stable

The NaCl package contains code to develop and train type Ia supernova spectrophotometric models. NaCl can train hybrid models, i.e. models trained simultaneously on lightcurves, spectral and/or, optionaly, spectrophotometric data, such as the spectrophotometric sequences published by the SNfactory collaboration.

As of today, NaCl contains:

  • a re-implementation of the SALT2 model and error model (Guy et al, 2007, 2010), with various improvements to make sure that the training can be performed in one single minimization

  • classes to manage a hybrid (light curves + spectra + photometric spectra) training sample

  • a minimization framework that is able to minize a log-likelihood function, along with quadratic constraints (optional) and quadratic regularization penalities (optional). It is also possible to fit a fairly general error model simultaneously.

Table of Contents

Installation

virtual environments

We recommend using conda which comes with a compiled version of suitesparse. venv is also a suitable option if suitesparse is already installed on your machine, or if you are ready to compile it yourself (on Debian/Unbuntu, just have a sudo apt install libsuitesparse-dev).

As a reminder:

conda create -n MY_ENV
conda activate MY_ENV

or:

python -m venv MY_ENV
source MY_ENV/bin/activate

Prerequisites

conda packages for sn-nacl are in preparation (but not ready yet). If you are working within a conda environnment, we recommend that you install these conda packages first:

conda install bbf ipython numpy numba scipy matplotlib scikit-sparse pandas h5py pyarrow

The mkl library can enhance training speed. While it is not a requirement, we recommend installing it if you are using an Intel platform:

conda install mkl sparse_dot_mkl

Until our changes are merged in sncosmo, we use a modified version of it:

pip install git+https://github.com/nregnault/sncosmo.git

Installing NaCl

pip install sn-nacl

or, if you prefer installing it from sources:

git clone https://gitlab.in2p3.fr/lemaitre/sn-nacl
cd sn-nacl
pip install -e .

Running the tests

pip install .[test]
pytest

Building the documentation

pip install -e .[doc]
cd docs
make html  # for example, type "make" for a list of targets

Then the documenation is available at docs/build/html/index.html

Getting started

TBD

Troubleshooting

Dealing with scikit-sparse

NaCl depends on the python bindings to the cholmod package, distributed with the scikit-sparse package. In most cases, scikit-sparse will be fetched automatically and installed without any problem. However, depending on your version of python the installation may crash for various reasons:

  • The package needs numpy to be installed already (and doesn't fetch it automatically if missing).

  • The packages needs cython : pip install cython should solve the problem.

  • Finally, libsuitesparse should also be available on your system. On a debian or ubuntu system: sudo apt-get install libsuitesparse-dev should suffice. On Fedora/CentOS the equivalent is sudo yum install libsuitesparse-devel. Otherwise, an alternative is to to the SuiteSparse repository, clone it and follow the installation instructions.

  • Also, for python>=3.10, the pip installation of scikit-sparse may complain about various things and stops. If you encounter this kind of problem, this longer install sequence should work:

    pip install numpy
    git clone https://github.com/scikit-sparse/scikit-sparse.git
    cd scikit-sparse; python setup.py install; cd ..
    pip install sn-nacl
    

License

sn-nacl is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sn_nacl-0.7.3.tar.gz (145.6 kB view details)

Uploaded Source

File details

Details for the file sn_nacl-0.7.3.tar.gz.

File metadata

  • Download URL: sn_nacl-0.7.3.tar.gz
  • Upload date:
  • Size: 145.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for sn_nacl-0.7.3.tar.gz
Algorithm Hash digest
SHA256 029bed0359cf2be587c79f5992bb9da99f7a5d273044bcedf0507b571aff1304
MD5 05171032c6d48f7adeb7f02ff95e6d46
BLAKE2b-256 1170bd41706262bbcb3e32c071e9aa05b7da031bb56a159c184b1f66ad88c86a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page