def _calc_nemsio_hgt(f):
    """Calculates the geopotential height from the variables hgtsfc and delz.

    Parameters
    ----------
    f : xarray.DataSet
        the NEMSIO opened object.  Can be lazily loaded.

    Returns
    -------
    xr.DataArray
        Geoptential height with varialbes, coordinates and variable attributes.

    """
    sfc = f.hgtsfc
    dz = f.delz
    z = dz + sfc
    z = z.rolling(z=len(f.z), min_periods=1).sum()
    z.name = 'geohgt'
    z.attrs['long_name'] = 'Geopotential Height'
    z.attrs['units'] = 'm'
    return z