Versions Compared

Key

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

...

Code Block
import imas
import getpass
import numpy as np
from imas import imasdef

#creating 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)

#opening the pulse file handled by the Data Entry object previously created
data_entry.open() 

#creating the 'magnetics' IDS and initializing it
magnetics_ids = imas.magnetics() #creates 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' #setting the ids_properties.comment attribute
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

#writing the 'magnetics' IDS
data_entry.put(magnetics_ids, 0) #writes magnetics data to the data_entry associated to the pulse file. The second argument 0 is the so-called IDS occurrence.

#closing the Data Entry
data_entry.close() 	 



Note

If you are using the HDF5 backend, you can check the content of the magnetics.h5 file using h5dump:

h5dump ~/public/imasdb/data_access_tutorial/3/15000/1/magnetics.h5



Let's extend the above example by adding the WEST data of the 10 first flux loops to the newly created 'magnetics' IDS.

...