Git Product home page Git Product logo

gamera's Introduction

GAMERA

is a project launched by the Max Planck Insitute for Nuclear Physics in Heidelberg (MPIK), an open-source C++/python package which handles the spectral modelling of non-thermally emitting astrophysical sources in a simple and modular way. It allows the user to devise time-dependent models of leptonic and hadronic particle populations in a general astrophysical context (including SNRs, PWNs and AGNs) and to compute their subsequent photon emission.

For more info and a turorial, see the GAMERA docu! (currently being updated)

GAMERA is written in C++ and can be wrapped to python.

The software is listed in the Astrophysics Source Code Library ascl:2203.007

Quick Start

Dependencies

You need to have GSL installed on your system, as well as SWIG if you want to wrap the python module. If you are a Mac user, it might be required to install pkg-config.

Building

Running

  • $ make all

will generate a shared object (lib/libgamera.so) as well as the python module (lib/_gamerapy.so , lib/gamerapy.py).

Licence

The GAMERA library and the GAMERA programs are free software; you can redistribute them and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

A copy of the GNU Lesser General Public License version 2.1 can be found here.

gamera's People

Contributors

carlor87 avatar cdeil avatar fwerner avatar joachimhahn avatar mischabr avatar

Stargazers

 avatar  avatar  avatar  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  avatar

gamera's Issues

flux units mismatch in tutorials 1 and 2

Hi there: I've been playing with gamera a bit. It's a nice package and is easy to install. But I noticed when running tutorials 1 and 2 that the units of E^2*Flux are coming out many orders of magnitude lower than in the same plots on your documentation page (http://joachimhahn.github.io/GAMERA/). When I switched from the master to the Astro branch and ran the tutorials, the units matched the documentation.

I'm not sure if the documentation is just out of synch with the main branch the or if there is a deeper issue. At first glance there doesn't seem to be some obvious explanation, like expressing energies in keV instead of erg. Thanks!

Printing error

When calculating the IC Loss lookup, I get:

CALCULATING IC LOSS LOOKUP
101% done
-> DONE!

I guess it is only a printing error (>100% of the lookup calculated) and it does not affect the result, but worth checking

gappa-tutorial issues with Python 3 on Mac

I tried the gappa tutorial from pygamma15.
Some things work, but I'm also getting some errors.
See http://nbviewer.ipython.org/gist/cdeil/4da1740bd380d5f1ef4e

One of the errors is this:

TypeError                                 Traceback (most recent call last)
<ipython-input-6-d7169c3eab5f> in <module>()
      1 rad = gp.Radiation()
      2 # gappa takes 2D arrays as input
----> 3 rad.SetElectrons(zip(e,nel))
      4 rad.SetProtons(zip(e,npr))

/Users/deil/code/GAMERA/lib/gappa.py in SetElectrons(self, ELECTRONS)
    709 
    710     def SetElectrons(self, ELECTRONS):
--> 711         return _gappa.Radiation_SetElectrons(self, ELECTRONS)
    712 
    713     def GetProtonVector(self):

TypeError: in method 'Radiation_SetElectrons', argument 2 of type 'std::vector< std::vector< double > >'

Another one is this:

IndexError                                Traceback (most recent call last)
<ipython-input-12-5e625acfa95c> in <module>()
----> 1 plt.loglog(to[:,0],to[:,1],c="black")
      2 plt.loglog(pp[:,0],pp[:,1],c="green")
      3 plt.loglog(sy[:,0],sy[:,1],c="blue")
      4 plt.loglog(br[:,0],br[:,1],c="red")
      5 plt.loglog(ic[:,0],ic[:,1],c="orange")

IndexError: too many indices for array

Please also try your notebook with Python 3, there's a few trivial issues (replace print statement with print function, i.e. add parentheses, use range instead of xrange).

std::isnan errors

I get errors with OS X 10.9.5 and Clang. must be included when you use std::isnan (<math.h> for naked isnan).

c++ -g -O2 -fpic -Wall -c src/Utils.C -o /Users/oxon/git/GAMERA/out/Utils.o -I/opt/local/include -std=c++11 -I./include
src/Utils.C:363:16: error: expected unqualified-id
      if (std::isnan(val) || std::isinf(val)) {
               ^
/usr/include/math.h:179:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
src/Utils.C:363:27: error: expected expression
      if (std::isnan(val) || std::isinf(val)) {
                          ^
src/Utils.C:363:35: error: expected unqualified-id
      if (std::isnan(val) || std::isinf(val)) {
                                  ^
/usr/include/math.h:174:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
src/Utils.C:363:35: error: expected expression
/usr/include/math.h:176:70: note: expanded from macro 'isinf'
                                  : __inline_isinfl((long double)(x)))
                                                                     ^
src/Utils.C:459:12: error: expected unqualified-id
  if (std::isnan(y) || std::isinf(y)) {
           ^
/usr/include/math.h:179:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
src/Utils.C:459:21: error: expected expression
  if (std::isnan(y) || std::isinf(y)) {
                    ^
src/Utils.C:459:29: error: expected unqualified-id
  if (std::isnan(y) || std::isinf(y)) {
                            ^
/usr/include/math.h:174:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
src/Utils.C:459:29: error: expected expression
/usr/include/math.h:176:70: note: expanded from macro 'isinf'
                                  : __inline_isinfl((long double)(x)))
                                                                     ^
8 errors generated.
make: *** [Utils] Error 1

GAMERA website confusingly has two landing pages

Hi all,

I noticed that the navigation of the web pages is slightly confusing - there seem to be two landing pages:

Maybe we could clean it up a bit, e.g. combine the two pages into one or perhaps rename main_page.md to NEWS.md and change the link in the project's About pane to the root page?

Cheers,
–Felix

install

How to install GAMERA, how to use the Python wrapper gappa that comes with GAMERA, and is this library compatible with Windows systems?

make always rebuilds

For GAMERA, make doesn't behave like make, it always re-executed the commands.

Can you fix the Makefile to only rebuild where needed?
(It's not really important for such a small package, feel free to close the issue if you don't think it's worth it to declare dependencies within the Makefile correctly to make this work.)

Bug in the EnergyLossRate calculation

The constants bremsl_epf and bremsl_eef are not initialize when calculating the energy losses with the function Particles::EnergyLossRate.
The problem is that they are initialized when calling the function Particles::CalculateConstants(), but the function is not called before the EnergyLossRate one.

The final wrong result I found so far is that the Bremsstrahlung losses are 0.

bin/TutorialLevel1 crashes on Mac with clang

The bin/TutorialLevel1 example crashes for me on Mac (with latest OS and clang).
The bt seems to suggest some bug in your string handling or uncaught error condition in ReadParameterFile (see below).

@JoachimHahn Is this enough info to track the issue down or should I investigate / fix?

$ lldb bin/TutorialLevel1 
(lldb) target create "bin/TutorialLevel1"
Current executable set to 'bin/TutorialLevel1' (x86_64).
(lldb) run
Process 76281 launched: '/Users/deil/code/GAMERA/bin/TutorialLevel1' (x86_64)


                               .==#W,                       
                             ,*''RBEB                       
                              $=gp-'M @                     
                             f  `-^;p$/W=                   
                               ,|5==*$Bp5BK@,               
                           ,=@w=>=@@$ZpB@E8BBBw             
                        ,4MM'^YU@`5Z3@EEEZBM , .E=@@,@p@K   
                ,     ;`  ,,@;E]BBWBWp@5W#UP@P;&;ET@5BBEBBp 
              ,*pT-p/@ ',/|@p|@]BP'`!*|`;p5N@EBp@(L`(,^^EBB 
              `*=B@/@BB@pp@5@@BM`b,@|@{Ep5E@BB@Bpp^`'''```  
                ''(Z@5BE``'*9y^  `*@bb]pEbE@ZBBU@Lp         
                 ^^']EMP `  `^w@|L|`^'$EEEEEZ@@EPP          
                    $E`E   ` /t u'*L=u@EbEb@UEEH@p          
                    $QL$.  ,,ppp,|uEp^@Z@@@@EBEEZp          
                    ]pp5p(4BEp3$5B@EE@B$@BBB@p5UpM          
                    jE@pBB5p5Bp@5bP;p{53BBBBDBB@            
                     8M `I5|5EEEBU@4b55]BBU5EE(Ey           
                     'b  ',|@EBEBUE6@@$BBB|p,/`$@B          
      ,,              !'``T#p6EBBUEpBp65BBE^$^@uZ6N,        
 ,p -``:!pp,         !.,!@y58$EEBBEEEUpEBBM95P/^``$C        
        ^YEP;B,       4/@@E@B]H3BEE@EppBBM 4(*WQ,A!b        
           !' |Bw   , ,/ZE3EBBHEE6@@EEBM   E^Z`|3+@@        
             ' `e!h ,8EbEEEM,B`($EE@E6H    'Zp/ZEE@'        
              `!`.em@@(uB'``,`Y@EEEEEB      j@P5]EBw,       
                ` ,/'^U^ @ @P;ZZKEEB`         Z`u!E^,b@p@w  
           ,,=@uw@P,]EEbppppBBM^             '9Nq@@~(C'9w ' 
            ]^ ]B` AM^                                      

      ▄▀▀▀▀▄    ▄▀▀█▄   ▄▀▀▄ ▄▀▄  ▄▀▀█▄▄▄▄  ▄▀▀▄▀▀▀▄  ▄▀▀█▄  
     █         ▐ ▄▀ ▀▄ █  █ ▀  █ ▐  ▄▀   ▐ █   █   █ ▐ ▄▀ ▀▄ 
     █    ▀▄▄    █▄▄▄█ ▐  █    █   █▄▄▄▄▄  ▐  █▀▀█▀    █▄▄▄█ 
     █     █ █  ▄▀   █   █    █    █    ▌   ▄▀    █   ▄▀   █ 
     ▐▀▄▄▄▄▀ ▐ █   ▄▀  ▄▀   ▄▀    ▄▀▄▄▄▄   █     █   █   ▄▀  
     ▐         ▐   ▐   █    █     █    ▐   ▐     ▐   ▐   ▐   
                       ▐    ▐     ▐                          


Process 76281 stopped
* thread #1: tid = 0x719e70, 0x00007fff8cd7ad32 libsystem_c.dylib`strlen + 18, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff8cd7ad32 libsystem_c.dylib`strlen + 18
libsystem_c.dylib`strlen:
->  0x7fff8cd7ad32 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fff8cd7ad36 <+22>: pmovmskb %xmm0, %esi
    0x7fff8cd7ad3a <+26>: andq   $0xf, %rcx
    0x7fff8cd7ad3e <+30>: orq    $-0x1, %rax
(lldb) bt
* thread #1: tid = 0x719e70, 0x00007fff8cd7ad32 libsystem_c.dylib`strlen + 18, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff8cd7ad32 libsystem_c.dylib`strlen + 18
    frame #1: 0x0000000100001f92 TutorialLevel1`ReadParameterFile(char const*) [inlined] std::__1::char_traits<char>::length(__s=0x0000000000000000) + 8 at string:640
    frame #2: 0x0000000100001f8a TutorialLevel1`ReadParameterFile(char const*) [inlined] std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(this=<unavailable>) at string:2001
    frame #3: 0x0000000100001f8a TutorialLevel1`ReadParameterFile(char const*) [inlined] std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(char const*) at string:1999
    frame #4: 0x0000000100001f8a TutorialLevel1`ReadParameterFile(inputname=0x0000000000000000) + 1018 at TutorialLevel1.C:57
    frame #5: 0x0000000100000b49 TutorialLevel1`main(argc=<unavailable>, argv=0x00007fff5fbff7f0) + 89 at TutorialLevel1.C:17
    frame #6: 0x00007fff8cbac5ad libdyld.dylib`start + 1

Problem with C++11 libraries on OS X El Capitan 10.11

Hi,

I cannot compile gappa on my mac using the Makefile provided. The problem is that when it calls python/setup.py, first of all it does not have any link to c++11 libraries and I get:

../src/Radiation.C:1561:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]

then, if I add the extra arguments to setup.py:
extra_compile_args.append('-std=c++11 -stdlib=libc++')

the compiler does not recognize the c++11 libraries and I get:
error: invalid value 'c++11 -stdlib=libc++' in '-std=c++11 -stdlib=libc++'

it is very weird, because if I copy in the command line the command that setup.py is trying to run, it works without any problem. I tried using exactly the same compiler inside setup.py as the one I use in the command line, but it still works for the command line and it does not work for setup.py.

Installation Troubles

A couple of install problems on macOS Catalina -

  1. "pkgconfig" was needed and not listed
  2. Needed to add:
extra_compile_args.append('-stdlib=libc++')
extra_link_args.append('-stdlib=libc++')

to setup.py

for better compatibility for c++

I think It's better

  • not using namespace std in headers. using std::vector instead.
  • all headers should mv to include/gamera/... for example #include <gamera/Utils.h>
  • using constexpr double insteadof #define
    But I don't know if this is suitable for python and if there is a bug using swig if I modify the headers

Make python3 compatible

Swig does all the wrapping. Currently, the flags are

-python -c++ -py3 -nosafecstrings

Running a python script with the package results in a crash, e.g.:

$ python3 docu/tutorial/TutorialLevel2.py docu/tutorial/TutorialLevel2Params.dat
Traceback (most recent call last):
File "docu/tutorial/TutorialLevel2.py", line 6, in
import gamerapy
File "/home/joachim/Documents/Arbeit/GAMERAGIT/lib/gamerapy.py", line 28, in
_gamerapy = swig_import_helper()
File "/home/joachim/Documents/Arbeit/GAMERAGIT/lib/gamerapy.py", line 24, in swig_import_helper
_mod = imp.load_module('_gamerapy', fp, pathname, description)
File "/usr/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: /home/joachim/Documents/Arbeit/GAMERAGIT/lib/_gamerapy.so: undefined symbol: PyClass_Type

Mac build fail

I get this error when I try to compile Gamerapy:

$ make gamerapy
cd python;\
    swig -python -c++ -nosafecstrings -outdir ../lib -o _gamerapy.cc gamerapy.i;\
    python setup.py build_ext --build-lib ../lib;\
    cd ..;\

running build_ext
building '_gamerapy' extension
creating build
creating build/temp.macosx-10.11-x86_64-3.4
creating build/src
/usr/bin/clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Os -I../include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c _gamerapy.cc -o build/temp.macosx-10.11-x86_64-3.4/_gamerapy.o -std=c++11 -L/opt/local/lib -lgsl -lgslcblas -lm
clang: warning: argument unused during compilation: '-L/opt/local/lib -lgsl -lgslcblas -lm'
In file included from _gamerapy.cc:3146:
./../include/Radiation.h:9:10: fatal error: 'gsl/gsl_sf_bessel.h' file not found
#include <gsl/gsl_sf_bessel.h>
         ^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

Somehow your python/setup.py is wrong, the linker flags are passed to the compile step:

$ cd python/
$ /usr/bin/clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Os -I../include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c _gamerapy.cc -o build/temp.macosx-10.11-x86_64-3.4/_gamerapy.o -std=c++11 -L/opt/local/lib -lgsl -lgslcblas -lm
clang: warning: -lgsl: 'linker' input unused
clang: warning: -lgslcblas: 'linker' input unused
clang: warning: -lm: 'linker' input unused
clang: warning: argument unused during compilation: '-L/opt/local/lib'
In file included from _gamerapy.cc:3146:
./../include/Radiation.h:9:10: fatal error: 'gsl/gsl_sf_bessel.h' file not found
#include <gsl/gsl_sf_bessel.h>
         ^
1 error generated.

Looks like on travis-ci gsl-config isn't found:

gsl-config: Command not found

https://travis-ci.org/JoachimHahn/GAMERA/jobs/91447338#L2321
https://travis-ci.org/JoachimHahn/GAMERA/jobs/91447340#L2320
https://github.com/JoachimHahn/GAMERA/blob/master/.travis.yml#L11

I'm not a homebrew user, probably you'll have to add it's location to the PATH?
http://stackoverflow.com/questions/10343834/homebrew-wants-me-to-amend-my-path-no-clue-how

Let me know if you can't figure the setup.py stuff out, we could have a look tomorrow evening.

PyPI package for GAMERA

Python users want to install package via pip install or conda install.

It's some work to make this possible (basically you have to write a more extensive setup.py file) and create Python and conda packages.

To get started you could reserve a package name on PyPI (make a free accound and fill out a web form).
gamera is already taken: https://pypi.python.org/pypi/gamera/
So gamerapy might be the best choice if you want to stick with gamera for the project and C++ library.

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.