def _instance2sub(instance_number, total_perturbations):
    """
    Converts an instance number (ii) to initial condition index (ci) and
    perturbation index (pi)  subscripts

    instances use 1-based indexes and vary according to this function:
        ii = ci * len(PERTURBATIONS) + pi + 1
    where both pi and ci use 0-based indexes.
    """
    perturbation_index = (instance_number - 1) % total_perturbations
    initial_condition = (instance_number - 1 - perturbation_index) // total_perturbations
    return initial_condition, perturbation_index