Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A Data Entry is an IMAS concept for designating a pulse with given shot and run numbers located in some database (see below).

HLI API (Ludovic)

The methods exposed by HLIs are:

  • —Operations on data base entry:
    • —CREATE
    • —OPEN
    • —CLOSE
  • —Operations on IDSs:
    • —PUT
    • —GET
    • —PUT_SLICE
    • —GET_SLICE
    • —DELETE


In this tutorial, we will describe each method of the HLI API (section 1.1. HLI API).

We will use As an example, we will describe the Python HLI.  Documentation of all others HLIs is available in the User guide available from this page:   https://confluence.iter.org/display/IMP/Integrated+Modelling+Home+Page

HLI API (Ludovic)

create

Creating a new Data Entry using the MDS+ backend consists in creating a new pulse file on disk.  Therefore, you need to have write permissions for the database specified in the create() command.

...

Code Block
import imas
import getpass
from imas import imasdef
#creates the Data Entry object 'data_entry' associated to the pulse file with shot=15000, run=1, belonging to database 'pcss_tutorial' of the current user, using the MDS+ backend
data_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, 'data_access_tutorial, 15000, 1, user_name=getpass.getuser())
#creates the pulse file associated to the Data Entry object 'data_entry' previously created
data_entry.create()
#close the pulse file associated to the 'data_entry' object
data_entry.close() 	

Execution of the code above will create the pulse file at location ~/public/imasdb/data_access_tutorial/3/0:

...

The pulse file is opened, however no data have been yet fetched from the pulse file.

put/

...

close

IDSs are data containers described by the IMAS Data Dictionary. IDSs represent either a Diagnostics (like the 'bolometer' IDS), or a System (like the 'camera_ir'), or a concept like the 'equilibrium' IDS representing the plasma equilibrium.

In order to write IDS data to the pulse file, we will first use the put() operation which writes all static (non time dependent) and AND dynamic data from an IDS. 

...

The first part of the code below is opening a data_entry (see 2.2.1.2.), then a magnetics IDS is created and written to the data_entry using the put() operation:

Code Block
import imas
import getpass
import numpy as np
from imas import imasdef
#creates the Data Entry object 'data_entry' associated  to the pulse file with shot=15000, run=1, belonging to database 'data_access_tutorial' of the current user, using the MDS+ backend
data_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, 'data_access_tutorial, 15000, 1, user_name=getpass.getuser())
#opens the pulse file associated to the Data Entry object 'data_entry' previously created
data_entry.open() 

magnetics_ids = imas.magnetics() #creating a 'magnetics' IDS
magnetics_ids.ids_properties.homogeneous_time=1 #setting the homogeneous time (mandatory)
magnetics_ids.ids_properties.comment='IDS created for testing the homogneous time to 1 IMAS Data Access layer'
magnetics_ids.time=np.array([0]) #the time(vector) basis must be not empty if homogeneous_time==1 otherwise an error will occur at runtime
data_entry.put(magnetics_ids, 0) #writing magnetics data to the data_entry associated to the pulse file. The second argument 0 is the so-called IDS occurrence.

#close the pulse file associated to the 'data_entry' object
data_entry.close() 	 


get/close


Let'read the 'magnetics' IDS previously created in put/close


Code Block
import imas
import getpass
import numpy as np
from imas import imasdef
#opens the Data Entry object 'data_entry' associated  to the pulse file with shot=15000, run=1, belonging to database 'data_access_tutorial' of the current user, using the MDS+ backend
data_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, 'data_access_tutorial, 15000, 1, user_name=getpass.getuser())
#opens the pulse file associated to the Data Entry object 'data_entry' previously created
data_entry.open() 

magnetics_ids = imas.magnetics() #creating a 'magnetics' IDS
magnetics_ids.ids_properties.homogeneous_time=1 #setting the homogeneous time (mandatory)
magnetics_ids.ids_properties.comment='IDS created for testing the IMAS Data Access layer'
magnetics_ids.time=np.array([0]) #the time(vector) basis must be not empty, if homogeneous_time==1 otherwise an error will occur at runtime
data_entry.put(magnetics_ids, 0) #writing magnetics data to the data_entry associated to the pulse file. The second argument 0 is the so-called IDS occurrence.

 #close the pulse file associated to the 'data_entry' object
data_entry.close()

  

get/getSlice

 	


 delete_data

...