Calculate total energy production. Not Rounded
492553
def _links(self):
        """"""
        total = 0.0
        for value in self.link.values():
            total += value
        return total
1142782
def energy_upperbound(self, spins):
        
        subtheta = self.theta.copy()
        subtheta.fix_variables(spins)

        # ok, let's start eliminating variables
        trees = self._trees

        if not trees:
            # if there are no variables to eliminate, then the offset of
            # subtheta is the exact value and we can just return it
            assert not subtheta.linear and not subtheta.quadratic
            return subtheta.offset

        energy = Plus(self.message_upperbound(trees, {}, subtheta), subtheta.offset)

        return energy
1321606
def energy(self):
        """"""
        arr = self.src.copy()
        arr = self.apply_color(arr, self.state)

        scores = [histogram_distance(self.ref[i], arr[i]) for i in range(3)]

        # Important: scale by 100 for readability
        return sum(scores) * 100
328003
def mw(mol, ndigits=2):
    
    mol.require("Valence")
    return round(sum(a.mw() for _, a in mol.atoms_iter()), ndigits)
448979
protected function calculateTotal()
    {
        $otherConfig = $this->getOtherConfig();
        $total       = $this
            ->getEnvironment()
            ->getDataProvider()
            ->fetchAll($otherConfig->setIdOnly(true));

        if (\is_array($total)) {
            $this->intTotal = $total ? \count($total) : 0;

            return;
        }

        if (\is_object($total)) {
            $this->intTotal = $total->length();

            return;
        }

        $this->intTotal = 0;
    }
124769
def total_cycles(self) -> int:
        """"""
        return sum((int(re.sub(r'\D', '', op)) for op in self.tokens))
1177949
def total_surface_energy(self):
        
        tot_surface_energy = 0
        for hkl in self.miller_energy_dict.keys():
            tot_surface_energy += self.miller_energy_dict[hkl] * \
                                  self.miller_area_dict[hkl]
        return tot_surface_energy
121820
def calculable(self):
        """"""
        self._thermo = ""
        if self.kwargs["T"] and self.kwargs["P"]:
            self._thermo = "TP"
        elif self.kwargs["P"] and self.kwargs["h"] is not None:
            self._thermo = "Ph"
        elif self.kwargs["P"] and self.kwargs["s"] is not None:
            self._thermo = "Ps"
        # TODO: Add other pairs definitions options
        # elif self.kwargs["P"] and self.kwargs["v"]:
            # self._thermo = "Pv"
        # elif self.kwargs["T"] and self.kwargs["s"] is not None:
            # self._thermo = "Ts"
        elif self.kwargs["h"] is not None and self.kwargs["s"] is not None:
            self._thermo = "hs"
        elif self.kwargs["T"] and self.kwargs["x"] is not None:
            self._thermo = "Tx"
        elif self.kwargs["P"] and self.kwargs["x"] is not None:
            self._thermo = "Px"
        return self._thermo
1349549
def smoothness(self):
        
        energies = self.energies
        try:
            sp = self.spline()
        except:
            print("Energy spline failed.")
            return None
        spline_energies = sp(range(len(energies)))
        diff = spline_energies - energies
        rms = np.sqrt(np.sum(np.square(diff)) / len(energies))
        return rms
775158
def generator(self, t):
        """"""
        self.check_fit()

        return (1.0 / self.theta) * (np.power(t, -self.theta) - 1)
1089622
def sum_over_energy(self):
        
        # Note that the array is using the opposite convention from WCS
        # so we sum over axis 0 in the array, but drop axis 2 in the WCS object
        return Map(np.sum(self.counts, axis=0), self.wcs.dropaxis(2))
113204
def calculate_energy(self):
        
        clibrebound.reb_tools_energy.restype = c_double
        return clibrebound.reb_tools_energy(byref(self))
1314124
def energy_entropy(data, fs, numOfShortBlocks=10):
    """"""
    data = np.mean(data, axis=1)

    Eol = np.sum(data ** 2)    # total data energy
    L = len(data)
    subWinLength = int(np.floor(L / numOfShortBlocks))
    if L != subWinLength * numOfShortBlocks:
        data = data[0:subWinLength * numOfShortBlocks]

    # subWindows is of size [numOfShortBlocks x L]
    subWindows = data.reshape(subWinLength, numOfShortBlocks, order='F').copy()

    # Compute normalized sub-data energies:
    s = np.sum(subWindows ** 2, axis=0) / (Eol + EPSILON)

    # Compute entropy of the normalized sub-data energies:
    Entropy = -np.sum(s * np.log2(s + EPSILON))
    return Entropy
596969
def get_cutoff_energy(self):
        ''''''
        return Value(
            scalars=[Scalar(value=self.settings["kinetic-energy cutoff"])],
            units=self.settings['kinetic-energy cutoff units']
        )
672097
def plot_energy(time, H, T, U):
    """"""
    # Normalize energy to initial KE
    T0 = T[0]
    H = H / T0
    T = T / T0
    U = U / T0
    
    # Plot
    fig, ax = plt.subplots(figsize=[16,8])
    ax.set_title('System Energy vs. Time')
    ax.set_xlabel('Time in Days')
    ax.set_ylabel('Energy (Ratio Initial KE)')
    ax.plot(time, T, label='T', color='r')
    ax.plot(time, U, label='U', color='b')
    ax.plot(time, H, label='H', color='k')
    ax.legend()
    ax.grid()
    plt.show()
951548
def load_energy():
    """"""
    tbl_name = 'energy_usage'
    data = get_example_data('energy.json.gz')
    pdf = pd.read_json(data)
    pdf.to_sql(
        tbl_name,
        db.engine,
        if_exists='replace',
        chunksize=500,
        dtype={
            'source': String(255),
            'target': String(255),
            'value': Float(),
        },
        index=False)

    print('Creating table [wb_health_population] reference')
    tbl = db.session.query(TBL).filter_by(table_name=tbl_name).first()
    if not tbl:
        tbl = TBL(table_name=tbl_name)
    tbl.description = 'Energy consumption'
    tbl.database = utils.get_or_create_main_db()

    if not any(col.metric_name == 'sum__value' for col in tbl.metrics):
        tbl.metrics.append(SqlMetric(
            metric_name='sum__value',
            expression='SUM(value)',
        ))

    db.session.merge(tbl)
    db.session.commit()
    tbl.fetch_metadata()

    slc = Slice(
        slice_name='Energy Sankey',
        viz_type='sankey',
        datasource_type='table',
        datasource_id=tbl.id,
        params=textwrap.dedent("""\
        {
            "collapsed_fieldsets": "",
            "groupby": [
                "source",
                "target"
            ],
            "having": "",
            "metric": "sum__value",
            "row_limit": "5000",
            "slice_name": "Energy Sankey",
            "viz_type": "sankey",
            "where": ""
        }
        """),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)

    slc = Slice(
        slice_name='Energy Force Layout',
        viz_type='directed_force',
        datasource_type='table',
        datasource_id=tbl.id,
        params=textwrap.dedent("""\
        {
            "charge": "-500",
            "collapsed_fieldsets": "",
            "groupby": [
                "source",
                "target"
            ],
            "having": "",
            "link_length": "200",
            "metric": "sum__value",
            "row_limit": "5000",
            "slice_name": "Force",
            "viz_type": "directed_force",
            "where": ""
        }
        """),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)

    slc = Slice(
        slice_name='Heatmap',
        viz_type='heatmap',
        datasource_type='table',
        datasource_id=tbl.id,
        params=textwrap.dedent("""\
        {
            "all_columns_x": "source",
            "all_columns_y": "target",
            "canvas_image_rendering": "pixelated",
            "collapsed_fieldsets": "",
            "having": "",
            "linear_color_scheme": "blue_white_yellow",
            "metric": "sum__value",
            "normalize_across": "heatmap",
            "slice_name": "Heatmap",
            "viz_type": "heatmap",
            "where": "",
            "xscale_interval": "1",
            "yscale_interval": "1"
        }
        """),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)
337082
def _production(self):
        """"""
        return self._nuclear + self._diesel + self._gas + self._wind + self._combined + self._vapor + self._solar + self._hydraulic + self._carbon + self._waste +  self._other