GithubHelp home page GithubHelp logo

cosmicrays / hermes Goto Github PK

View Code? Open in Web Editor NEW
21.0 8.0 9.0 24.14 MB

HERMES is a publicly available computational framework for the line of sight integration over galactic radiative processes which creates sky maps in the HEALPix-compatibile format.

License: GNU General Public License v3.0

CMake 3.45% C++ 83.14% Objective-C 1.32% Makefile 0.06% C 2.79% Shell 0.31% Python 8.52% Starlark 0.34% Dockerfile 0.06%
astroparticle-physics gamma-ray-astronomy neutrino-astronomy synchrotron cosmic-rays galactic-radiative-processes healpix

hermes's Introduction

HERMES - High-Energy Radiative MESsengers

Build Status Coverage Status Codacy Badge GitHub arXiv ascl

About

gamma sky map from pi0

HERMES is a publicly available computational framework for the line of sight integration which creates sky maps in the HEALPix-compatibile format of various galactic radiative processes including Faraday rotation, synchrotron and free-free radio emission, gamma-ray emission from pion-decay, bremsstrahlung and inverse-Compton. The name is an acronym for "High-Energy Radiative MESsengers".

The code is written in C++ relying on features of the language's recent revisions (C++11, C++14). Once compiled, HERMES can optionally be used from Python thanks to pybind11 (Python 2.X is not supported). Some components of the code (such as galactic magnetic field models, vector and grid classes) were adopted from CRPropa 3, a code for cosmic ray propagation.

HERMES provides the following integrators:

  • Dispersion measure
  • Rotation measure
  • Free-Free emission
  • Synchrotron emission (with absorption)
  • Pion decay gamma-ray emission
  • Inverse Compton scattering
  • Bremsstrahlung
  • Gamma-ray emissions from Dark Matter annihilation

The complete feature list is documented on github.io.

Quickstart

If Docker or Podman is installed, one can quickly enter a Jupyter notebook with HERMES already built and available:

docker run -it --rm -p 8888:8888 quay.io/cosmicrays/jupyter-hermes:latest

The notebook can be accessed via web browser following the link in the output of the above command.

For more details how to use containers see INSTALL - Use with Docker/Podman image and Jupyter Docker Stacks.

Install

For those who know their way around, the make-install procedure is available:

mkdir build
cd build
cmake ..
make -j

For detailed installation guides and requirements see INSTALL.

Usage

from pyhermes import *
from pyhermes.units import TeV, deg, kpc, pc

nside = 512
Egamma = 0.1*TeV
obs_pos = Vector3QLength(8.0*kpc, 0*pc, 0*pc)

skymap = GammaSkymap(nside, Egamma)
mask = RectangularWindow([5*deg, 40*deg], [-5*deg, 90*deg])
skymap.setMask(mask)

neutral_gas = neutralgas.RingModel(neutralgas.GasType.HI)
cosmicray_protons = cosmicrays.Dragon2D(Proton)
pp_crosssection = interactions.Kamae06Gamma()

integrator = PiZeroIntegrator(cosmicray_protons, neutral_gas, pp_crosssection)
integrator.setObsPosition(obs_pos)
integrator.setupCacheTable(100, 100, 20)

skymap.setIntegrator(integrator)
skymap.compute()

output = outputs.HEALPixFormat("!pizero-dragon2d.fits.gz")
skymap.save(output)

More examples can be found in the examples repository. Full documentation of the code is available here.

How to cite HERMES

If you have used HERMES in a scientific project that lead to a publication, we'd appreciate you citing the paper associated with it:

@ARTICLE{HermesCode,
       author = {{Dundovic}, A. and {Evoli}, C. and {Gaggero}, D. and {Grasso}, D.},
        title = "{Simulating the Galactic multi-messenger emissions with HERMES}",
      journal = {\aap},
         year = 2021,
        month = sep,
       volume = {653},
          eid = {A18},
        pages = {A18},
          doi = {10.1051/0004-6361/202140801},
          url = {https://doi.org/10.1051/0004-6361/202140801},
archivePrefix = {arXiv},
       eprint = {2105.13165},
 primaryClass = {astro-ph.HE},
}

Credits

Name Institution
Andrej Dundovic Institute for Cosmology and Philosophy of Nature, Križevci, Croatia
Carmelo Evoli Gran Sasso Science Institute, L'Aquila, Italy
Daniele Gaggero INFN Sezione di Pisa, Pisa, Italy

hermes's People

Contributors

adundovi avatar carmeloevoli avatar codacy-badger avatar joveh avatar lepperdinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hermes's Issues

Random magnetic field

Hi,

I have been trying to reproduce the results of this paper https://arxiv.org/abs/1210.4546 . In fig 2 it is shown that the dominant contribution of the synchrotron maps is from the random magnetic field. Is there any possibility of computing the synchroton maps using both Pshirkov and the random field at the same time? Thanks.

Regards,
Manuel

Issue in reproducing Figure 6

I was trying to reproduce Pion HI decay at 10 GeV, Figure 6 of your paper. Somehow I couldn't generate the same scale for the colour scheme. Overall the plot looks the same; the scaling is different for the colours, even after taking care of units and taking the log scale. I am attaching the scales I am getting for the Pion HI decay at 10 GeV
Can you share the code you used to generate the plot or suggest something I might not follow?

pyhermes module not found

Hello!
Python is having troubles to find the pyhermes module, even though I am importing pyhermes in the build folder, where the pyhermes.cpython-38-x86_64-linux-gnu.so is located. I have tried adding explicitly the build path to the PYTHONPATH variable and to the python sys.path(), but for both cases I get the same error:
>>> import pyhermes
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pyhermes'

I am installing Hermes in a cluster of computers, within an environment where I have full control, and there was no problem in the installation process.

Any ideas on how to solve this?
Thanks!

neutrino and antineutrino flux

Hi,

Important double check: The cross section returned in interactions/KelnerAharonianNeutrino ( F_numu + 2. * F_e ) refers to only neutrinos, right?
I assume that, in order to compute the total nu + nu_bar flux, we have to multiply the flux computed by HERMES by 2, as in eq. 52 and 53 of Kelner and Aharonian 2006. Could you confirm this?

Thanks a lot!!

deprecation warning for CMake

CMake Deprecation Warning at lib/kiss/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at lib/cparamlib/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

Error reading CR 3D distribution

Hi!

When trying to read the regular 3D CR distribution from DRAGON that comes with the HERMES release, I get this error: AttributeError: module 'pyhermes.cosmicrays' has no attribute 'Dragon3D'.

Thanks a lot in advance!

observer

change sun_position to observer_position to clarify its meaning.

Adding Integrators and Gas Types

Hello:

I would like to generate a Skymap that include Inverse Compton, Pion Decay and Bremsstrahlung, and for the latter two, I want to include both HI and H2. I want a Skymap with all the relevant background light. How can I do that?

Thanks

A question on the code and plot 6

Hello:

I have a question regarding your plot 6 and the sample code. It is my understanding that the integrators yield the intensity, which for plot 6 is given by GeV cm^-2 sr^-1 s^-1. However, in the sample code you provide (e2-pizero-dragon2d.ipynb), the skymap gives a plot with units of TeV^-1 cm^-2 sr^-1 s^-1. What does this represent? and how do I get an intensity plot similar to plot 6 in your paper?

In addition, I would like to integrate over Egamma, how do I do that? From the C++ code, or is it possible to do it on the python code?

Thanks

Problem with Masks

The rectangular mask seems to have a problem.

For instance if I set
mask_edges = ([5deg, 0deg], [-5deg, 180deg])
mask = RectangularWindow(*mask_edges)

I think I actually get the [0,5*deg] in latitude

3D Gas Datacube

Hi,

it would ve very useful to include the possibility to compute the pi0 emission from a gas model provided as a 3D datacube (for instance as FITS file), or a generic smooth function f(x,y,z) provided by the user. The model would not necessarily be defined in the whole Galaxy, it could be a zoomed-in map of the GC region, or a relevant star-forming region for instance.

Would it be possible to modify the pi0 integrator to include this possibility?

thanks!
Daniele

FITS file for H2 ring model

Hello!

When I try to load the ring model for the H2 gas via

auto gasType = hermes::neutralgas::GasType::H2;
auto ringModel = std::make_shared<neutralgas::RingModel>(gasType);

I get the error message

FITSIO status = 252: 1st key not SIMPLE or XTENSION
Extension doesn't start with SIMPLE or XTENSION keyword. (ffrhdu)
._WCOrings_COGAL.fits
ffopen could not interpret primary array header of file: 
/home/stefan/.virtualenvs/hermes/share/hermes/data/GasDensity/Remy18/WCOrings_CO
GAL.fits.gz
This does not look like a FITS file.
terminate called after throwing an instance of 'std::runtime_error'
  what():  hermes: error: Cannot open file.
Aborted (core dumped)

My OS is Linux Mint 20.2.

I also can't open the file hermes/share/hermes/data/GasDensity/Remy18/WCOrings_COGAL.fits.gz via SAOImageDS9 (SAOImageDS9 version = 8.1) or via astropy.io.fits.open() (astropy version = 5.1). So this file seems to be broken. If I unpack WCOrings_COGAL.fits.gz via gzip (gzip version = 1.10), the resulting file WCOrings_CO GAL.fits is still broken but if I unpack WCOrings_COGAL.fits.gz via tar (tar version = 1.30) instead, the resulting file WCOrings_COGAL.fits looks fine.

My current workaround for that problem is to extract the file via tar and then to compress it again via gzip:

hermes_virtualenv=~/.virtualenvs/hermes
cd ${hermes_virtualenv}/share/hermes/data/GasDensity/Remy18
tar xf WCOrings_COGAL.fits.gz
gzip -f WCOrings_COGAL.fits

(The FITS file is part of the archive https://heat.gssi.it/hermes/data/hermes-data.tar.gz, which gets downloaded by CMake.)

pyhermes module not created

Hi,
I am trying to install Hermes on MacOS in a conda environment. After linking the python interpreter in the env at the cmake step, the installation and the tests went well, meaning that the C++ part works correctly. But even if I turn on the -DENABLE_PYTHON flag, PyBind doesn't seem to create the python library.

Do you have an idea on how to solve this issue?

Thanks!
Jordan Koechler

latest update and python

Hi,

I installed the latest version, I get no error with cmake and the library is correctly installed. However, only the C++ library is there, in previous versions I also had pyhermes.cpython-37m-darwin.so (which could be loaded by any python script)

I have python3 correctly installed and linked via homebrew, and launched the usual
cmake ..
-DPYTHON_EXECUTABLE=$PYTHON_BREW_PATH/bin/python3
-DPYTHON_LIBRARY=$PYTHON_BREW_PATH/Frameworks/Python.framework/Versions/Current/lib/libpython3.10.dylib
-DPYTHON_INCLUDE_PATH=$PYTHON_BREW_PATH/Frameworks/Python.framework/Versions/Current/include
-DENABLE_TESTING=On

Error reading the libraries

I get this error message running the notebook in spite all required libraries are correctly installed:

ImportError Traceback (most recent call last)
in
----> 1 from pyhermes import *
2 from pyhermes.units import *
3
4 import astropy.units as u
5

ImportError: dlopen(/Users/dariograsso/Codes/hermes/build/pyhermes.so, 2): Symbol not found: __PyThreadState_Current
Referenced from: /Users/dariograsso/Codes/hermes/build/pyhermes.so
Expected in: flat namespace
in /Users/dariograsso/Codes/hermes/build/pyhermes.so

A typo in your paper?

Hello:

I am currently running some of you code and reading the paper. However, there is an issue that is confusing me. According to Figure 8. in your paper, pion decay through the contribution from HI dominates over that from H2, however, when you look at Figure 6 and compare the left image to the right, we can see that it is H2 that dominates over HI, at least near the galactic center (you can check the color bar). This is what I did when I ran your sample codes given in the file: e2-pizero-dragon2d.ipynb.
Is this a typo?

Installation errors in ubuntu 18.04

Hi, I am trying to install Hermes in my computer (I use ubuntu 18.04 in a session of MobaXterm) and the compilation shows me several errors such as:
/home/Diffuse_models/hermes/include/hermes/integrators/PiZeroIntegrator.h:26:30: error: ‘RingModel’ is not a member of
‘hermes::neutralgas’
std::shared_ptrneutralgas::RingModel ngdensity;
/home/Diffuse_models/hermes/include/hermes/integrators/PiZeroIntegrator.h:26:30: error: ‘RingModel’ is not a member of
‘hermes::neutralgas’
/home/Diffuse_models/hermes/include/hermes/integrators/PiZeroIntegrator.h:26:39: error: template argument 1 is invalid
std::shared_ptrneutralgas::RingModel ngdensity;

And other similar ones regarding the declaration of variables not found. I think this is due to my compiler (I am using gcc 8.4.0.)

In addition, when using the command cmake .. I find that CFitsio and doxygen are not found. I even tried a command like: cmake .. -DCFITSIO=/home/Diffuse_models/cfitsio-3.49/ but it does not find it and I get the following warning:
Manually-specified variables were not used by the project:
CFITSIO

Any ideas on how could I fix these problems?

Thank you in advance.

deprecated function in CacheTools

CacheTools.h:30:32: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]

CacheTools.h:40:33: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]

warning found both for Mac and GNU compliers, we should find an alternative at some point.

Incompatibility with python 3.9.1 version?

I am trying to install Hermes in a new environment, where I am using the Python version 3.9.1, and I get the following error when running the CMAKE_PREFIX_PATH=$HERMES_DIR cmake -DCMAKE_INSTALL_PREFIX=$HERMES_DIR -DENABLE_TESTING=On .. command, in the build directory:

CMake Error at /software/sse/manual/CMake/3.12.1/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find PythonInterp: Found unsuitable version "3.9.1", but required
is at least "39" (found /home/x_pedde/.virtualenvs/hermes/bin/python)

Any idea on what is the problem here?

Query regarding DarkMatterIntegrator

Hi,

We can use the DarkMatterIntegrator to get the flux as a function of gamma-ray energy (for a given DM mass, channel and NFW profile) at any given observer position. For a given NFW profile parameters (the concentration, gamma slope, mass of halo) and observer position, can any one tell how do I obtain the J-factor using HERMES?

Any help in this regard would be really useful.

Thanks!
Tejas

Dark matter annihilation with HERMES (request for help)

Hi,

Two questions regarding dark matter(DM) annihilation to gamma-rays using HERMES.

  1. The dark matter integrator takes two inputs, the spectrum and the profile. So, in the spectrum part, how do I extract the canonical cross section (<sigma.v> value) for a given DM annihilation channel?

  2. How do I include (or is it possible to include) the gamma-ray absorption in the ISRF medium for the DM annihilation case?

Any help with the above questions would be really helpful.

Thanks!
Tejas Satheesh

problem with Grid2D

Grid2D is still based on Vector3D, which is clearly inconsistent.
Still it is used only for reading Dragon maps, so it is not an issue now but it might be for future users.

HERMES Installation (request for help)

Hi,

I am facing an error while installing HERMES. While running the make -j command (in Linux operating system), I am getting some errors like ‘RingModel’ is not a member of ‘hermes::neutralgas’, ‘ring’ is not captured, base operand of ‘->’ is not a pointer, ‘gasType’ is not captured,
and finally,
make[2]: *** [CMakeFiles/hermes.dir/build.make:362: CMakeFiles/hermes.dir/src/integrators/PiZeroAbsorptionIntegrator.cpp.o] Error 1
make[2]: *** [CMakeFiles/hermes.dir/build.make:375: CMakeFiles/hermes.dir/src/integrators/PiZeroIntegrator.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:619: CMakeFiles/hermes.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 47%] Linking CXX static library ../../libgtest.a
[ 47%] Built target gtest
make: *** [Makefile:141: all] Error 2

Any help in solving the errors would be really helpful.

Thanks!
Tejas Satheesh

New integrator: Gamma-ray absorption on CMB only

In order to speed up the pi0 integrator including gamma-ray absorption we should consider the case in which CMB is the only photon field. Being spatially uniform it simplifies the runtime calculation of the optical depth.

cfitsio must be mandatory

I am trying to install hermes in a new computer and I forgot to install cfitsio beforehand.

cmake .. went smooth, altough I didn't catch the message -- CFITSIO not found. immediately.

When passing to the make however , it generated several errors, mainly due to the fact that hermes::neutralgas::RingModel exists only if CFITSIO has been found, due to the header guard line #ifdef HERMES_HAVE_CFITSIO

Now I installed CFITSIO and it works... My question is: is there a way to stop makefile generation with cmake .. when CFITSIO is not found?

RectangularWindow mask argument

Hello!
differently from what it's on the technical paper, it seems that the function RectangularWindow, that isolates a limited region in the sky, requires two 2D arrays with ([latitude_low, latitude_high], [longitude_low, longitude_high]) instead of (top_left_edge, bottom_right_edge).
I tested it with something easily recognizable such as b = [-30, 15], l = [60, 75] and seems to be this way, I am sure it's just a matter of naming.

Schermata 2021-06-28 alle 18 13 10

Ottavio

Integrating over photon energy

Hello:

The skymaps Hermes produces are differential flux for a specific photon energy Egamma. I would like to integrate over the photon energy so that I get skymaps with the total energy flux, i.e. I want to do the integral $\int_{Emin}^{Emax}$ dE_{\gamma} \epsilon E_{\gamma}$, however, there is a problem doing this because in order for the Skymap integrator in Hermes to work, I need to specify Egamma from the start. I tried this in Jupyter Notebook

def integrate_function(emissivity, energy_min, energy_max): integrand = lambda energy: emissivity * energy result, _ = quad(integrand, energy_min, energy_max) return result

However, I can't do Skymap.compute() keeping Egamma as unknown. I need to somehow convolve my energy integral with Hermes's Skymap integral. I am not sure how to do that. I tried to look into the integrator files, but it's not clear where I should modify the code.

I appreciate your help

Best regards

When skymap mask is present, multithreading is not optimally used

The procedure in which pixel chunks are distributed across CPU threads ignores masked pixels (in SkymapTemplate.h), thus threads with many masked pixels are quickly completed and stay idle until other, busy threads finish their chunks. If a computer has many threads and masked scenario is run, redesigning this can bring a significant reduction in the computation time.

Instalation error

Hi, I have some problems when installing HERMES.
When I do the "CMAKE_PREFIX_PATH=$HERMES_DIR cmake -DCMAKE_INSTALL_PREFIX=$HERMES_DIR -DENABLE_TESTING=On .." I get a warning:

CMake Warning at lib/gtest/googletest/CMakeLists.txt:47 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.

But it still works. Then, when I do the "make -j" I get an error:

/usr/bin/ld: /usr/local/lib/libfftw3f.a(assert.o): relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile con -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hermes.dir/build.make:886: libhermes.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:646: CMakeFiles/hermes.dir/all] Error 2

What could I do? I am in Ubuntu 20.04

Thank you in advance.

Gas ring model: sun position

The gas ring model cannot be used with an observer position different than [8.5,0,0]. An exception should be raised if not.

Gamma-ray absorption in dark matter annihilation (help required)

Hi,

I was trying to modify the DarkMatterIntegrator to include the absorption of gamma rays as well. So, in the DarkMatterIntegrator.cpp (located in /src/integrators), I pasted the following from the PiZeroAbsorptionIntegrator.cpp

auto cmbPhotonField(const QEnergy &eps) {
using hermes::units::expm1;
const auto K = 1. / (M_PI * M_PI) / pow<3>(h_planck_bar * c_light);
const auto cmbTemperature = 2.725_K;
const auto kT = k_boltzmann * cmbTemperature;
return K * pow<2>(eps) / expm1(eps / kT);
}

QInverseLength DarkMatterIntegrator::absorptionCoefficient(const QEnergy &Egamma_) const {
auto integrand = [this, Egamma_](double eps) {
return static_cast(cmbPhotonField(QEnergy(eps)) *
bwCrossSec->integratedOverTheta(Egamma_, QEnergy(eps)));
};

QEnergy epsMin = 1e-5_eV;
QEnergy epsMax = 5e-3_eV;

double abs_error = 0.0;  // disabled
double rel_error = 1.0e-4;
int key = GSL_INTEG_GAUSS51;  // GSL_INTEG_GAUSS15;
double result = 0;
double error = 0;

gsl_function_pp<decltype(integrand)> Fp(integrand);
gsl_function *F = static_cast<gsl_function *>(&Fp);

gsl_integration_workspace *w = gsl_integration_workspace_alloc(GSL_LIMIT);
gsl_integration_qag(F, static_cast<double>(epsMin), static_cast<double>(epsMax), abs_error, rel_error, GSL_LIMIT,
                    key, w, &result, &error);
gsl_integration_workspace_free(w);

return QInverseLength(result);

}

After pasting, I ran a python code with DarkMatterIntegrator to evaluate flux as a function of gamma -ray energy. The code ran without any errors. But I think I haven't re-compiled properly. To re-compile, should I run make -j in the hermes main directory? Can anyone tell me if what I have done is correct to include absorption for the DM annihilation to gamma-ray process? Also, it looks like what I have done only considers absorption from only the ambient CMB field and not the entire ISRF model (which includes even IR emmisions from dust, the star light as described by Vernetto and Lipari's model).

Any help in this regard would be really useful.

Thanks!
Tejas Satheesh

parallelization

Hi, very quick dummy questions:

  1. how do I disable multi-threading, or set a different number of threads?
    I noticed this line *env_num_threads = getenv("HERMES_NUM_THREADS”)
    but I have no such environment variable set in my system... still, the code is parallelized!

  2. In alternative, for debugging purpose: how do I set a line of code (e.g. a std::cout) so that it is executed on one thread at a time? I mean, the equivalent of "#pragma omp critical" in openMP

Thanks!
Daniele

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.