Versions Compared

Key

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

Table of Contents

...

06.2.1.

...

2 "put" and "putSlice" functions

putputSlice


Code Block
languagepy
titleIMAS Python :: put
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()

ids = imas_obj.core_profiles

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


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

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

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

# OR STORE AS VECTORS
ids.x.y = valueVector
ids.time = timeVector

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

#close the pulse file
imas_obj.close()



Code Block
languagepy
titleIMAS Python :: putSlice
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()  

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 = '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)

# Setting values of time depended data
ids.x.y[0] = VALUE 

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

#Append this slice in the database
ids.putSlice()

#close the pulse file
imas_obj.close()

...


06.2.1.

...

"get" and "getSlice" functions

getgetSlice


Code Block
languagepy
titleIMAS Python :: get
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  = ' + str(ids.x.y)


#close the pulse file
imas_obj.close()



Code Block
languagepy
titleIMAS Python :: getSlice
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.getSlice(2, 1)


print 'Time : ' + str(ids.time)
print 'VALUE = ' + str(ids.x.y)

#close the pulse file
imas_obj.close()

 

...