Skip to content

Data loaders need prioritization to resolve multiple matches #171

@sean-lockwood

Description

@sean-lockwood

When trying to associate an identifier with my particular type of FITS file, the loader cannot decide between the generic FITS loader and my STIS-specific FITS loader.

IORegistryError: Format is ambiguous - options are: cubetest1, stis-format, tabular-fits

Location of error in AstroPy source code

My identifier:

# Define an optional identifier. If made specific enough, this circumvents the
# need to add `format="my-format"` in the `Spectrum1D.read` call.
def identify_stis_fits(origin, *args, **kwargs):
    from astropy.io import fits
    import os
    import six
    
    if isinstance(args[0], six.string_types) and (os.path.splitext(args[0].lower())[1] == '.fits'):
        with fits.open( args[0]) as f:
            return f[0].header.get('INSTRUME', '') == 'STIS'
    else:
        return False

Glue gets around this by allowing the specification of loader priorities.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions