Versions Compared

Key

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

...

 put()
Code Block
languagepy
titleITM
linenumberstrue
import sys
from pylab import * 
import ual

ids = ual.itm(13,3)
ids.create()

if not ids.isConnected():
    print 'error during itmdb entry creation'
    sys.exit(1)

ids.equilibriumArray.resize(10)
equi = ids.equilibriumArray

#First fill fields which are not time-dependent.
equi.array[0].datainfo.dataprovider = 'MKO'
equi.array[0].datainfo.putdate = '20/09/2016'
equi.array[0].codeparam.parameters = 'param'



# ---- a loop ----
for i in range(0, 10):
    #Fill time-dependent fields 
    equi.array[i].eqgeometry.boundary.resize(1)
    equi.array[i].eqgeometry.boundary[0].r = sin(arange(0,2*pi,2*pi/100)) + (1/float(100-i))
    equi.array[i].eqgeometry.boundary[0].z = cos(arange(0,2*pi,2*pi/100)) + (1/float(100-i))
    
	#Do not forget time!!
    equi.array[i].time = i
# ---- a loop ----

#Save data in the database
equi.put() # <= Called outside the loop

#close the pulse file
ids.close()
Code Block
languagepy
titleIMAS
linenumberstrue
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()

...