data-download
Data Import
One of the most important aspects of the bi-directional communication between Altergo and the Python is the ability for Altergo to import date pertaining to the assets on the cloud into Python. This allows users to rapidly iterate through their algorithms and test it on data stored on relevant assets on the cloud. Thus, it is important to understand the method for importing data.
getAssetDataFrame
The getAssetDataFrame
method within the SDK Client
allows users to import data into their Python environment in the form of Pandas DataFrames.
The method in its most basic form requires the user to provide a list of assets for which data has to be pulled, a list of sensors for which data has to be imported, and date range.
Example:
from ion_sdk.edison_api.edison_api import setupClient, edisonDate
edApi = setupClient()
myAsset = edApi.getAsset("MyBattery001")
edApi.getAssetDataFrame([myAsset], ["Current", "Voltage", "Temperature"], edisonDate(2021, 10, 1), edisonDate(2021, 10, 2))
print(myAsset.df)
The above example shows how a user can import data from an asset called MyBattery001
for the Current
, Voltage
, and Temperature
sensors for a total of 1 day. edisonDate
is a function that helps convert human-interprettable date-times into UNIX/EPOCH/POSIX time in milliseconds. The reference for this function is available here.
Several Pitfalls
Here are some of the most common pitfalls and method to resolve them.
I ran the method correctly, but I can't see my data
This generally happens if the user has errorneously assigned the output of the method to the dataframe attribute of the asset.
Example:
myAsset.df = edApi.getAssetDataFrame([myAsset], ["Current", "Voltage", "Temperature"], edisonDate(2021, 10, 1), edisonDate(2021, 10, 2))
Since an assignment was made the asset's dataframe attribute, the dataframe gets deleted and replaced by None
. Thus, the user is unable to see the data.
To fix this issue, the user should drop the assignment.
edApi.getAssetDataFrame([myAsset], ["Current", "Voltage", "Temperature"], edisonDate(2021, 10, 1), edisonDate(2021, 10, 2))
Data import is taking too much time
If you experience a significantly large time to import data, this can mean either of two things:
- The Altergo Server is facing performance issues.
- You have asked for a very large (memory size) data and the server is taking to prepare the request.
To address the first part- if the user is able to access and view the plots in the Visualisation Tool for an asset in their desired time range, the user can eliminate point 1. However, if such is not the case, the user should report to the Person of Contact at Altergo for further assistance.
For the second part- if the users has accessed large data, the server is unable to rapidly serve this request. Thus, it may be sensible to break the request into smaller pieces which the server can serve rapidly. Once imported, the user can stitch this pieces together using the pd.concat
function so as to be returned with a single dataframe.
The method raised an HTTPError saying the server cannot process more than 5 days
This is an error raised because the user asked for very large data. The server is only allowed to serve request which have a range of 5 days or less. Any requests larger than 5 days are not served by the server.
To navigate past this error, break the request down into smaller pieces which the server can serve. Once imported, the user can stitch this pieces together using the pd.concat
function so as to be returned with a single dataframe.