<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def time_series_h5(timefile, colnames):
 """Read temporal series HDF5 file. If :data:`colnames` is too long, it will be truncated. If it is too short, additional column names will be deduced from the content of the file. Args: timefile (:class:`pathlib.Path`):
 path of the TimeSeries.h5 file. colnames (list of names):
 names of the variables expected in :data:`timefile` (may be modified). Returns: :class:`pandas.DataFrame`: Time series, with the variables in columns and the time steps in rows. """

    if not timefile.is_file():
        return None
    with h5py.File(timefile, 'r') as h5f:
        dset = h5f['tseries']
        _, ncols = dset.shape
        ncols -= 1  # first is istep
        h5names = map(bytes.decode, h5f['names'][len(colnames) + 1:])
        _tidy_names(colnames, ncols, h5names)
        data = dset[()]
    return pd.DataFrame(data[:, 1:],
                        index=np.int_(data[:, 0]), columns=colnames)