FetchHistory
The FetchHistory function of the mplreport class returns an AQLHistResponse object with the results of a historical AQL query.
Parameters
Parameter | Type | Default | Meaning |
---|---|---|---|
query | str | The AQL query to run, without the GETHISTORY command. | |
start | DateTime | None | The start of the query time, in UTC. If None, the report start time is used. |
end | DateTime | None | The end of the query time, in UTC. If None, the report end time is used. |
samples | int | 2000 | The number of samples to return. Ignored if method is raw. |
method | str | interp | The query method. Can be interp,min,max or raw. |
utc | bool | false | If true, result times are in UTC. If false, result times are in local time. |
Return
This function returns None on failure, or a AQLHistResponse object.
The AQLHistResponse has a member called 'data' which contains a Pandas dataframe containing all of the query results.
Usage
If this information is required for your report, we suggest calling FailOnError immediately after using this function.
Example
#Get the history of all temperatures across the system hist = report.FetchHistory("'Temperature' PROPERTY ALLPOINTS") report.FailOnError('Temperature') #Get the dataframe from that history... df = hist.data #For each column, plot a line-chart. for col in df.columns: ax.plot(df[col],label=col) ax.legend()
This code will request every temperature property for the report range and chart it.