Skip to main content

Python client for Sintetic Project. This library provides a simple interface to interact with the Sintetic API, allowing users to manage and retrieve data related to synthetic datasets. For more information, visit https://sinteticproject.eu/

Project description

Contents of README.md

Sintetic Library

Description

Python client for Sintetic Project. This library provides a simple interface to interact with the Sintetic API, allowing users to manage and retrieve data related to synthetic datasets. For more information, visit https://sinteticproject.eu/

Intallation

To install the library, you can use pip:

pip install sintetic-library

Use case

from sintetic_library import SinteticClient

# Create istance of SinteticClient using your Sintetic account
client = SinteticClient(
        email="XXXXXX",
        password="YYYYYYY"
    )

#######
# Sample #1
# Implementation sample for tree processor, forest operation and stan4d files
#######

# Call method for retrieving list of tree processors
result = client.get_list_tree_processors ()

# Retrieve list of forest properties
result = client.get_list_forest_properties () 

# Retrieve list of forest properties
result = client.get_list_forest_properties ()

# Create tree processor id for given data
data = { "name" : "Test Tree Processor",
         "type" : "harvester"    
       }        

id_tree_processor = client.create_tree_processor(data)

# Create new forest operation from given data
# 
data = { "name" : "Test Forest Operation",
                 "status" : "planned",
                 "location": {
                    "type": "Point",
                    "coordinates": [10.2, 45.2]
                    },  
                 "start_date" : "2025-06-19",
                 "end_date" : "2025-06-19", 
                 "area": 100,
                 "forest_property_id": "XXXXXXXX-YYYY-ZZZZ-XXXX-ZZZZZZZZZZZZ"
                }
        
id_forest_operation = client.create_forest_operation(data)       

# Retrieve list of Stan4D files
response = client.get_stan4d_list() 

# Save new Stan4D file
with open("./stan4d_file.hpr", "rb") as f:
    xml_content = f.read()
    
response = client.save_stan4d_object(
    filename=os.path.basename(f.name),
    xml_content=xml_content,
    tree_processor_id=id_tree_processor,
    forest_operation_id=id_forest_operation
)
    
# Extract Stan4D file ID    
stand4d_id = response.json()["id"]

# Get Stan4D file using the associated ID
response = client.get_stan4d_file(fileid=stand4d_id)

# Delete Stan4D file using the associated ID
response = client.delete_stan4d_file(fileid=stand4d_id)

# Delete Forest Operation using the associated ID
response = client.delete_forest_operation(forest_operation_id=id_forest_operation)
        
# Delete Tree Processor using the associated ID
response = client.delete_tree_processor(tree_processor_id=id_tree_processor)
##### End of Sample #1

#####
# Sample #2
# Implementation sample for climate data attachment management
#####

#Open CSV file with climate data
with open("testcsv.csv", "rb") as f:
    csv_content = f.read()

# Create new climate object
response = client.save_climate_object(
    filename="testcsv.csv",
    climate_file=csv_content,
    anomalistic=True,
    forest_operation_id="24a912c4-6a0a-4860-a163-f62e96f43d6b",
    temporal_resolution=TemporalResolution.DAILY.value,
    coverage_start_year=2025,
    coverage_end_year=2025,
    description="Test Climate Attachment"
)


climate_object_id = response   
print("Climate object saved successfully:", climate_object_id)    

# Retrieve Climate Attachment data
print("Retrieved Climate Attachment data:", client.get_climate_data(climate_object_id))   

# Retrieve Climate Attachment file
print("Retrieved Climate file contents:", client.get_climate_file(climate_object_id))

# Delete climate file and data
print("Delete climate file:", client.delete_climate_file(climate_object_id))

#### End of Sample #2

####
# Sample #3
# Implementation sample for subcompartments and vegetation file management
####

#create a new forest operation for subcompartment
data = { "name" : "Test Leandro for Subcompartment",
                "status" : "planned",
                "location": {
                "type": "Point",
                "coordinates": [10.2, 45.2]
                },  
                "start_date" : "2025-06-19",
                "end_date" : "2025-06-19", 
                "area": 100,
                "forest_property_id": "8a0febff-e133-44fd-8e15-bfa11b40f620"
            }
    
forest_id = client.create_forest_operation(data)
print("Risposta creazione forest operation: ", forest_id)

# Create a new subcompartment
response = client.create_subcompartment("Test subcompartment Leandro", SubcompartmentType.FOREST_OPERATION.value, 
                            forest_id, 10.0, 10.0, 20.0, 20.0)

print(f"Subcompartment created successfully with UUID: {response}")
subcomp_id = response
# Retrieve the list of subcompartments
response = client.get_subcompartments_list()
print(f"List of subcompartments: {response}")

# Retrieve the subcompartment by UUID   
response = client.get_subcompartment(subcomp_id)
print(f"Retrieved subcompartment info: {response}")

# Create new vegetation object
# open ndvi file in binary mode
with open("ndvi_july.csv", "rb") as f:
    csv_content = f.read()

response = client.save_vegetation_object(
    filename="ndvi_july.csv",
    vegetation_file=csv_content,
    subcompartment_id=subcomp_id,
)

print(f"Vegetation object saved successfully with ID: {response}")

# Retrieve the vegetation data
response = client.get_vegetation_data(subcomp_id)
print(f"Retrieved vegetation file contents: {response}")
    
# Retrieve vegetation attachments list
response = client.get_vegetation_list()
print(f"Retrieved vegetation attachments list: {response}")

# Retrieve the vegetation object
response = client.get_vegetation_file(subcomp_id)
print(f"Retrieved vegetation file contents: {response}")
    
#Append new vegetation file
#open ndvi file in binary mode
with open("ndvi_august.csv", "rb") as f:
    csv_content = f.read()

response = client.save_vegetation_object(
    filename="ndvi_august.csv",
    vegetation_file=csv_content,
    subcompartment_id=subcomp_id,
)

print(f"Vegetation object saved successfully with ID: {response}")

# Retrieve the updated vegetation object 
response = client.get_vegetation_file(subcomp_id)
print(f"Retrieved updated file contents: {response}")

# Delete vegetation file
response = client.delete_vegetation_file(subcomp_id)
print(f"Vegetation file deleted successfully: {response}")

# Delete subcompartment
response = client.delete_subcompartment(subcomp_id)
print(f"Subcompartment deleted successfully: {response}")

# Delete forest operation
response = client.delete_forest_operation(forest_id)
print(f"Subcompartment deleted successfully: {response}")

License

This library is freely provided for use within the Sintetic project

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

sintetic_library-0.5.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

sintetic_library-0.5.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file sintetic_library-0.5.0.tar.gz.

File metadata

  • Download URL: sintetic_library-0.5.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for sintetic_library-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4d291e2c8a4a78b4b88e4ca9e34a010fef0cb348efeb20ddf5f9af0bc041ea8f
MD5 3e4554300074139fb0655b9c6dfa34fd
BLAKE2b-256 4ee693025b3a80362a8fa00ad12b44886f94a6758ce128b63603a09837c250e3

See more details on using hashes here.

File details

Details for the file sintetic_library-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sintetic_library-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37e07618541ed8f5da10c43aca740188da85d57da7fd44c06ef6818da815b02e
MD5 9db94fedc788845693de9c361f8bf67c
BLAKE2b-256 f08aefa92a8fb49a39a511802a62651fd0bcb6b74aa553f1f9bc018ae88c6e4e

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