Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem about load_absorption_table in class EBL #142

Open
huangylei opened this issue May 3, 2023 · 2 comments
Open

Problem about load_absorption_table in class EBL #142

huangylei opened this issue May 3, 2023 · 2 comments

Comments

@huangylei
Copy link

I've found differences in the EBL absorption(with Saldana-Lopez model) between agnpy and the data released by Saldana-Lopez.

Then I checked the function load_absorption_table and found that all the models use np.unique() to return the sorted unique elements of an array. However, we don't need to sort data in Saldana-Lopez model.

@cosimoNigro
Copy link
Owner

cosimoNigro commented May 9, 2023

@huangylei, thanks a lot for reporting this.
I will make a fix soon.

Do you have a snippet to show the issue you are reporting?
The interpolated values are checked against the original table values in the tests, so I am surprised by this.

Thanks again.

@huangylei
Copy link
Author

I used the table that Saldana-Lopez provided, and compared it with the result by agnpy. They are different. (Unfortunately
I cannot find the code)

I checked the function load_absorption_table into:

def load_absorption_table(self):
        """load the reference values from the table file to be interpolated later"""
        f = fits.open(self.model_file)
        self.energy_ref = (
            np.sqrt(f["ENERGIES"].data["ENERG_LO"] * f["ENERGIES"].data["ENERG_HI"])
            * u.keV
        )
        # Franceschini file has two columns repeated, eliminate them
        if self.model == "franceschini":
            self.z_ref = np.unique(f["SPECTRA"].data["PARAMVAL"])
            self.values_ref = np.unique(f["SPECTRA"].data["INTPSPEC"], axis=0)
        else:
            self.z_ref = f["SPECTRA"].data["PARAMVAL"]
            self.values_ref = f["SPECTRA"].data["INTPSPEC"]

It worked and perfectly match the result that Saldana-Lopez provided. After this change, the aborption should be:

截屏2023-05-23 17 10 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants