telegraphic / pygdsm

Python interface to Global Diffuse Sky Models (GDSM) for the radio sky between 10 MHz - 5 THz
MIT License
30 stars 7 forks source link

IndexError in get_sky_temperature when initialize GlobalSkyModel2016 with resolution='low' #8

Closed FurenDeng closed 2 years ago

FurenDeng commented 2 years ago

I found that in class GlobalSkyModel2016, the self.nside is hard coded as 1024, which is not compatible when resolution='low'. The get_sky_temperature will use self.nside to find the indices of pixels, and thus will produce IndexError. The code that produce the error will be like:

#%%
from pygdsm import GlobalSkyModel, GlobalSkyModel2016
from astropy.coordinates import SkyCoord
import numpy as np

#%%

ra = np.linspace(175, 185, 101)
dec = np.linspace(20, 30, 101)
freq = np.linspace(700, 800, 21)
coord = SkyCoord(ra=ra, dec=dec, unit='deg', frame='icrs')
# %%
gsm16 = GlobalSkyModel2016(resolution='low')
Tsky = gsm16.generate(freqs=freq)
# %%
gsm16.view(0, True)
# %%
patch = gsm16.get_sky_temperature(coord)

and the output:

IndexError: index 302869 is out of bounds for axis 1 with size 49152
telegraphic commented 2 years ago

That was silly, thanks @FurenDeng, I've just pushed a quick fix.