lpsinger / ligo.skymap

Localization of gravitational-wave transients. Mirror of https://git.ligo.org/lscsoft/ligo.skymap
22 stars 18 forks source link

`ligo.skymap.moc.rasterize` fails with `S230529ay_rev4_Bilby.multiorder` #21

Closed simeonreusch closed 1 year ago

simeonreusch commented 1 year ago

Hi Leo, raising this here as I cannot open issues on the LVK gitlab.

When employing the ligo.skymap.moc.rasterize function to convert the Bilby multiorder map of S230529A from NUNIQ to NESTED, I get the following error (probably from your C implementation of the rasterize function):

GSL function failed: not enough memory to allocate image (errnum=8)
XLAL Error - <GSL function> (src/bayestar_moc.c:127): Generic failure
Traceback (most recent call last):
  File "/Users/simeon/nuztf/test_rasterize.py", line 31, in <module>
    probs = rasterize(data)
  File "/Users/simeon/miniconda3/envs/nuztf/lib/python3.10/site-packages/ligo/skymap/moc.py", line 161, in rasterize
    return _rasterize(moc_data, order=order)
MemoryError: Out of memory

Note that out of memory is not correct, I monitored my RAM and there is plenty available, and it does not fill up during code execution.

I have attached a minimal example and the skymap (zipped to upload here) to reproduce the error (Robert Stein also encountered this on his machine, we both use ARM Macs)

code_and_skymap.zip

lpsinger commented 1 year ago

Try this instead:

from ligo.skymap.io import read_sky_map
from ligo.skymap.moc import rasterize

skymap_path = "S230529ay_rev4_Bilby.multiorder.fits,0"
data = read_sky_map(skymap_path, moc=True)

data_nested = rasterize(data)