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

Error on gta.setup(): cannot reshape array of size 240000 into shape (26,50,50) #592

Open
AnaMartinheira opened this issue May 24, 2024 · 2 comments
Assignees

Comments

@AnaMartinheira
Copy link

Describe the error
I'm using the data with these parameters:

spacecraft_name = 'L240508112131F3944B7045'
source_ra = 143.89
source_dec = -36.77
roi_width = 10
e_min = 500
e_max = 1000000
z_max = 100
t_min = 239557417
t_max = 673458221

And the lt_cube.fits file was generated using these parameters:

my_apps.expCube['dcostheta'] = 0.025
my_apps.expCube['binsz'] = 1
my_apps.expCube['zmin'] = 0
my_apps.expCube['zmax'] = 100

To Reproduce

A notebook script with the error and the necessary files are in this link.

Expected behavior
To run the gta command right. If I decrease the maximum energy in the config.yaml, then the gta analysis command goes through fine.

Log files

2024-05-24 17:52:34 INFO    GTAnalysis.__init__(): 
--------------------------------------------------------------------------------
fermipy version 1.2.2 
ScienceTools version 2.2.0
2024-05-24 17:52:34 INFO    GTAnalysis.setup(): Running setup.
2024-05-24 17:52:34 INFO    GTBinnedAnalysis.setup(): Running setup for component 00
2024-05-24 17:52:34 INFO    GTBinnedAnalysis._select_data(): Skipping data selection.
2024-05-24 17:52:34 INFO    GTBinnedAnalysis.setup(): Using external LT cube.
{'Prefactor': 0, 'Index1': 1, 'Scale': 2, 'Cutoff': 3, 'Index2': 4}
2024-05-24 17:52:35 INFO    GTBinnedAnalysis._create_expcube(): Skipping gtexpcube.
WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2001-01-01T00:01:04.184' from MJDREF.
Set MJD-OBS to 54682.655283 from DATE-OBS.
Set MJD-END to 59704.655278 from DATE-END'. [astropy.wcs.wcs]
2024-05-24 17:52:35 INFO    GTBinnedAnalysis._create_srcmaps(): Skipping gtsrcmaps.
2024-05-24 17:52:35 INFO    GTBinnedAnalysis.setup(): Finished setup for component 00
2024-05-24 17:52:35 INFO    GTBinnedAnalysis._create_binned_analysis(): Creating BinnedAnalysis for component 00.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[28], line 3
      1 gta = GTAnalysis('config.yaml')
      2 matplotlib.interactive(True)
----> 3 gta.setup()
      4 gta.write_roi('fit0')

File [~/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py:1090](http://localhost:8888/home/anavitoriam/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py#line=1089), in GTAnalysis.setup(self, init_sources, overwrite, **kwargs)
   1087     c.setup(overwrite=overwrite)
   1089 # Create likelihood
-> 1090 self._create_likelihood()
   1092 # Determine tmin, tmax
   1093 for i, c in enumerate(self._components):

File [~/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py:1122](http://localhost:8888/home/anavitoriam/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py#line=1121), in GTAnalysis._create_likelihood(self, srcmdl)
   1120 self.like.model = self.like.components[0].model
   1121 self._fitcache = None
-> 1122 self._init_roi_model()

File [~/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py:1136](http://localhost:8888/home/anavitoriam/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py#line=1135), in GTAnalysis._init_roi_model(self)
   1134 proj_type = 0
   1135 for c, crd in zip(self.components, rm['components']):
-> 1136     cm = c.counts_map()
   1137     wm = c.weight_map()
   1138     cmaps += [cm]

File [~/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py:4948](http://localhost:8888/home/anavitoriam/mambaforge/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py#line=4947), in GTBinnedAnalysis.counts_map(self)
   4946 if p_method == 0:  # WCS
   4947     z = cmap.data()
-> 4948     z = np.array(z).reshape(self.enumbins, self.npix[1], self.npix[0])
   4949     return WcsNDMap(copy.deepcopy(self.geom), z)
   4950 elif p_method == 1:  # HPX

ValueError: cannot reshape array of size 240000 into shape (26,50,50)

Environment (please complete the following information):

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Additional context
Add any other context about the problem here.

@ndilalla
Copy link
Contributor

ndilalla commented May 24, 2024

Hi @AnaMartinheira I tried your notebook but I seem to be missing the file srcmap_00.fits. Can you upload it? What version of fermipy are you running?

@ndilalla ndilalla self-assigned this May 24, 2024
@AnaMartinheira
Copy link
Author

AnaMartinheira commented May 25, 2024

Thanks for the quick response, I thought that file was generated by the gta.setup() command and that's why I didn't upload it.
Here it is: link
My fermipy version is 1.2.2.

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