Parameters
    ----------
    radius_sphere_um : float
        Radius of sphere in um
    size_simulation_um : list of floats
        Size of simulation volume in lateral dimension in um.
        If a float is given, then a square simulation size is assumed. If
        a tuple is given, then a rectangular shape is assumed.
    shape_grid : tuple of ints
        Grid points in each lateral dimension.
        If a float is given, then a square simulation size is assumed. If
        a tuple is given, then a rectangular shape is assumed.
    refractive_index : float
        RI of sphere
    measurement_position_um : float
        Axial measurement position in um
    wavelength_nm : float
        Light wavelength in nanometers
    offset_x_um : float
        x coordinate of center of the sphere in um
    offset_y_um : float
        y coordinate of center of the sphere in um
    arp: bool
        Use arbitrary precision
    working_directory: str or pathlib.Path or None
        User-defined working directory; used for testing

def simulate_sphere(radius_sphere_um=2.5,
                    size_simulation_um=[7, 7],
                    shape_grid=(50, 50),
                    refractive_index_medium=1.0,
                    refractive_index_sphere=1.01,
                    measurement_position_um=2.5,
                    wavelength_nm=500,
                    offset_x_um=0,
                    offset_y_um=0,
                    arp=True,
                    working_directory=None):
    """
    Parameters
    ----------
    radius_sphere_um : float
        Radius of sphere in um
    size_simulation_um : list of floats
        Size of simulation volume in lateral dimension in um.
        If a float is given, then a square simulation size is assumed. If
        a tuple is given, then a rectangular shape is assumed.
    shape_grid : tuple of ints
        Grid points in each lateral dimension.
        If a float is given, then a square simulation size is assumed. If
        a tuple is given, then a rectangular shape is assumed.
    refractive_index : float
        RI of sphere
    measurement_position_um : float
        Axial measurement position in um
    wavelength_nm : float
        Light wavelength in nanometers
    offset_x_um : float
        x coordinate of center of the sphere in um
    offset_y_um : float
        y coordinate of center of the sphere in um
    arp: bool
        Use arbitrary precision
    working_directory: str or pathlib.Path or None
        User-defined working directory; used for testing
    """
    wavelength_um = wavelength_nm / 1000

    # size simulation tuple
    sizeum = list(size_simulation_um)
    shape_grid = list(shape_grid)

    # The size of the simulation must be zero
    # if there is only one grid point.
    if shape_grid[0] == 1:
        sizeum[0] = 0
    if shape_grid[1] == 1:
        sizeum[1] = 0

    assert np.allclose(shape_grid[0], int(
        shape_grid[0])), "resulting x-size is not an integer"
    assert np.allclose(shape_grid[1], int(
        shape_grid[1])), "resulting y-size is not an integer"

    while True:
        if working_directory is None:
            # create temp dir
            wdir = tempfile.mkdtemp(prefix="qpsphere_bhfield_")
        else:
            wdir = pathlib.Path(working_directory)

        try:
            run_simulation(wdir=wdir,
                           arp=arp,
                           wl=wavelength_um,
                           r_core=radius_sphere_um,
                           r_coat=radius_sphere_um,
                           n_grid_x=int(shape_grid[0]),
                           xspan_min=-sizeum[0] / 2 - offset_x_um,
                           xspan_max=sizeum[0] / 2 - offset_x_um,
                           n_grid_y=int(shape_grid[1]),
                           yspan_min=-sizeum[1] / 2 - offset_y_um,
                           yspan_max=sizeum[1] / 2 - offset_y_um,
                           n_grid_z=1,
                           zspan_min=measurement_position_um,
                           zspan_max=measurement_position_um,
                           case="other",
                           Kreibig=0,
                           n_med=refractive_index_medium,
                           n_core=refractive_index_sphere,
                           k_core=0,
                           n_coat=refractive_index_medium,
                           k_coat=0)
        except BaseException:
            if arp:
                raise
            else:
                msg = "bhfield: Standard precision failed. " \
                      + "Retrying with arbitrary precision."
                warnings.warn(msg)
                arp = True
            clear_temp(wdir=wdir)
        else:
            break

    result = load_field(wdir=wdir, shape_grid=shape_grid)
    clear_temp(wdir=wdir)
    return result