Skip to main content

Getting started

The following documentation is presented as Python code running inside a Jupyter Notebook. To run it yourself you can copy/type each individual cell or directly download the full notebook, including all required files.

Here we'll show a series of examples of what the Treble Software Development Kit (SDK) can be used for. The examples are based on Jupyter Notebooks but it is by no means necessary to use the SDK within a Notebook style environment. It is, however, a convenient way to do initial scripting, especially while getting a feeling for the SDK.

The initial notebooks are self-standing but can be viewed as a step-by-step guide to run your first simulation.

Initialize SDK and Create a Project

Before initializing the SDK, you will need to load your credential file to the correct directory. When you receive access to the SDK, you will be provided with instructions of how to do this.

The TSDK (Treble SDK) is what is used to initialize your SDK instance.

from treble_tsdk.tsdk import TSDK
from treble_tsdk import tsdk_namespace as treble
from treble_tsdk import display_data as dd

# Initialize the SDK (for this you will need credentials)
tsdk = TSDK()

Working with Projects

At the top of the organizational hierarchy for each user are the projects. The projects own simulations, models, Devices, Geometries and Source types. The data belonging to a project is all linked to the project in the cloud.

Projects belong to your organization so users belonging to the same organization can collaborate on a single project.

Each project has a unique ID, but multiple projects can have the same name. The instance of the TSDK class has a few functions to work with projects.

  • create_project(name) - Create a project with a certain name (id will be generated)
  • get_project(id) - Load a project with a certain id
  • get_or_create_project(name) - Create a project if no project exists with that name, otherwise load the last updated project with that name
  • get_last_updated_project() - Load the project you were using last time
  • list_projects() - List all projects in your organization
  • list_my_projects() - List all projects created by you as a user
  • delete_project(id) - Delete the project with this id

We will load or create new project with the name Tutorial

project_name = "Tutorial"
p = tsdk.get_or_create_project(name=project_name, description="Project used in Documentation Tutorial")

A good way to get an overview of your projects, and to associate ids with project names and creation dates. It's a good idea to plot the list of projects as a table. The id can then be used to load a certain project.

projects = tsdk.list_projects()

This Tutorial project is then what the next notebooks will all use.