def downsample(darray, round_func=round, **dim_limits):
    """
    Downsamples `darray` based on dimensions given in dim_limits

    dim_limits should be of the form:
        dim_limits = dict(yC=1000, zF=2048)
    """
    for dim, dim_limit in dim_limits.items():
        dim_length = len(darray[dim])
        stride = int(round_func(dim_length / dim_limit))
        down = {dim : slice(None, None, stride)}
        darray = darray.isel(**down)
    return darray