Null timestamps example#
This notebook shows how to retrieve timestamps where the requested metrics return null values.
API-24SEA endpoint: https://api.24sea.eu/routes/v1/datasignals/null_timestamps
[1]:
# **Package Imports**
# - From the Python Standard Library
import logging
import os
import sys
# - API-24SEA
from api_24sea.version import __version__, parse_version
from api_24sea.datasignals.core import AsyncAPI
[2]:
# **Package Version**
print(f"Package {parse_version(__version__)}")
# **Notebook Configuration**
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
Package Version(major=2, minor=1, patch=6, release=None, num=None)
Login Credentials
Do not store API credentials in plain text in your notebook. Rather use the python-dotenv package to load environment variables from a .env file.
[3]:
# **Set Sample API Credentials**
os.environ["API_24SEA_USERNAME"] = "Sample.User"
os.environ["API_24SEA_PASSWORD"] = "CheckOutSomeData!"
[4]:
# **Package Versions**
print(f"Package {parse_version(__version__)}")
# **Notebook Configuration**
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
Package Version(major=2, minor=1, patch=6, release=None, num=None)
[5]:
# **API Initialization**
# API initialization can happen either explicitly via the API class, or
# implicitly when using the pandas `datasignals` accessor.
# In this example we will use the Pandas accessor.
api = AsyncAPI()
# The Metrics Overview is a table containing all the locations and metrics
# available in the API, together with their metadata. It is useful to query it
# before getting data, to check which locations and metrics are available for
# the site you want to query.
m_o = api.metrics_overview
# site is the wind farm name you want to query. The parameter can also be
# a list of site names, e.g. ["windfarm", "windfarm2"]. Matching is
# case-insensitive and passing the "site-id" is also accepted, e.g. "windfarm"
# will match "WindFarm", but also "WF", "wf", etc.
site = "windfarm"
# Matching locations from Metrics Overview for the specified site
# Also partial names of locations are accepted, e.g. "a01" will match
# all locations containing "a01" in their name, such as "A01", "a01". Matching
# is case-insensitive.
locations = m_o[m_o["site"].str.lower() == site]["location"].unique().tolist()
# Metrics: partial matches and regexes are accepted.
# Spaces are interpreted as .* in the name.
# If you want to query all metrics, pass "all" or ["all"].
metrics = ["mean windspeed", "mean power", "mean yaw", "mean rpm",
"mean pitch", "mean winddirection", "mean inc"]
# Start and end timestamp in ISO 8601 format. The API accepts also other
# formats, such as the one provided by
# https://www.elastic.co/docs/reference/elasticsearch/rest-apis/common-options#date-math
start_timestamp = "2020-03-01T00:00:00Z"
end_timestamp = "2020-06-01T00:00:00Z"
data = await api.get_null_timestamps(site, locations, metrics,
start_timestamp, end_timestamp)
data
Getting chunk: [1-1]: 100%|██████████| 1/1 [00:04<00:00, 4.72s/it]
[5]:
| metric | timestampsnotfound | site | location | data_group | statistic | short_hand | print_str | |
|---|---|---|---|---|---|---|---|---|
| 0 | mean_WF_A01_pitch | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA01 | scada | mean | pitch | Pitch |
| 1 | mean_WF_A01_power | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA01 | scada | mean | power | Power |
| 2 | mean_WF_A01_rpm | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA01 | scada | mean | rpm | Rotor speed |
| 3 | mean_WF_A01_TP_INC_LAT015_DEG240_X_nr1 | [2020-03-22T14:20:00+00:00, 2020-03-22T14:30:0... | WindFarm | WFA01 | inclination | mean | TP_INC_LAT015_DEG240_X_nr1 | TP INC LAT015 DEG240 X nr1 |
| 4 | mean_WF_A01_TP_INC_LAT015_DEG240_Y_nr2 | [2020-03-22T14:20:00+00:00, 2020-03-22T14:30:0... | WindFarm | WFA01 | inclination | mean | TP_INC_LAT015_DEG240_Y_nr2 | TP INC LAT015 DEG240 Y nr2 |
| 5 | mean_WF_A01_winddirection | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA01 | scada | mean | winddirection | Wind direction |
| 6 | mean_WF_A01_windspeed | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA01 | scada | mean | windspeed | Wind speed |
| 7 | mean_WF_A01_yaw | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA01 | scada | mean | yaw | Yaw |
| 8 | mean_WF_A02_pitch | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA02 | scada | mean | pitch | Pitch |
| 9 | mean_WF_A02_power | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA02 | scada | mean | power | Power |
| 10 | mean_WF_A02_rpm | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA02 | scada | mean | rpm | Rotor speed |
| 11 | mean_WF_A02_TP_INC_LAT015_DEG240_X_nr1 | [2020-03-12T04:00:00+00:00, 2020-03-12T04:10:0... | WindFarm | WFA02 | inclination | mean | TP_INC_LAT015_DEG240_X_nr1 | TP INC LAT015 DEG240 X nr1 |
| 12 | mean_WF_A02_TP_INC_LAT015_DEG240_Y_nr2 | [2020-03-12T04:00:00+00:00, 2020-03-12T04:10:0... | WindFarm | WFA02 | inclination | mean | TP_INC_LAT015_DEG240_Y_nr2 | TP INC LAT015 DEG240 Y nr2 |
| 13 | mean_WF_A02_winddirection | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA02 | scada | mean | winddirection | Wind direction |
| 14 | mean_WF_A02_windspeed | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA02 | scada | mean | windspeed | Wind speed |
| 15 | mean_WF_A02_yaw | [2020-03-04T10:00:00+00:00, 2020-03-05T09:10:0... | WindFarm | WFA02 | scada | mean | yaw | Yaw |