Versions Compared

Key

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

...

putSlice()
Code Block
languagepy
titleITM
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
titleIMAS
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 = '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()

...

 put()
Code Block
languagepy
titleITM
linenumberstrue
#system libraries
import sys
from pylab import * 

#UAL library
import ual

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




cpoArray = itm_obj.equilibriumArray

# allocate the CPO structures
cpoArray.resize(10)


# Filling fields with TIME-INDEPENDENT data
cpoArray[0].codeparam.parameters = 'param'

# ---- a loop ----
for i in range(0, 10):
      #Fill time-dependent fields 
      cpoArray[i].x.y = i
    
	  #Do not forget time!!
      cpoArray[i].time = i
# ---- a loop ----

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

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

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

ids = imas_obj.core_profiles

# allocate the IDS structures
ids.x.y.resize(10)
ids.time.resize(10))

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

# ---- a loop ----
for i in range(0,10):
      #Fill time-dependent fields
      ids.x.y[i] = i 
	  
      #Do not forget time!!
      ids.time[i] = i
# ---- a loop ----

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

#close the pulse file
imas_obj.close()

 

 

 

VI related notice
I will use VI in every place where text files are modified. If you have any other text file editor of your choice - fell free to use it instead.
Handling IDSes: putget() CPO vs . putSliceget() IDS
Code Block
languagepy
title$TUTORIAL_DIR/ids_basics/python/put_ids_array.pyITM
linenumberstrue
#system libraries
import sys
from pylab import *numpy

#UAL library
import ual

ids#Open =the 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()database
itm_obj = ual.itm(11,22)
itm_obj.open() 

cpoArray = itm_obj.pfsystemsArray

#Get data
cpoArray.get()

# SCALARS (!)
for i in range(len(cpoArray)):
    print 'Time SCALAR  =' + str(cpoArray[i].time) 
    print 'Value SCALAR =' + str(cpoArray[i].x.y)


#close the pulse file
itm_obj.close()
Code Block
languagepy
titleIMAS
linenumberstrue
#system libraries
import sys
import numpy

#UAL library
import imas

#Open a database
imas_obj = imas.ids(11, 22)
imas_obj.open()  

ids = imas_obj.core_profiles

#Get data
ids.get()

# SCALARS (!)
for i in range(len(ids.time)):
    print 'Time   =' + str(ids.time[i]) 
    print 'Value  =' + str(ids.x.y[i])

# VECTORS (!)
print 'Time  = '  + str(ids.time)
print 'Value 
Code Block
languagepy
title$TUTORIAL_DIR/ids_basics/python/put_ids_slices.py
linenumberstrue
#system libraries
import sys
import numpy

#UAL library
import imas

#Open a database
imas_obj = imas.ids(11, 22)
imas_obj.open()  

ids = imas_obj.core_profiles

#Get data
ids.get()

print 'Ip = ' + str(ids.global_quantitiesx.ipy)


#close the pulse file
imas_obj.close()

 

...