def write_ps_hdf5(file, spec_name, l, ps, spectra=None):
    """Write down the power spectra in a hdf5 file.
        
    Parameters
    ----------
    file: hdf5
      the name of the hdf5 file
    spec_name: string
      the name of the group in the hdf5 file
    l: 1d array
      the multipoles (or binned multipoles)
    ps: 1d array or dict of 1d array
      the power spectrum, if spectra is not None, expect a dictionary with entry spectra
    spectra: list of strings
      needed for spin0 and spin2 cross correlation, the arrangement of the spectra
    """

    def array_from_dict(l,ps,spectra=None):
        array = []
        array += [l]
        if spectra == None:
            array += [ps]
        else:
            for spec in spectra:
                array += [ps[spec]]
        return array
    
    group = file.create_group(spec_name)
    array = array_from_dict(l, ps, spectra=spectra)
    group.create_dataset(name="data", data=array, dtype="float")