def get_timesteps(trajectory):
    """
    Determine valid timesteps for the associated hdf5 dump

    Parameters
    ----------
    trajectory : The decoded hdf5 file containing the dumped run data.
        Usually from something like h5py.File(infile, 'r')

    Returns
    -------
    A tuple consisting of three entries. The first is a sorted list of
    integers for every valid timestep.
    The second and third are for convenience and represent the start and
    end time of the run. (First and last timesteps.)

    """
    trajectory_times = sorted([int(k) for k in trajectory['id'].keys()])
    start_time = trajectory_times[0]
    end_time = trajectory_times[len(trajectory_times)-1]
    return(trajectory_times, start_time, end_time)