radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
98 stars 65 forks source link

Cube mosaicing: Expand capabilities substantially #868

Open keflavich opened 1 year ago

keflavich commented 1 year ago

the cube utils mosaic header maker wasn't checking the spectral dimension before

keflavich commented 1 year ago

Now branched off of #854

keflavich commented 1 year ago

This is largely reimplementing reproject/mosaicking/coadd.py, which is not good.

keflavich commented 1 year ago

Some of the functionality I want here needs to be pushed into coadd. Will split this into another PR.

keflavich commented 1 year ago

Dang, I thought I was getting somewhere.

Traceback (most recent call last):
  File "<ipython-input-1-349e0fbab013>", line 1, in <module>
    from aces.imaging.mosaic_12m import cs21_cube_mosaicing_minimal_test; cs21_cube_mosaicing_minimal_test()
  File "/orange/adamginsburg/ACES/reduction_ACES/aces/imaging/mosaic_12m.py", line 288, in cs21_cube_mosaicing_minimal_test
    result,_ = mosaic_cubes(cubes,
  File "/blue/adamginsburg/adamginsburg/repos/spectral-cube/spectral_cube/cube_utils.py", line 914, in mosaic_cubes
    output_array, output_footprint = reproject_and_coadd(
  File "/blue/adamginsburg/adamginsburg/repos/reproject/reproject/mosaicking/coadd.py", line 223, in reproject_and_coadd
    array, footprint = reproject_function(
  File "/blue/adamginsburg/adamginsburg/repos/astropy/astropy/utils/decorators.py", line 604, in wrapper
    return function(*args, **kwargs)
  File "/blue/adamginsburg/adamginsburg/repos/reproject/reproject/interpolation/high_level.py", line 121, in reproject_interp
    return _reproject_blocked(
  File "/blue/adamginsburg/adamginsburg/repos/reproject/reproject/utils.py", line 297, in _reproject_blocked
    output_array_dask = da.empty(shape_out, chunks=block_size or "auto")
  File "/blue/adamginsburg/adamginsburg/repos/dask/dask/array/wrap.py", line 60, in wrap_func_shape_as_first_arg
    parsed = _parse_wrap_args(func, args, kwargs, shape)
  File "/blue/adamginsburg/adamginsburg/repos/dask/dask/array/wrap.py", line 30, in _parse_wrap_args
    chunks = normalize_chunks(chunks, shape, dtype=dtype)
  File "/blue/adamginsburg/adamginsburg/repos/dask/dask/array/core.py", line 3106, in normalize_chunks
    raise ValueError(
ValueError: Chunks do not add up to shape. Got chunks=((4,), (5, 80, 101), (5, 100, 101)), shape=(4, 161, 152)
keflavich commented 1 year ago

It works with a simple test - but not with blocks yet

image
keflavich commented 1 year ago

I've been using this in production for a while. @e-koch, want to give it a once-over? Looks like I have some failing tests to fix, but I'm not sure if they're also failing on master

codecov[bot] commented 1 year ago

Codecov Report

Patch has no changes to coverable lines.

:exclamation: Current head e8083b7 differs from pull request most recent head 0cfcd02. Consider uploading reports for the commit 0cfcd02 to get more accurate results

Files Changed Coverage
spectral_cube/cube_utils.py 0.00%

:loudspeaker: Thoughts on this report? Let us know!.