def _internal_ion_fraction_field(field, data):
    """
    Creates the function for a derived field for following the ion_fraction
    of an ion over a dataset when the number density and nuclei_density for
    that field are already defined on disk.  Example: H I ion fraction is
    H I number density / H number density from on-disk fields.
    """
    if isinstance(field.name, tuple):
        ftype = field.name[0]
        field_name = field.name[1]
    else:
        ftype = 'gas'
        field_name = field.name
    field_array = field_name.split('_')
    if len(field_array) == 3:
        ion = field_array[0]
    else:
        ion = '_'.join(field_array[:2])
    atom = field_array[0]
    return data[ftype, '%s_number_density' % ion] / data[ftype, 
        '%s_nuclei_density' % atom]
