AlanLoh / nenupy

NenuFAR python package
MIT License
10 stars 6 forks source link

shape mismatch exception in MiniArray().beam() #72

Closed flomertens closed 3 months ago

flomertens commented 4 months ago

Using a recent (from git) version of nenupy, I got this exception when computing the beam gains in 1 direction, 1 pol, 1 frequency and 3 times:


Traceback (most recent call last):
    File "/home/users/mertens/soft/conda4/envs/py310/bin/modeltool", line 8, in <module>
      sys.exit(main())
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
      return self.main(*args, **kwargs)
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/click/core.py", line 1078, in main
      rv = self.invoke(ctx)
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
      return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
      return ctx.invoke(self.callback, **ctx.params)
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/click/core.py", line 783, in invoke
      return __callback(*args, **kwargs)
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/nenucal/tools/modeltool.py", line 65, in attenuate
      sky_model = skymodel.apply_nenufar_beam(sky_model, observing_time, coord_phase_dir, mfmhz)
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/nenucal/skymodel.py", line 82, in apply_nenufar_beam
      beam_pointing = compute_beam(ma, mfmhz, observing_time, coord_target, coord_target, [Polarization.NW, Polarization.NE])
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/nenucal/skymodel.py", line 62, in compute_beam
      return MiniArray(ma_number).beam(sky=sky, pointing=target_tracking, configuration=conf)
    File "/home/users/chege/.local/lib/python3.10/site-packages/nenupy/instru/nenufar.py", line 541, in beam
      return super().beam(
    File "/home/users/chege/.local/lib/python3.10/site-packages/nenupy/instru/interferometer.py", line 701, in beam
      np.array([gain(
    File "/home/users/chege/.local/lib/python3.10/site-packages/nenupy/instru/interferometer.py", line 701, in <listcomp>
      np.array([gain(
    File "/home/users/chege/.local/lib/python3.10/site-packages/nenupy/instru/nenufar.py", line 931, in _antenna_gain
      gain[:, :, i, :] = pol.value[sky]
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/dask/array/core.py", line 1926, in __setitem__
      dsk = setitem_array(out, self, key, value)
    File "/home/users/mertens/soft/conda4/envs/py310/lib/python3.10/site-packages/dask/array/slicing.py", line 1877, in setitem_array
      raise ValueError(
  ValueError: shape mismatch: value array of shape (1, 1, 3) could not be broadcast to indexing result of shape (3, 1, 1)

This was working with nenupy 2.4.6.

flomertens commented 3 months ago

Thanks Alan, it seams to have fixed my issue