def build_energy_model(freq_power_table, cpus_power, idle_power, first_cluster_idle_state):
    # pylint: disable=too-many-locals
    em = EnergyModel()
    idle_power_sc = idle_power[idle_power.cpus == 1]
    perf_data = get_normalized_single_core_data(freq_power_table)

    for cluster in ['little', 'big']:
        cluster_cpus_power = cpus_power[cluster].dropna()
        cluster_power = cluster_cpus_power['cluster'].apply(int)
        core_power = (cluster_cpus_power['1'] - cluster_power).apply(int)
        performance = (perf_data[perf_data.cluster == cluster].performance_norm * 1024 / 100).apply(int)
        for perf, clust_pow, core_pow in zip(performance, cluster_power, core_power):
            em.add_cap_entry(cluster, perf, clust_pow, core_pow)

        all_idle_power = idle_power_sc[idle_power_sc.cluster == cluster].power.values
        # CORE idle states
        # We want the delta of each state w.r.t. the power
        # consumption of the shallowest one at this level (core_ref)
        idle_core_power = low_filter(all_idle_power[:first_cluster_idle_state] -
                                     all_idle_power[first_cluster_idle_state - 1])
        # CLUSTER idle states
        # We want the absolute value of each idle state
        idle_cluster_power = low_filter(all_idle_power[first_cluster_idle_state - 1:])
        em.add_cluster_idle(cluster, idle_cluster_power)
        em.add_core_idle(cluster, idle_core_power)

    return em
dataset/ETHPy150Open ARM-software/workload-automation/wlauto/instrumentation/energy_model/__init__.py/build_energy_model/original