Skip to main content

Client package for the DDC API.

Project description

DDC Utility

This is the Danube Data Cube Utility library, for interacting with the DDC API service.

Installation

pip install ddc-utility

Usage

Users must have a valid DDC registration.

Example #1 (using DdcClient with client ID and secret)

This example walks you through the process of creating and opening an AOI cube.

$ python

# Importing packages
>>> import os
>>> from ddc_utility.client import DdcClient

# Setting DDC credentials
>>> os.environ['DDC_CLIENT_ID'] = "<client id>"
>>> os.environ['DDC_CLIENT_SECRET'] = "<client secret>"

# Initialize DDC client 
>>> client = DdcClient()

# List available data layers
>>> client.get_data_layers()

# List user's AOIs
>>> client.get_all_aoi()

# Create an AOI
>>>  res = client.create_aoi(name="My AOI",
                  geometry="POLYGON ((19.021454 47.507925, 19.043941 47.489601, 19.047031 47.490181, 19.039478 47.506997, 19.021454 47.507925))",
                  time_range=("2023-06-01", "2023-07-01"),
                  layer_ids=[4, 8, 15, 48])
>>> id = res.iloc[0]['id']
                  
# Check if AOI is 'ready'
>>> info = client.get_aoi_by_id(id)
>>> print(f"AOI status is: {info.iloc[0]['status']}")

# If status is 'ready', open cube
>>> ds = client.open_aoi_cube(aoi_id=id)

Example #2 (using IntegrationClient with bearer token)

This example shows how you can retrieve the dataset associated with a growing season if you have a valid OAuth2 bearer token.

$ python

# Importing packages
>>> from ddc_utility.client import IntegrationClient

# Initialize Integration client 
>>> client = IntegrationClient(
    bearer_token="...",
    expires_in=86400,
)

# Retrieve xarray Dataset for the specified growing season
>>> ds = client.open_growing_season_cube(1234)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ddc_utility-1.8.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ddc_utility-1.8.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file ddc_utility-1.8.0.tar.gz.

File metadata

  • Download URL: ddc_utility-1.8.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.14

File hashes

Hashes for ddc_utility-1.8.0.tar.gz
Algorithm Hash digest
SHA256 9e09820491de023af0dd43adfafe6f8bf1d530ca1abee906c79c0f1b6c500aa7
MD5 daef226b8cb76ac186e0d4d0536394b8
BLAKE2b-256 167aa923b7ebde2b49b711fa9474d6ac6f86d17924a235f45d035dcf7264954f

See more details on using hashes here.

File details

Details for the file ddc_utility-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: ddc_utility-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.14

File hashes

Hashes for ddc_utility-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e49961c044b4fde5c818f2652f02cc190e4b7a0f5a0f38a2581a2c7ae87beaa0
MD5 8c5e5efd452dcd81739b39073f008f46
BLAKE2b-256 cc0986a1c3040eeeeb32309cf195c7ce66b1fb45c72fd6697103b9c67aae45d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page