#PARSER PQL
#DOREWRITE false
#DEFINE PATH_LOCAL '/media/mydata/dev/odysseus_workspace/phd-workspace/Moving Object/Evaluation/scenarios/energy/energy_data.csv'
#ADDQUERY
input = ACCESS({
source='households',
wrapper='GenericPull',
schema=[
['id','Integer'],
['wh','Integer'],
['BaseDateTime','StartTimeStamp']
],
inputschema=['Integer','Integer','Integer'],
transport='File',
protocol='csv',
datahandler='Tuple',
metaattribute = ['TimeInterval', 'PredictionTimes'],
options=[
['filename', ${PATH_LOCAL}],
['Delimiter',','],
['TextDelimiter','"'],
['delay','1000'],
['readfirstline','false'],
['BaseTimeUnit','MINUTES']
]
}
)
/// Only use the last two measured values
time = TIMEWINDOW({
size = [20, 'minutes']
},
input
)
/// Convert the wh-attribute to a temporal double
temporalize = AGGREGATION({
aggregations = [
['function' = 'ToTemporalDouble', 'input_attributes' = 'wh', 'output_attributes' = 'temp_wh']
],
group_by = ['id'],
eval_at_outdating = false
},
time
)
predTime = PREDICTIONTIME({
addtostartvalue = [0, 'MINUTES'],
addtoendvalue = [15, 'MINUTEs']
},
temporalize
)
/// Energy consumption per household per minute in the next 15 minutes
derivative = MAP({
expressions = [
['derivative(temp_wh, PredictionTimes)','whPerMinute'],
['id','id']
]
},
predTime
)
/// Energy consumption per household per minute in the next 15 minutes
watts = MAP({
expressions = [
['whPerMinute * 60','watt'],
['id','id']
]
},
derivative
)
/// Filter out elements with a low energy consumption
highConsumption = SELECT({
predicate = 'watt > 300'
},
watts
) |