import imas
import numpy
import sys
imas_obj = imas.ids(11, 22)
imas_obj.create() # Create a new instance of database
# Define a first generic vector and its time base
time = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
ids = imas_obj.core_profiles
# allocate the ids fie
ids.global_quantities.ip.resize(len(time))
ids.time.resize(len(time))
# Mandatory to define this property
ids.ids_properties.homogeneous_time = 0
#First fill fields which are not time-dependent.
# Fillthe ids fields with data
ids.ids_properties.comment = 'This is a test ids'
for i in range(len(time)):
#Fill time-dependent fields
ids.global_quantities.ip[i] = time[i] * 10
ids.time[i] = time[i]
#Save data in the database
ids.put() # <= Called outside the loop
imas_obj.close() |