def METHOD_NAME(pupil_grid, ptv, diameter, exponent=-2.5, aperture=None, remove_modes=None):
    '''Create an error surface from a power-law power spectral density.
    Parameters
    ----------
    pupil_grid : Grid
        The grid on which to calculate the error.
    ptv : scalar
        The peak-to-valley of the wavefront aberration in meters.
    diameter : scalar
        The diameter over which the ptv is calculated.
    exponent : scalar
        The exponent of the power law.
    aperture : Field
        The mask over which to calculate the ptv. A circular aperture with diameter
        `diameter` is used if this is not given.
    remove_modes : ModeBasis
        The modes which to remove from the surface aberration. The peak-to-valley
        is enforced before these modes are removed. This allows for correctting surface
        errors with optic alignment.
    Returns
    -------
    Field
        The surface error calculated on `pupil_grid`.
    '''
    def psd(grid):
        res = Field(grid.as_('polar').r**exponent, grid)
        res[grid.as_('polar').r == 0] = 0
        return res
    if aperture is None:
        aperture = make_circular_aperture(diameter)(pupil_grid)
    screen = SpectralNoiseFactoryFFT(psd, pupil_grid).make_random()()
    screen *= ptv / np.ptp(screen[aperture != 0])
    if remove_modes is not None:
        trans = remove_modes.transformation_matrix
        trans_inv = inverse_tikhonov(trans, 1e-6)
        screen -= trans.dot(trans_inv.dot(screen))
    return Field(screen * aperture, pupil_grid)