GithubHelp home page GithubHelp logo

kjmeagher / nuflux Goto Github PK

View Code? Open in Web Editor NEW

This project forked from icecube/nuflux

0.0 0.0 0.0 6.43 MB

A library for calculating atmospheric neutrino fluxes.

Home Page: https://docs.icecube.aq/nuflux/main

License: GNU Lesser General Public License v3.0

C++ 62.35% Python 23.78% C 0.18% Meson 10.82% Dockerfile 2.14% Shell 0.73%

nuflux's Introduction

Tests codecov Conda-Forge AUR DOI

nuflux

Nuflux is a library for calculating atmospheric neutrino fluxes.

Installation

Packages

nuflux is packaged on conda-forge. Install with conda install -c conda-forge nuflux.

From source

nuflux uses two different build systems: one based on setuptools and one based on meson. Which one you should use depends on whether you need to build C++ libraries against nuflux, or are content to use the Python bindings.

Prerequisites

  • cfitsio
  • photospline
  • boost_python

setuptools

If you only need to use python you can install it directly through pip:

pip install --user git+https://github.com/icecube/nuflux

Note that this may fail if photospline and boost_python are installed in nonstandard locations, e.g. headers in /opt/toolsets/photospline/include, libraries in /opt/toolsets/photospline/lib. In this case, set the CMAKE_PREFIX_PATH environment variable to the root of your photospline installation and BOOST_ROOT to the root of your boost installation:

CMAKE_PREFIX_PATH=/opt/toolsets/photospline BOOST_ROOT=/opt/toolsets/boost pip install --user git+https://github.com/icecube/nuflux

If you are running it in IceCube's cvmfs environment you will want to set CMAKE_PREFIX_PATH and BOOST_ROOT to the base of the cvmfs envionment which is stored in the environment variable SROOT:

eval `/cvmfs/icecube.opensciencegrid.org/py3-v4.3.0/setup.sh`
CMAKE_PREFIX_PATH=${SROOT} BOOST_ROOT=${SROOT} pip install --user git+https://github.com/icecube/nuflux

Meson

If you want to use nuflux from a c++ program you need to install it with meson

git clone https://github.com/icecube/nuflux
cd nuflux
meson build
ninja -C build
sudo ninja -C build install

If boost and photospline are installed in nonstandard locations, you might need to let meson know with environment variables. Since photospline is detected with cmake you need to set CMAKE_PREFIX_PATH=/path/to/photospline. Boost uses BOOST_ROOT.

For example, in IceCube's cvmfs envionment you should do:

 CMAKE_PREFIX_PATH=${SROOT} BOOST_ROOT=${SROOT} meson setup build . --prefix=/path/to/instal/to

the option -Ddata_path can be used to install the raw flux tables to a directory outside of the PREFIX directory.

If you want to install to a read-only file system you can pass -Dinstall_data=False

You may also use the environment variable NUFLUX_DATA to specify the path of the raw flux tables if they are in a place other than where they were installed to.

Documentation

You can build the documentation yourself using sphinx:

pip3 install sphinx breathe sphinx_rtd_theme

Run ninja with docs/html target:

ninja docs/html

The latest version of the documentation is automatically uploaded to IceCube documentation server

Usage

From python:

>>> import nuflux
>>> flux = nuflux.makeFlux('honda2006')
>>> nu_type=nuflux.NuMu
>>> nu_energy=1e3 # in GeV
>>> nu_cos_zenith = 0.5
>>> flux.getFlux(nu_type,nu_energy,nu_cos_zenith)
2.2395566552347364e-11

from c++:

#include <nuflux/nuflux.h>

int main(){  
  boost::shared_ptr<nuflux::FluxFunction> flux;
  flux=nuflux::makeFlux("honda2006");
  nuflux::ParticleType pdgid = nuflux::NuMu;
  double energy = 1e3; // in GeV
  double cos_zenith = 0;
  double f = flux->getFlux(pdgid, energy, cos_zenith);
  assert(f == 4.6476245267530432e-11);
}

nuflux's People

Contributors

arguelles avatar austinschneider avatar jvansanten avatar kjmeagher avatar nechnif avatar pabloferm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.