The `api_24sea` package contains modules that are aimed at helping a user interact with the 24SEA API.
Project description
API 24Sea
api_24sea is a project designed to provide aid for the interaction with data from the 24SEA API.
Installation
pip install api_24sea
Project Structure
.
├── .azure/
├── api_24sea/
│ ├── __init__.py
│ ├── datasignals/
│ │ ├── __init__.py
│ │ └── schemas.py
│ ├── utils.py
│ └── version.py
├── tests/
├── docs/
├── notebooks/
├── pyproject.toml
├── LICENSE
├── VERSION
└── README.md
DataSignals Usage
The following example shows the classical usage of the datasignals module. The first step is to import the package and the necessary libraries. Then, the environment variables are loaded from a .env
file. After that, the package is initialized and the user is authenticated with the API. Finally, the user can get data from the API.
Importing the package
# %%
# **Package Imports**
# - From the Python Standard Library
import logging
import os
# - From third party libraries
import dotenv
import pandas as pd
# - Local imports
from api_24sea.version import __version__, parse_version
import api_24sea
Setting up the environment variables
# %%
_ = dotenv.load_dotenv("../env/.env")
if _:
print("Environment Variables Loaded Successfully")
print(os.getenv("API_USERNAME"))
else:
raise Exception("Environment Variables Not Loaded")
Initializing an empty dataframe
# %%
df = pd.DataFrame()
# %%
try:
df.datasignals.get_metrics()
except Exception as e:
print("API not available")
print(e)
Authenticating with the API
# %%
df.datasignals.authenticate(
os.getenv("API_USERNAME"), os.getenv("API_PASSWORD")
)
Checking the available metrics after authentication
# %%
df.datasignals.metrics_overview
Getting sample data from the API
# %%
sites = ["windfarm"]
locations = ["a01", "a02"]
metrics = ["mean WinDSpEed", "Std-windspeed", "mean_pitch", "mean power"]
start_timestamp = "2020-03-01T00:00:00Z"
end_timestamp = "2020-06-01T00:00:00Z"
df.datasignals.get_data(sites, locations, metrics,
start_timestamp, end_timestamp,
outer_join_on_timestamp=True)
Checking the metrics selected
# %%
df.datasignals.selected_metrics
Checking the data
# %%
df
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
api_24sea-0.2.3.tar.gz
(23.9 kB
view hashes)
Built Distribution
api_24sea-0.2.3-py3-none-any.whl
(22.6 kB
view hashes)
Close
Hashes for api_24sea-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4977a580470ca6a8c9fc75689ffc4d93aff224b562ee93c1dbe9babae52d6d9b |
|
MD5 | af23653bc3e57c303562bac30a1a76b9 |
|
BLAKE2b-256 | 871893abd53a02d80a390ac71ebdca0f436009b0003e2446c7420f57f0f07c13 |