@data_factory(label='CASA PPV Cube', identifier=is_casalike)
def casalike_cube(filename, **kwargs):
    from astropy.io import fits

    result = Data()

    if 'ignore_missing_end' not in kwargs:
        kwargs['ignore_missing_end'] = True

    with fits.open(filename, **kwargs) as hdulist:
        array = hdulist[0].data
        header = hdulist[0].header
    result.coords = coordinates_from_header(header)
    for i in range(array.shape[0]):
        result.add_component(array[[i]], label='STOKES %i' % i)
    return result
This provides special support for 4D CASA FITS - like cubes,
dataset/ETHPy150Open glue-viz/glue/glue/core/data_factories/fits.py/casalike_cube