import json


def write_eci_json(eci, basis_json_path):
    """Writes supplied ECI to the eci.json file for use in grand canonical monte carlo. Written for CASM 1.2.0

    Parameters:
    -----------
    eci: numpy.ndarray
        Vector of ECI values.

    basis_json_path: str
        Path to the casm-generated basis.json file.

    Returns:
    --------
    data: dict
        basis.json dictionary formatted with provided eci's
    """

    with open(basis_json_path) as f:
        data = json.load(f)

    for index, orbit in enumerate(data["orbits"]):
        data["orbits"][index]["cluster_functions"]["eci"] = eci[index]

    return data