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

Disable track_overflow in PointSourceResponse #285

Open
hiyoneda opened this issue Jan 23, 2025 · 0 comments
Open

Disable track_overflow in PointSourceResponse #285

hiyoneda opened this issue Jan 23, 2025 · 0 comments
Labels

Comments

@hiyoneda
Copy link
Contributor

Currently, track_overflow is set to True when generating an instance of PointSourceResponse. I think that track_overflow should always be False because the under/overflow bins will not be used in the response files.

Probably, we can simply add these lines in PointSourceResponse:

   def __init__(self, *args, **kwargs):
        """
        Initialize a PointSourceResponse object.
        """
        # Not to track the under/overflow bins
        kwargs['track_overflow'] = False

        super().__init__(*args, **kwargs)

But when I tried this change and tested it, it caused errors in the unit test.

________________________________________________________ test_inject_point_source_saving ________________________________________________________

    def test_inject_point_source_saving():

        # defind the response and orientation
        response_path = test_data.path / "test_precomputed_response.h5"

        # powerlaw model
        index = -2.2
        K = 17 / u.cm / u.cm / u.s / u.keV
        piv = 1 * u.keV
        spectrum = Powerlaw()
        spectrum.index.value = index
        spectrum.K.value = K.value
        spectrum.piv.value= piv.value
        spectrum.K.unit = K.unit
        spectrum.piv.unit = piv.unit

        # Define an injector by the response
        injector = SourceInjector(response_path = response_path, response_frame = "galactic")

        # Define the coordinate of the point source
        source_coord = SkyCoord(l = 50, b = -45, frame = "galactic", unit = "deg")

        # Get the data of the injected source
>       injected_crab_signal = injector.inject_point_source(spectrum = spectrum, coordinate = source_coord,
                                                            source_name = "point_source",
                                                            make_spectrum_plot = False, data_save_path = Path("./galactic_rsp.h5"),
                                                            project_axes = "Em")

tests/source_injector/test_source_injector.py:112:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cosipy/source_injector/source_injector.py:136: in inject_point_source
    psr = SourceInjector.get_psr_in_galactic(coordinate = coordinate, response_path = self.response_path, spectrum = spectrum)
cosipy/source_injector/source_injector.py:81: in get_psr_in_galactic
    psr = PointSourceResponse(axes[1:], f['hist/contents'][pix+1], unit = f['hist'].attrs['unit'])
cosipy/response/PointSourceResponse.py:41: in __init__
    super().__init__(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

1 participant