Versions Compared

Key

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

...

Warning

Warning

Stop here for a moment. Make sure you have followed the configuration setup before proceeding any further!

Configuration related tutorial is here -> Click me! <-

 

3.1

...

.1 Method "putSlice"

 

 

Code Block
languagebash
shell> python ./put_ids_array.py
shell> python ./put_ids_slices.py
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()





# Setting values of time depended data
cpo.x.y = VALUE
    
#Do not forget time!!
cpo.time = VALUE 
    
#Append this slice in the database
cpo.putSlice() 

#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()  

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)

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

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

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

#close the pulse file
imas_obj.close()

 4. XXX

3.1.1 Method "put"

 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'

# SCALARS(!)
# ---- a loop ----
for i in range(10):
      # Setting values of time depended data 
      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'

# STORE AS SCALARS(!)
# ---- 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()

  

3.1.1 Method "get"

 

Image RemovedVI 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.
get() CPO vs IDS
Code Block
languagepy
titleITM
linenumberstrue
#system libraries
import numpy
import sys

#UAL library
import ual

#Open the database
itm_obj = ual.itm(123,3,123,0)
itm_obj.open() 
        
cpoArray = itm_obj.pfsystemsArray

#Get data
cpoArray.get()

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






#close the pulse file
imas_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  = ' + str(ids.x.y)


#close the pulse file
imas_obj.close()

 

 

 

...

What you can see here is a simple code that stores particular IDS into MDSPlus database using UAL.

 

 

Let's check how to read these data in Fortran.

3.2 Accessing data using Fortran

Exercise no. 4 - After this exercise you will:

  • know how to connect to UAL
  • know how to retrieve data from UAL
  • know how to prepare Makefile for your Fortran code

Exercise no. 4 (approx. 15 min)

In this exercise you will read IDS and print some data stored inside.

1. source ITMv1 script by invoking

source $ITMSCRIPTDIR/ITMv1 kepler test 4.10b > /dev/null

2. Change directory to a demo location for this exercise

3.1.1 Method "getSlice"

 

cd $TUTORIAL_DIR/ids_basics/fortran
 
 getSlice() CPO vs  IDS
Code Block
languagepy
titleITM
linenumberstrue
#system libraries
import sys
import numpy

#UAL library
import ual

#Open the database
itm_obj = ual.itm(11,22)
itm_obj.open() 
 
cpo = my_itm_obj.pfsystems

#Get data
cpo.getSlice(2, 1)

#SCALARS 
print 'Time : ' + str(cpo.time)
print 'VALUE = ' + str(ids.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.getSlice(2, 1)

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

#close the pulse file
imas_obj.close()

 

4. Compile the code
 
Code Block
shell> make clean
shell> make

5. Run the code

...

...

shell> ./get_ids_array.exe
shell> ./get_ids_slices.exe

 

 

...

6. You should see values that we have stored using Python based code.

4. FC2K - Fortran Code to Kepler

It is possible to encapsulate Fortran/C++ code with Java code that represents Kepler actor. This way, you can easily incorporate your Fortran code with existing Kepler workflow. In order to make it happen you will have to:

...

...

After these steps are performed, you will have an access to Kepler actor that encapsulates your Fortran code.

...

4

...