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`."""
    with open('CELLPARM.INP', 'w') as f:
        for i, p in enumerate(ps):
            fn = p.filename
            cell = p.unit_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)
