convert_region

ndmapper.utils.convert_region(region, convention)[source] [edit on github]

Convert a NumPy- or FITS-style region string into a tuple of integers and Python slice objects that is suitable for subscripting arrays.

Some corner cases (eg. involving ‘*’, ‘:’ or steps) currently behave differently from Python/IRAF subscripting but should be fairly harmless.

Parameters:

region : str

Region string, eg. ‘100:110,50:60’, ‘100,*’ or ‘:,99’.

convention : str

Indexing convention used: ‘NumPy’ (default) or ‘FITS’; case insensitive.