def get_sample_size(prefix=None):
    """
    Count how many files we're dealing with
    Assumes snapshots start with "snapshot-" string and contain
    two numbers: snapshot-XXX-YYY_ZZZZ.hdf5, where both XXX and YYY
    are integers, have the same minimal, maximal value and same
    difference between two consecutive numbers.

    if prefix is given, it will prepend it to snapshots.

    this is intended for numbered output.
    Returns:
        nx : number of files (in one direction)
        filenummax: highest XXX
        fileskip: integer difference between two XXX or YYY
    """
    import os
    import numpy as np
    if prefix is not None:
        filelist = os.listdir(prefix)
    else:
        filelist = os.listdir()
    snaplist = []
    for f in filelist:
        if f.startswith('snapshot-'):
            snaplist.append(f)
    snaplist.sort()
    first = snaplist[0]
    s, dash, rest = first.partition('-')
    num, dash, junk = rest.partition('-')
    lowest = int(num)
    finalsnap = snaplist[-1]
    s, dash, rest = finalsnap.partition('-')
    num, dash, junk = rest.partition('-')
    highest = int(num)
    steps = int(np.sqrt(len(snaplist)))
    nx = steps
    filenummax = highest
    fileskip = int((highest - lowest) / (steps - 1))
    return nx, filenummax, fileskip
