Versions Compared

Key

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

...

putputSlice


Code Block
languagepy
titleIMAS Python :: put
linenumberstrue
# coding: utf8
#system libraries
import sys
import numpy
import os

#UAL library
import imas
from imas.imasdef import *

# Gets user name and data (major) version
user = os.environ['USER']
imasVersion = os.environ['IMAS_VERSION'][:1]
database = 'test'

# Create a new instance of database
imas_obj = imas.ids(11, 22)
imas_obj.create_env(user, database, imasVersion)  # Create a new instance of database
 
ids = imas_obj.core_profiles

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


# allocate the IDS structures
ids.xglobal_quantities.yip.resize(10)
ids.time.resize(10)

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

# ---- a loop ---- STORE VECTORS OF SIZE N
for i in range(10):
      # Setting values of time depended data
      ids.xglobal_quantities.yip[i] = 2*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
import os
 
# UAL library
import imas
from imas.imasdef import *
 
 # Gets user name and data (major) version
user = os.environ['USER']
imasVersion = os.environ['IMAS_VERSION'][:1]
database = 'test'

# Create a new instance of database
imas_obj = imas.ids(11, 22)
imas_obj.create_env(user, database, imasVersion)  # Create a new instance of database
 
ids = imas_obj.core_profiles
 
# Mandatory to define this property
ids.ids_properties.homogeneous_time = 1
IDS_TIME_MODE_HOMOGENEOUS
 
# 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
time_1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
vect1DDouble_1 = time_1

ids.time.resize(1)
ids.x.yprofiles_1d.resize(1)
ids.global_quantities.ip.resize(1)

# Setting values of time depended data
for i in range(len(time_1)):
    ids.xglobal_quantities.yip[0] = VALUE 

10*vect1DDouble_1[i]
    
    #Do not forget time!!
    ids.time[0] = time_1[i]
    
    # STORING  DATA 
    if i = VALUE

= 0:
        ids.put()
    else:
        #Append this slice in the database
        ids.putSlice()

#close the pulse file
imas_obj.close()


...

getgetSlice


Code Block
languagepy
titleIMAS Python :: get
linenumberstrue
#system libraries
import sys
import numpy
import os
 
#UAL library
import imas

# Gets user name and data (major) version
user = os.environ['USER']
imasVersion = os.environ['IMAS_VERSION'][:1]
database = 'test'

#Open a database
imas_obj = imas.ids(11, 22)
imas_obj.open_env(user, database, imasVersion)  

ids = imas_obj.core_profiles

#Get data
ids.get()

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

# VECTORS (!time))
print 'Time  = '  + str(ids.time)
print 'Value  = ' + str(ids.x.y)
global_quantities.ip))

#close the pulse file
imas_obj.close()



Code Block
languagepy
titleIMAS Python :: getSlice
linenumberstrue
#system libraries
import sys
import numpy
import os
 
#UAL library
import imas
 
 # Gets user name and data (major) version
user = os.environ['USER']
imasVersion = os.environ['IMAS_VERSION'][:1]
database = 'test'

#Open a database
imas_obj = imas.ids(11,22)
imas_obj.open_env(user, database, imasVersion) 
 

ids = imas_obj.core_profiles
 
#Get data
ids.getSlice(23, 12)
 
#VECTORS of SIZE 1 (!)
print ('Time : ' + str(ids.time))
print ('VALUE = ' + str(ids.x.yglobal_quantities.ip))
 
#close the pulse file
imas_obj.close()


...