Versions Compared

Key

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

...

python put_cpo.py

4. Open example file

 

...

Handling CPOs: put() vs. putSlice()
Code Block
languagepy

 

vi $TUTORIAL_DIR/cpo_basics/python/put_cpo.py

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

...

title$TUTORIAL_DIR/cpo_basics/python/put_cpo_array.py
linenumberstrue
import sys
from pylab import * 
import ual

cpo = ual.itm(

...

13,

...

3)
cpo.create()

if not cpo.isConnected():
    print 'error during itmdb entry creation'
    sys.exit(1)

cpo.equilibriumArray.resize(

...

100)

...

equi = cpo.equilibriumArray

...


for i in range(0, 10):
    #Time independent fields
    equi.array[

...

i].datainfo.dataprovider = 'MKO'
    equi.array[

...

i].datainfo.putdate = '

...

20/

...

09/

...

2016'
    equi.array[

...

i].codeparam.parameters = 'param'

...

    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

equi.put()

#close the pulse file
cpo.close()
Code Block
languagepy
title$TUTORIAL_DIR/cpo_basics/python/put_cpo_slices.py
linenumberstrue
import sys
from pylab import * 
import ual

cpo = ual.itm(14,4)
cpo.create()

if not cpo.isConnected():
    print 'error during itmdb entry creation'
    sys.exit(1)

equi = cpo.equilibrium

#First fill fields which are not time-dependent.
equi.datainfo.dataprovider = 'MKO'
equi.datainfo.putdate = '20/09/2016'
equi.codeparam.parameters = 'param'

#Save time independent fields
equi.putNonTimed()

for i in range(0, 10):
    equi.eqgeometry.boundary.resize(1)
    equi.eqgeometry.boundary[0].r

...

 = sin(arange(0,2*pi,2*pi/100)) + (1/float(100-i))
    equi.eqgeometry.boundary[0].z = cos(arange(0,2*pi,2*pi/100)) + (1/float(100-i))
    
    #Do not forget time!!
    equi.time = i 
    
    #Append this slice in the database
    equi.

...

putSlice()

#close the pulse file
cpo.close()
Image AddedVI 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.

 

vi $TUTORIAL_DIR/cpo_basics/python/put_cpo.py

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

 

 

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

...