andreatramacere / jetset

JetSeT a framework for self-consistent modeling and fitting of astrophysical relativistic jets
BSD 3-Clause "New" or "Revised" License
30 stars 15 forks source link

setting the size of the frequency grid #37

Closed cosimoNigro closed 3 years ago

cosimoNigro commented 3 years ago

Hello @andreatramacere,

I would like to generate an SED with a fixed grid in nu, now if I try to set a value lower than 200 it is just ignored and an SED of 200 points is returned. Here a snippet:

from jetset.jet_model import Jet

pwl_jet = Jet(name="", electron_distribution="pl")
pwl_jet.set_nu_grid_size(50)
pwl_jet.show_model()
pwl_jet.eval()
pwl_synch_sed = pwl_jet.get_spectral_component_by_name("Sync").get_SED_points()
# check how many SED points the we get
print(len(pwl_synch_sed[0]))

I get

200

despite in the show_model overview 50 is correctly reported

SED info:
 nu grid size :50
 nu mix (Hz): 1.000000e+06
 nu max (Hz): 1.000000e+30

Is 200 a hardcoded minimum you set? Thank you!

andreatramacere commented 3 years ago

Hi @cosimoNigro :), no it is not hardcoded. The grid is the grid used in the python interface to interpolate the values from all the components, in such a way that you can sum them without any problem. But there are two grids, one at level of the C code, and one at level of the python interface. the pwl_synch_sed = pwl_jet.get_spectral_component_by_name("Sync").get_SED_points() is returning the synch from the C code, evaluated over seed photons grid size=100 and interpolated over the full C-level grid of 200. To get the SED interpolated over python code use pwl_jet.spectral_components.Sync.SED.nu.

from jetset.jet_model import Jet

pwl_jet = Jet(name="", electron_distribution="pl")
pwl_jet.set_nu_grid_size(50)
pwl_jet.show_model()
pwl_jet.eval()
pwl_synch_sed = pwl_jet.get_spectral_component_by_name("Sync").get_SED_points()
# check how many SED points the we get
print(len(pwl_synch_sed[0]))
print(len(pwl_jet.spectral_components.Sync.SED.nu))`

you get

size of C-grid array 200
size of python-grid 50

The method .get_SED_points() is not reported in the documentation and I should move it as protected, because it should be used only internally to the code.

cosimoNigro commented 3 years ago

Ok perfect, this is what I wanted. Thanks! You can close the issue.