def get_mag_ff(atomic_number, q, ion=0, j=0):
    """Returns the j0 magnetic form factor for a given atomic number,
    radiation and q values

    :param atomic_number: atomic number
    :type atomic_number: int
    :param q: value or values of q for which to get form factors
    :type q: float, list, :class:`numpy.ndarray`
    :param ion: charge of selected atom
    :type ion: int
    :param j: order of spherical Bessel function (0, 2, 4 or 6)
    :type j: int
    :return: magnetic form factor for given q
    :rtype: float, :class:`numpy.ndarray`

    :Examples:

    >>> get_mag_ff(8, q=2, ion=1)
    0.58510426376585045

    >>> get_mag_ff(26, q=[0.0, 3.5, 7.0], ion=2)
    array([ 1.        ,  0.49729671,  0.09979243])

    >>> get_mag_ff(26, q=[0.0, 3.5, 7.0], ion=4)
    array([ 0.9997    ,  0.58273549,  0.13948496])

    >>> get_mag_ff(26, q=[0.0, 3.5, 7.0], ion=4, j=4)
    array([ 0.       ,  0.0149604,  0.0759222])
    """
    import periodictable
    return getattr(periodictable.elements[atomic_number].magnetic_ff[ion], 
        'j' + str(j) + '_Q')(q)
