Hint

You can run this notebook in a live session with Binder Helmholtz.

  • it is important to acknowledge that the utilization of the Helmholtz is restricted to individuals who possess the necessary credentials as Helmholtz users. It is highly recommended to utilize the Python scipy option when constructing the environment in order to mitigate the occurrence of a 404 Bad request error.

How to work with STA2STAC#

Below are few examples demonstrating how to begin using STA2STAC:

Prior to proceeding, it is necessary to install STA2STAC:

[ ]:
pip install sta2stac

In this example, our objective is to harvest data from the SensorThingsAPI of IMK-IFU, without any supplementary assets and extensions.

[ ]:
from sta2stac import STA2STAC

STA2STAC(sta_link="https://sensorthings.imk-ifu.kit.edu/",
        sta_version="v1.1",
        logger_properties={"logger_handler": "StreamHandler"})

In the upcoming example, we will determine the values of stac_dir, stac_id, stac_title, and stac_dir.

[ ]:
from sta2stac import STA2STAC
import os

STA2STAC(sta_link="https://sensorthings.imk-ifu.kit.edu/",
            sta_version="v1.1",
            stac_dir=os.getcwd(),
            stac_id="test-id",
            stac_title="This is a test title",
            stac_description="This is a test description",
            logger_properties={"logger_handler": "StreamHandler"})

In this example, we execute the ItemInfoHandler class initially to retrieve the auto-generated ID, title, and description of the items. Subsequently, we create our own items_tuples to substitute the automatically created ones.

[ ]:
from sta2stac import ItemInfoHandler

result = ItemInfoHandler(
    logger_properties={"logger_handler": "StreamHandler"}
    ).get_entity_tuples_info(
        sta_link="https://sensorthings.imk-ifu.kit.edu/",
        sta_version="v1.1",
        entity="Things", )
print(result)

[(‘BE_K_000’, ‘BE_K_000’, ‘Climate Station at TERENO Site Berg’), (‘FEN_MET_000’, ‘FEN_MET_000’, ‘Climate Station at TERENO Pre-Alpine Site Fendt’), (‘KOL_MET_001’, ‘KOL_MET_001’, ‘Climate Station at TERENO Pre-Alpine Site Kolbensattel’), (‘LaS_MET_001’, ‘LaS_MET_001’, ‘Climate Station at TERENO Pre-Alpine Site Laber’), (‘ROT_MET_000’, ‘ROT_MET_000’, ‘Climate Station at TERENO Pre-Alpine Site Rottenbuch’), (‘GRA_MET_000’, ‘GRA_MET_000’, ‘Climate Station at TERENO Pre-Alpine Site Graswang’), (‘ACH_MET_000’, ‘ACH_MET_000’, ‘Climate Station at TERENO Site Acheleschwaig’), (‘KIT_Campus_Alpin_Greenhouse_experiment-2022_heat_limit’, ‘KIT_Campus_Alpin_Greenhouse_experiment:2022_heat_limit’, ‘experiment:2022_heat_limit campaign at KIT Campus Alpin’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’), (‘Kitchen’, ‘Kitchen’, ‘The Kitchen in my house’)]

[ ]:
from sta2stac import STA2STAC
items_tuples = [('BE_K_000', 'test-id','test title', 'test description'),('ACH_MET_000', 'test-id1','test title1', 'test description2')]

STA2STAC(sta_link="https://sensorthings.imk-ifu.kit.edu/",
            sta_version="v1.1",
            items_tuples=items_tuples,
            logger_properties={"logger_handler": "StreamHandler"})

In this example, we seek to employ the filter function to selectively improve the output result of STA. In this instance, our objective is to employ a filter to exclusively choose the Things that possess an id of 65.

[ ]:
from sta2stac import STA2STAC

STA2STAC(sta_link="https://sensorthings.imk-ifu.kit.edu/",
            sta_version="v1.1",
            filter="$filter=id%20eq%2065",
            logger_properties={"logger_handler": "StreamHandler"})

In the above example, we aim to activate the datacube_extension during the harvesting process.

[ ]:
from sta2stac import STA2STAC

STA2STAC(sta_link="https://sensorthings.imk-ifu.kit.edu/",
            sta_version="v1.1",
            datacube_extension=True,
            logger_properties={"logger_handler": "StreamHandler"})