def cells_to_cellparm(ps):
    """Takes a list of `xds_parser` instances and writes the cell
    parameters to an instruction file `CELLPARM.INP` for the program
    `cellparm`.
    """
    fn = 'CELLPARM.INP'
    with open(fn, 'w') as f:
        for i, p in enumerate(ps):
            i += 1
            fn = p.filename
            cell = p.d['raw_cell']
            ntot = p.d['total']['ntot']
            print(f'! {i: 3d} from {fn}', file=f)
            print(
                'UNIT_CELL_CONSTANTS= {:10.2f}{:10.2f}{:10.2f}{:10.2f}{:10.2f}{:10.2f} WEIGHT= {ntot}'
                .format(*cell, ntot=ntot), file=f)
    print(f'Wrote file {fn}')
