amaurea / enlib

5 stars 12 forks source link

`enmap.submap` produces `ValueError` #19

Closed msyriac closed 7 years ago

msyriac commented 7 years ago

I can't seem to be able to do a simple submap selection

from enlib import enmap
import numpy as np

shape,wcs = enmap.get_enmap_patch(width_arcmin=2*60,px_res_arcmin=0.5)
imap = enmap.ndmap(np.empty(shape),wcs)
print imap.box()*180./np.pi

sbox = np.array([[-0.5,-0.5],[0.5,0.5]])*np.pi/180.
smap = imap.submap(sbox)
print smap.box()*180./np.pi

results in


ERROR: ValueError: operands could not be broadcast together with shapes (3,) (2,)  [enlib.enmap]
Traceback (most recent call last):
  File "tests/slice.py", line 9, in <module>
    smap = imap.submap(sbox)
  File "/astro/u/msyriac/repos/enlib/enmap.py", line 126, in submap
    ibox = self.subinds(box, inclusive)
  File "/astro/u/msyriac/repos/enlib/enmap.py", line 150, in subinds
    ibox[:,1] = np.minimum(ibox[:,1],self.shape[-2:])
ValueError: operands could not be broadcast together with shapes (3,) (2,) 

This bug seems to have been introduced with this commit: https://github.com/amaurea/enlib/commit/d1b91bed9e0d4fb9ec2053e43a578de7cab5e8a0

If I don't do the cap=True bit I get the expected behaviour.

msyriac commented 7 years ago

Fixed with recent commit to master by amaurea. Closing.