datacamp-astro / 2022-arqus-bergen

0 stars 0 forks source link

3_spectrum #8

Open micheledoro opened 2 years ago

micheledoro commented 2 years ago

Hi @ibatkovi I am trying to run the script and at the step in which you load the modules I have the error

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/var/folders/b4/206k7jy123760vx_14btyhlw0000gn/T/ipykernel_39957/3537657737.py in <module>
      5 #from gammapy.utils.random import get_random_state
      6 from gammapy.maps import MapAxis, WcsGeom, Map, RegionGeom
----> 7 from gammapy.makers import SafeMaskMaker, MapDatasetMaker, SpectrumDatasetMaker, ReflectedRegionsBackgroundMaker, WobbleRegionsFinder
      8 from gammapy.estimators import FluxPointsEstimator
      9 

ImportError: cannot import name 'WobbleRegionsFinder' from 'gammapy.makers' (/Users/mdoro/opt/anaconda3/envs/gammapy019/lib/python3.9/site-packages/gammapy/makers/__init__.py)

I am using gammapy 0.19

Also, considering it is for students, can you add more 'markdown' text to explain all the steps of the analysis, what does the script do, etc? This can be done later on of course, but still before the schoo.

ibatkovi commented 2 years ago

Dear Michele,

The error is coming from the version of gammapy. 'WobbleRegionsFinder' is introduced in gammapy-0.20. I wrote in the README.md that version 0.20 is needed.

Cheers, Ivana

On Thu, 25 Aug 2022 at 15:01, Michele Doro @.***> wrote:

Hi @ibatkovi https://github.com/ibatkovi I am trying to run the script and at the step in which you load the modules I have the error


ImportError Traceback (most recent call last) /var/folders/b4/206k7jy123760vx_14btyhlw0000gn/T/ipykernel_39957/3537657737.py in 5 #from gammapy.utils.random import get_random_state 6 from gammapy.maps import MapAxis, WcsGeom, Map, RegionGeom ----> 7 from gammapy.makers import SafeMaskMaker, MapDatasetMaker, SpectrumDatasetMaker, ReflectedRegionsBackgroundMaker, WobbleRegionsFinder 8 from gammapy.estimators import FluxPointsEstimator 9

ImportError: cannot import name 'WobbleRegionsFinder' from 'gammapy.makers' (/Users/mdoro/opt/anaconda3/envs/gammapy019/lib/python3.9/site-packages/gammapy/makers/init.py)

I am using gammapy 0.19

Also, considering it is for students, can you add more 'markdown' text to explain all the steps of the analysis, what does the script do, etc? This can be done later on of course, but still before the schoo.

— Reply to this email directly, view it on GitHub https://github.com/arqus-gamma/arqus_school_2022/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASRO4AUS25GJDBDEL52DFULV25VDLANCNFSM57TAX6AQ . You are receiving this because you were mentioned.Message ID: @.***>

ibatkovi commented 2 years ago

Hi @micheledoro and @giacomodamico24 ,

I was checking the files a bit and thinking about how to do the spectral analysis with only using fits files without gammapy. I am a bit confused, should we then calculate the flux points or not? Up to what extent I should go with the data analysis? In the hdu and obs index files I can access the irfs and observational data, but should I use them to calculate the flux, I am not sure how to extract them.

giacomodamico24 commented 2 years ago

Hi @ibatkovi you can find here https://github.com/arqus-gamma/arqus_school_2022/blob/main/hands_on/3_spectrum/Spectrum_no_gammapy_test.ipynb

a first attempt to get the flux without using gammapy, but only astropy.

I made a few naive assumptions for this first attempt, like neglecting the background and ignoring the exposure time.

Let me know if you are any comments or doubts.

giacomodamico24 commented 2 years ago

Hi @ibatkovi @micheledoro

I manage to get the Crab flux by only using astropy. Considering that I used just 1 run of ~ 20 mins I think that the result is very nice

image

You can check the whole procedure (plus extra things) here:

https://github.com/arqus-gamma/arqus_school_2022/blob/main/hands_on/3_spectrum/Spectrum_no_gammapy_test.ipynb

ibatkovi commented 2 years ago

Hi Giacomo,

Thank you a lot, I will check it and try to rin it tomorrow, I am on my way to Padova right now.

Cheers, Ivana

On Sat, 27 Aug 2022, 16:24 giacomodamico24, @.***> wrote:

Hi @ibatkovi https://github.com/ibatkovi @micheledoro https://github.com/micheledoro

I manage to get the Crab flux by only using astropy. Considering that I used just 1 run of ~ 20 mins I think that the result is very nice

[image: image] https://user-images.githubusercontent.com/22915518/187034470-d85b16e5-1b0d-45ce-8c63-70cb70b44fa5.png

You can check the whole procedure (plus extra things) here:

https://github.com/arqus-gamma/arqus_school_2022/blob/main/hands_on/3_spectrum/Spectrum_no_gammapy_test.ipynb

— Reply to this email directly, view it on GitHub https://github.com/arqus-gamma/arqus_school_2022/issues/8#issuecomment-1229202217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASRO4AU6MFF4O46EQNMGRSTV3IQK7ANCNFSM57TAX6AQ . You are receiving this because you were mentioned.Message ID: @.***>

giacomodamico24 commented 2 years ago

I finally manage to get the comparison between gammapy and astropy. Here it is:

image image image image
micheledoro commented 2 years ago

Interesting. I believe it is more than satisfactory, although I am not sure i can explain the differences, e/g/ at the point at 10 TeV

micheledoro commented 2 years ago

I run it, all is ok expect the OBJECT field is not recognized by sky coord and the name of source must be input at hand, this is michele OBJECT is CrabNebula without space.

Missing is

giacomodamico24 commented 2 years ago

I have finished cleaning up the notebook https://github.com/arqus-gamma/arqus_school_2022/blob/main/hands_on/3_spectrum/Spectral_analysis.ipynb

I was thinking to give the student the exercise consisting in re-doing everything on a new source and check if the result is consistent with the expected one from a given reference.