Time series versions #497
-
|
Is it possible to read multiple versions or a specific version of a time series using the Python SDK? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
What do you mean by specific version of time series?
|
Beta Was this translation helpful? Give feedback.
-
|
This looks like what I want. Thanks! Is there an example of e.g. getting all versions of a forecast given by a target object? |
Beta Was this translation helpful? Give feedback.
-
|
Not sure if this is what you need, but for getting historical versions: # Get historical time series
# Calculation expression: ## = @GetTsHistoricalVersions(@t('.some_ts_attribute'),5)
LOCAL_TIME_ZONE = tz.tzlocal()
start = datetime(2021, 9, 1, tzinfo=LOCAL_TIME_ZONE)
end = datetime(2021, 9, 15, tzinfo=LOCAL_TIME_ZONE)
max_number_of_versions_to_get = 5
historical_timeseries = session.history_functions(
timeseries_attribute.id, start_time=start, end_time=end
).get_ts_historical_versions(max_number_of_versions_to_get)
for timeseries in enumerate(historical_timeseries):
pandas_dataframe = timeseries.arrow_table.to_pandas()
# Post processing: convert to UTC timezone-aware datetime object and then to given time zone
pandas_dataframe["utc_time"] = pd.to_datetime(
pandas_dataframe["utc_time"], utc=True
).dt.tz_convert(LOCAL_TIME_ZONE)For getting all forecasts: # Get forecast time series
# Calculation expression: ## = @GetAllForecasts(@t('.some_ts_attribute'))
LOCAL_TIME_ZONE = tz.tzlocal()
start = datetime(2021, 9, 1, tzinfo=LOCAL_TIME_ZONE)
end = datetime(2021, 9, 15, tzinfo=LOCAL_TIME_ZONE)
forecast_timeseries = session.forecast_functions(
timeseries_attribute.id, start_time=start, end_time=end
).get_all_forecasts()
for timeseries in enumerate(forecast_timeseries):
pandas_dataframe = timeseries.arrow_table.to_pandas()
# Post processing: convert to UTC timezone-aware datetime object and then to given time zone
pandas_dataframe["utc_time"] = pd.to_datetime(
pandas_dataframe["utc_time"], utc=True
).dt.tz_convert(LOCAL_TIME_ZONE)Similar for other Mesh functions: https://volue-public.github.io/energy-mesh-python/mesh_functions.html. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, this helped a lot. Is there a way to distinguish from the contents of a volue.mesh._attribute.TimeseriesAttribute whether or not it has forecasts? |
Beta Was this translation helpful? Give feedback.
What do you mean by specific version of time series?