def _get_axis_idx(header, axis_name):
    """Return the axis number of the given axis."""
    axes = ['right ascension', 'declination', 'stokes', 'frequency']
    assert axis_name.lower() in axes, "Unknown `axis_name`."
    for ax in range(1, len(axes)+1):
        key = 'ctype{:d}'.format(ax)
        if header[key].lower() == axis_name.lower():
            return ax
    raise ValueError("Cannot find requested axis in the image.")