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

Make the unified file type reader figure out pbcor, psf, model, etc. #770

Open keflavich opened 3 years ago

keflavich commented 3 years ago

Right now one has to specify format='casa_image' for any .image files that have non-.image suffixes, including: .pbcor, .psf, .weight, .pb, .model, .image.tt*, etc.

We should have these auto-recognized. Not doing so makes it impossible to use SpectralCube.read as a default reader in other functions without passing on kwargs, which can result in really ugly code.

Case in point - I wanted to write feather_simple_cube to replace the file_in method with SpectralCube.read, but can't b/c pbcor images break this:

def feather_simple_cube(hires, lores, **kwargs):
    if not hasattr(hires, shape):
        hires = SpectralCube.read(hires)
    if not hasattr(hires, shape):
        lores = file_in(lores)