Versions Compared

Key

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

...

Code Block
languagepy
title$TUTORIAL_DIR/ids_basics/python/put_ids_array.pyITM
linenumberstrue
#system libraries
import sys
from pylab import * 

# UAL library
import ual

# Create a new instance of database
itm_obj = ual.itm(14,4)
itm_obj.create()

cpo = itm_obj.equilibrium




# Filling fields with TIME-INDEPENDENT  data
cpo.codeparam.parameters = 'param'

#Save time independent fields
cpo.putNonTimed()





# ---- a loop ----
for i in range(0, 10):
	#Fill time-dependent fields 
	cpo.x.y = i
    
    #Do not forget time!!
    cpo.time = i 
    
    #Append this slice in the database
    cpo.putSlice() # <= Called inside the loop
# ---- a loop ----

#close the pulse file
itm_obj.close()
Code Block
languagepy
title$TUTORIAL_DIR/ids_basics/python/put_ids_slices.pyIMAS
linenumberstrue
#system libraries
import sys
import numpy

# UAL library
import imas

# Create a new instance of database
imas_obj = imas.ids(11, 22)
imas_obj.create()  # Create a new instance of database

ids = imas_obj.core_profiles

# Mandatory to define this property
ids.ids_properties.homogeneous_time = 1

# Filling fields with TIME-INDEPENDENT  data
ids.ids_properties.comment = 'A test IDS created by putSlice'

#Save time independent fields
ids.putNonTimed()

# Allocate all variables, time coordinate of size 1
ids.time.resize(1)
ids.x.y.resize(1)

# ---- a loop ----
for i in range(10)):
       # Setting values of time depended data
       ids.x.y[0] = i 

       #Do not forget time!!
       ids.time[0] = i

       #Append this slice in the database
       ids.putSlice() # <= Called inside the loop
# ---- a loop ----

#close the pulse file
imas_obj.close()

...