gammapy
gammapy copied to clipboard
Support for IRF file format evolution
IRF files will likely evolve in time as new dimensions or keywords are added to keep up with pipeline developments. Therefore it is necessary to think now about how to handle this evolution.
For IRFs (and really any other support file), it would be nice to make theread()
and write()
methods of the IRF classes use reader/write code based on the version number in the file so that the same interface can be used even if the IRF format evolves in time. That implies also a format version number in the header.
Perhaps something like this is a simple solution:
@classmethod
def read(cls, filename):
version = get_irf_version_from_file(filename)
reader_dispatch = {
1: cls._read_v1,
2: cls._read_v2
}
return reader_dispatch.get(version)(filename)
Where read_v1()
and read_v2()
implement reading different format versions.
Or a more general piece of code could be developed to handle this for all file types.