Closed landmanbester closed 4 years ago
Probably caused because weights is a dask array
while imaging_weights
is a xarray DataArray.
Also IMAGING_WEIGHT is getting default dimension labels (IMAGING_WEIGHT-1, IMAGING_WEIGHT-2) which don't correspond to the usual (row, chan, corr).
I would recommend dealing with it all in dask or xarray land.
Sorry, I missed the .data on
imaging_weights = getattr(ds, self.imaging_weight_column).data
I now get
Traceback (most recent call last):
File "/home/landman/venvs/pfbenv/bin/ssclean.py", line 7, in <module>
exec(compile(f.read(), __file__, 'exec'))
File "/home/landman/Projects/pfb-clean/scripts/ssclean.py", line 457, in <module>
main(args)
File "/home/landman/Projects/pfb-clean/scripts/ssclean.py", line 170, in main
psf_array = R.make_psf()
File "/home/landman/Projects/pfb-clean/pfb/operators/gridder.py", line 348, in make_psf
weights = weightsxx + weightsyy
File "/home/landman/venvs/pfbenv/lib/python3.6/site-packages/dask/array/core.py", line 1814, in __add__
return elemwise(operator.add, self, other)
File "/home/landman/venvs/pfbenv/lib/python3.6/site-packages/dask/array/core.py", line 3886, in elemwise
broadcast_shapes(*shapes)
File "/home/landman/venvs/pfbenv/lib/python3.6/site-packages/dask/array/core.py", line 3847, in broadcast_shapes
"shapes {0}".format(" ".join(map(str, shapes)))
ValueError: operands could not be broadcast together with shapes (758160, 0, 4) (758160, 31, 4)
Any quick fixes you can recommend?
Its probably failing because of the 0 in dimension 2 of the first shape. It should be a 1,
I think the None
in the slicing might be causing this.
None should introduce an extra dimension of size 1 though!
That is true, but I have never really embraced broadcast_to because it always fights me.
Though isn't this bug coming from weights = weightsxx + weightsyy
?
weightsxx = imaging_weights[:, : 0] * weights[:, : 0]
weightsyy = imaging_weights[:, : -1] * weights[:, : -1]
I think your slicing is broken here?
[:, :0]
will be empty.
weightsxx = imaging_weights[:, : 0] * weights[:, : 0] weightsyy = imaging_weights[:, : -1] * weights[:, : -1]
I think your slicing is broken here?
Good catch!
Oh, haha. Thanks
Thanks for the quick support @sjperkins and @JSKenyon
I am trying to add an option to apply additional imaging weights as requested in https://github.com/ratt-ru/pfb-clean/issues/30. I am running into a problem when trying to combine WEIGHT and IMAGING_WEIGHT_SPECTRUM because they do not have the same dimensions. When I try to broadcasts WEIGHTS over frequency axis and combine them with IMAGING_WEIGHT_SPECTRUM, i.e. doing something like
results in the following error
which I guess happens because broadcast_to doesn't actually make a copy for each channel. Any ideas on this @sjperkins?