Code Monkey home page Code Monkey logo

Comments (3)

cosimoNigro avatar cosimoNigro commented on July 1, 2024

Hi @jsitarek,
thanks for reporting, very strange that is not matched by the tests.
I just pulled the latest version and executed all the tests, they work.
I will take another look executing your snippet.

from agnpy.

cosimoNigro avatar cosimoNigro commented on July 1, 2024

Hi @jsitarek,
to me it works with the latest version of the code.
I have cleaned your snippet, please next time post a more ordered snipppet 😜

import numpy as np
import math
import astropy.units as u
import astropy.constants as const
from astropy.coordinates import Distance
from agnpy.emission_regions import Blob
from agnpy.synchrotron import Synchrotron
from agnpy.utils.plot import plot_sed
import matplotlib.pyplot as plt

z = 0.94 # redshift
delta_D = 15
Gamma = 15
theta = 1. / Gamma
spectrum_norm2 = 2.e-7 * u.Unit("erg cm-3")
B2 = np.sqrt(spectrum_norm2.value * 8 * np.pi) * u.G
gmin2 = 2. # minimum Lorentz factor
xi2 = 3.e-10 # acceleration parameter
dist2 = 100 * 3.e18 * u.cm # distance of the blob
p1_2 = 2.0
p2_2 = p1_2 + 1

radius2 = dist2 * theta

gbreak = 43.e3 # tentative values
gmax = 43.e3 # tentative values
parameters2 = {
    "p1": p1_2,
    "p2": p2_2,
    "gamma_b": gbreak,
    "gamma_min": gmin2,
    "gamma_max": gmax,
}
spectrum_dict2 = {"type": "BrokenPowerLaw", "parameters": parameters2}
blob2 = Blob(radius2, z, delta_D, Gamma, B2, spectrum_norm2, spectrum_dict2, xi=xi2)

nu = np.logspace(8, 28, 100) * u.Hz
synch2 = Synchrotron(blob2, ssa=True)
# let us compute synchrotron SED
synch_sed2 = synch2.sed_flux(nu)
# let us plot it
plot_sed(nu, synch_sed2)
plt.show()

Figure_1

Can you try:

cd agnpy
git pull origin master
python -m pip install .

this will install the development agnpy version in your miniconda base environment

In [1]: import agnpy
In [2]: agnpy.__file__
Out[2]: '/home/cosimo/software/miniconda3/lib/python3.7/site-packages/agnpy/__init__.py'

you can un-install it any moment with pip

cosimo@posimo:~$ pip uninstall agnpy
Found existing installation: agnpy 0.0.8
Uninstalling agnpy-0.0.8:
  Would remove:
    /home/cosimo/software/miniconda3/lib/python3.7/site-packages/agnpy-0.0.8.dist-info/*
    /home/cosimo/software/miniconda3/lib/python3.7/site-packages/agnpy/*
Proceed (y/n)? y
  Successfully uninstalled agnpy-0.0.8

I recommend you stop using sys.path.append.

from agnpy.

jsitarek avatar jsitarek commented on July 1, 2024

Hi @cosimoNigro,

Thx for checking and sorry for a messy code example.
I checked the snippet again and mysteriously it works now, I have no idea what happened here, I will check again my on laptop at home, maybe I screwed up something with the code there.
I checked also the other issue #75 since it was reporting also a similarly looking problem, but it seems to be something else there.

About sys.path.append I'm using two versions of agnpy, the current one, and some older one which had some differences in API, and also having both was good for tests, and this was the simplest way to switch between them.
Installing it via pip is convenient for the user, but then if I install it via pip I guess I would have to reinstall it after every modification of the code, or modify directly the installed code and then for commits move those files back to git directory. Or does it just install links to git directory?

Let me close the issue now, if I find out what happened that caused the original problem I will let you know, and sorry again for wasting your time on checking it.

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.