63ef8bfa3b63090437bd27bf1e04db7ae1eae3cf,nilmtk/stats/totalenergy.py,,get_total_energy,#Any#Any#,39
Before Change
energy = {}
data_source_rank = {} // overwrite Power with Energy with Energy(cumulative)
for (physical_quantity, ac_type), series in df.iteritems():
if physical_quantity == "power":
// Preference is to calculate energy from
// native Energy data rather than Power data
// so don"t overwrite with Power data.
if not energy.has_key(ac_type):
energy[ac_type] = _energy_for_power_series(
series, max_sample_period)
data_source_rank[ac_type] = 3 // least favourite
elif physical_quantity == "cumulative energy":
energy[ac_type] = series.iloc[-1] - series.iloc[0]
data_source_rank[ac_type] = 1 // favourite
elif (physical_quantity == "energy" and
data_source_rank.get(ac_type, 3) > 2):
energy[ac_type] = series.sum()
data_source_rank[ac_type] = 2
return energy
def _energy_for_power_series(series, max_sample_period):
After Change
// Select a column based on ordered preferences
PHYSICAL_QUANTITY_PREFS = ["cumulative energy", "energy", "power"]
selected_columns = []
for ac_type in AC_TYPES:
physical_quantities = [physical_quantity
for (physical_quantity, col_ac_type) in df.keys()
if col_ac_type == ac_type]
for pq in PHYSICAL_QUANTITY_PREFS:
if pq in physical_quantities:
selected_columns.append((pq, ac_type))
break
energy = {}
for col in selected_columns:
print("Calculating energy for column", col)
(physical_quantity, ac_type) = col
series = df[col]
if physical_quantity == "power":
energy[ac_type] = _energy_for_power_series(series, max_sample_period)
elif physical_quantity == "cumulative energy":
energy[ac_type] = series.iloc[-1] - series.iloc[0]
elif physical_quantity == "energy":
energy[ac_type] = series.sum()
return energy
def _energy_for_power_series(series, max_sample_period):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 9
Instances
Project Name: nilmtk/nilmtk
Commit Name: 63ef8bfa3b63090437bd27bf1e04db7ae1eae3cf
Time: 2014-11-27
Author: jack-list@xlk.org.uk
File Name: nilmtk/stats/totalenergy.py
Class Name:
Method Name: get_total_energy
Project Name: CellProfiler/CellProfiler
Commit Name: c65430b778f645fb8bc5ff81f08d8cf8c547a52d
Time: 2009-10-16
Author: thouis@1fc53939-2000-0410-845c-e8453a809027
File Name: pyCellProfiler/cellprofiler/modules/measureimagequality.py
Class Name: MeasureImageQuality
Method Name: test_valid
Project Name: nilmtk/nilmtk
Commit Name: b2cba5c722c3f41244c4c415513ad42fe6325132
Time: 2014-05-07
Author: jack-list@xlk.org.uk
File Name: nilmtk/pipeline/energynode.py
Class Name: EnergyNode
Method Name: process