Code Monkey home page Code Monkey logo

Comments (2)

cosimoNigro avatar cosimoNigro commented on July 19, 2024

Hi @jsitarek,

I already thought about this, this is why I left a integrator parameter in all the functions performing SED or absorption calculation.

At the moment you can basically choose between two methods: the np.trapz we actually use in most of the functions and this trapz_loglog I implemented in utils/math.py.
It is based on the same function implementation in naima
https://github.com/zblz/naima/blob/master/src/naima/utils.py#L291
and in gammapy
https://github.com/gammapy/gammapy/blob/master/gammapy/utils/integrate.py#L8
I tried to make it a more efficient but did not really manage.
The gammapy developers tell me a log-log integration allows you to have the same precision with a lower number of grid points.
It is not adaptive though.

There is actually a test function checking the two integration methods (np.trapz and trapz_loglog) against each other, for synch and inverse Compton processes:
synch_comparison_integration_methods
comparison_integration_methods
comparison_integration_methods

I just wanted to say that I already started to think about this 😉, but let's discuss more!

from agnpy.

jsitarek avatar jsitarek commented on July 19, 2024

Hi @cosimoNigro
I realized one more problem with those integrals. They take really increadible amount of system memory.
If you want to compute EC SED over 500 gamma values, 100 mu values and 50 phi values for 100 energies, even with 4 bytes per number it would already end up in 1 GB of memory, and I think in reality python is using much more, because during tests I was running out of memory of a 16 GB machine.
I think we should consider some integration method that takes as a parameter not a grid of points, but a function and boundaries. This will take much less memory and most probably will be also much faster.

from agnpy.

Related Issues (20)

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.