Locations API
Module to connect to the database API to retrieve and operate on locations data.
- class owimetadatabase_preprocessor.locations.io.LocationsAPI(api_root: str = 'https://owimetadatabase.owilab.be/api/v1', api_subdir: str = '/locations/', token: str | None = None, uname: str | None = None, password: str | None = None, **kwargs)
Bases:
API
Class to connect to the location data API with methods to retrieve data.
A number of methods are provided to query the database via the owimetadatabase API. In the majority of cases, the methods return a dataframe based on the URL parameters provided. The methods are written such that a number of mandatory URL parameters are required (see documentation of the methods). The URL parameters can be expanded with Django-style additional filtering arguments (e.g.
location__title__icontains="BB"
) as optional keyword arguments. Knowledge of the Django models is required for this (seeowimetadatabase
code).- __init__(api_root: str = 'https://owimetadatabase.owilab.be/api/v1', api_subdir: str = '/locations/', token: str | None = None, uname: str | None = None, password: str | None = None, **kwargs) None
Create an instance of the LocationsAPI class with the required parameters.
- Parameters:
api_root – Optional: root URL of the API endpoint, the default working database url is provided.
api_subdir – Optional: subdirectory of the API endpooint url for specific type of data.
token – Optional: token to access the API.
uname – Optional: username to access the API.
password – Optional: password to access the API.
kwargs – Additional parameters to pass to the API.
- Returns:
None
- get_projectsites(**kwargs) Dict[str, DataFrame | bool | int64 | None]
Get all available projects.
- Param:
kwargs: Additional parameters to pass to the API.
- Returns:
Dictionary with the following keys:
”data”: Pandas dataframe with the location data for each project
”exists”: Boolean indicating whether matching records are found
- get_projectsite_detail(projectsite: str, **kwargs) Dict[str, DataFrame | bool | int64 | None]
Get details for a specific projectsite.
- Parameters:
projectsite – Title of the projectsite.
kwargs – Additional parameters to pass to the API.
- Returns:
Dictionary with the following keys:
”id”: id of the selected project site.
”data”: Pandas dataframe with the location data for each projectsite.
”exists”: Boolean indicating whether matching records are found.
- get_assetlocations(projectsite: str | None = None, **kwargs) Dict[str, DataFrame | bool | int64 | None]
Get all available asset locations for all projectsites or a specific projectsite.
- Parameters:
projectsite – String with the projectsite title (e.g. “Nobelwind”).
assetlocation – String with the asset location title (e.g. “NW2A04”).
kwargs – Additional parameters to pass to the API.
- Returns:
Dictionary with the following keys:
”data”: Pandas dataframe with the location data for each location in the projectsite.
”exists”: Boolean indicating whether matching records are found.
- get_assetlocation_detail(assetlocation: str, projectsite: str | None = None, **kwargs) Dict[str, DataFrame | bool | int64 | None]
Get a selected turbine.
- Parameters:
projectsite – Name of the projectsite (e.g. “Nobelwind”).
assetlocation – Title of the asset location (e.g. “BBK05”).
kwargs – Additional parameters to pass to the API.
- Returns:
Dictionary with the following keys:
”id”: id of the selected projectsite site.
”data”: Pandas dataframe with the location data for the individual location.
”exists”: Boolean indicating whether a matching location is found.
- plot_assetlocations(return_fig: bool = True, show_fig: bool = True, **kwargs) None | Figure
Retrieve asset locations and generates a Plotly plot to show them.
- Parameters:
return_fig – Boolean indicating whether the Plotly figure object needs to be returned.
show_fig – Boolean indicating whether the figure needs to be shown.
kwargs – Keyword arguments for the search (see
get_assetlocations
).
- Returns:
Plotly figure object with selected asset locations plotted on OpenStreetMap tiles (if requested) or nothing.