Versions Compared

Key

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

...

Code Block
titleConnecting to JET - instructions
collapsetrue
In order to access the new mdsplus.jetdata.eu service, users will need to make a minor change to their codes, changing the host parameter 
in the connection calls from "mdsplus.jet.efda.org" or "mdsplus.jet.uk" to "ssh://<username>@mdsplus.jetdata.eu" 
where <username> is the your JET account username (e.g. jsmith or xy1234)

Users will also need to register their SSH public key with us in order for this to work. 
Please do this by emailing support@it.ukaea.uk with the subject line “MDSplus SSH Key Registration”. 
Please put your SSH Public key into the body of the message – do not add attachments to the email. 
It is important that you provide your public key only and do not include your private key (users should take all reasonable steps to protect their private keys). 
(Due to a limitation of the mdsplus server, please avoid using Ed25519 keys, though ecdsa keys can be used)

Suggested email text to use:

Please register my SSH Public key for use with mdsplus.jetdata.eu. 
My username is : <your shortname>
My SSH Public key is: 

Once your key has been registered we will confirm this back to you and you will then be able to test the connection and your clients

If you need information about creating SSH keys please see the information here:
•	There is some general information here: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-2
•	There is a page on how to create key pairs with openssh at https://www.ssh.com/academy/ssh/keygen
•	There is a page on how to create key pairs with putty at https://www.ssh.com/academy/ssh/putty/windows/puttygen
•	The www.ssh.com has pages about generating keys for other ssh clients too.

Important Note: when generating SSH key pairs, we’d suggest that most users will find it more convenient not to use a passphrase (i.e. leave it blank). 
Also, due to a limitation of the mdsplus server, please avoid using Ed25519 keys, though ecdsa keys can be used

Saving data to IMAS

Before saving the experimental data to imas it is important check which version of imas data dictonary we are using.

You may load (or you may use scripts that load) IMAS environment without specifying the version

Code Block
module purge
module load cineca
module load imasenv

The last line loads imas data dictionary and also idstools which will be used later.

However, loading imasenv does not necessarily provide you with the latest version of data dictionary. In this case: 


Once the pair of keys 'id_rsa_jet'  is created it necessary that the system can distinguish between the keys. You can inform the system by editing 'config' file in ~/ .ssh folder.

Code Block
titlessh config
Host jet
 HostName mdsplus.jetdata.eu
 User <your jet username>
 IdentityFile ~/.ssh/id_rsa_jet

In an example we fetch JET data  (dda='hrts', uid = 'jetppf', seq=0, dtype= ['TE', 'DTE', 'NE', 'DNE', 'Z']) .

Example of script fetching HRTS JET data.

Code Block
titleExample script of fetching data from JET
linenumberstrue
collapsetrue
#example of saving experimental data to ids

import os
import json	

def read_ppf(conn, shot, ppf, seq=0, uid='jetppf',debug=False):
    ierr = conn.get('_sig=ppfuid("' + uid +'")')
    c = '_sig=jet("ppf/%s/%d",%d)'% (ppf, seq, shot)
    if debug: print('\nDEBUG: %s\n' % c)
    try:
Code Block
languagebash
title>module list
collapsetrue
~>module list
Currently Loaded Modulefiles:
  1) profile/archive                      18) cmake/3.5.2                          35) IMAS/3.29.0/AL/4.8.3
  2) cineca                    s = conn.get(c)
        raw 19) mdsplus/7.92.0/gcc/4.8= s.data()
        dim0       36) itm-blas/3.8.0/intel/17.0
  3) intel/pe-xe-2017--binary= conn.get('dim_of(_sig,0)').data()
        try:
        20) blitz/1.0.1 dim1       = conn.get('dim_of(_sig,1)').data()
          return {'raw': raw, 'x':dim0, 't':dim1}
    37) itm-lapack/3.8.0/intel/17.0
  4) itm-intel/17.0 except:
          return {'raw': raw, 't':dim0}
    except:
      21) jaxfront/R1.1   return None


def readExperimental(data_exp, host, server='ssh://'):
    '''
    reads experimental data after connecting to the host via ssh server
   38) interpos/9.2.0/intel/17.0
  5) intelmpi/2017--binary   data_exp: data details in dictionary format	
    '''
    import sys
    try:	
 22) git/2.23      import MDSplus
        haveMDS = True
    except:
        39) xmllib/3.3.1/intel/17.0
  6) itm-intelmpi/2017   print(' No MDSplus support found.\n')
        print('\n\n\n Exiting...\n')
        exit(1)

    try:
     23) itm-fftw/3.3.4   conn = MDSplus.Connection(server+host)
      print('Connection OK')
      connected = True
      40) libfortranparser/0.0.6/intel/17.0except:
  7) gnu/7.3.0   print('in readExperimental, MDSplus failed: ',sys.exc_info()[1])
      connected = False

    if connected:
        24) szip/2.1--gnu--6.1.0try:
            EXP={}
      41) keplertools/1.8.9
  8) itm-gcc/7.3.0  for sig in data_exp['dtype']:
                print('reading   25) zlib/1.2.8--gnu--6.1.0dtype: ',sig)
                42) kepler/2.5p5-3.1.1signal= data_exp['dda']+'/'+sig
  9) jdk/1.8.0_111             aux = read_ppf(conn, discharge, signal, seq=data_exp['seq'], uid=data_exp['uid']) 
    26) itm-hdf5/1.8.17-old           # Z coordinate is one dimensional, aux['raw'] is 43) imas-fc2k/4.13.9
 10) itm-java/1.8.0_1112D by default
                if sig=='Z':
      27) pspline/20161207             aux['raw'] = aux['raw'].flatten()

      44) itm-qt/5.8.0
 11) itm-python/3.6       EXP[sig] =  {
             28) slatec/4.1      'time': aux['t'].tolist(),
                    45) imas-viz/2.4.4
 12) matlab/2018b'x':aux['x'].tolist(),
                    'data': aux['raw'].tolist(),
         29) itm-mkl/2017.1          'signal': signal 
           46) idstools/1.5.1
 13) itm-matlab/2018b      }
        except:
       30) itm-matheval/1.1.11    print('in readExperimental, read_ppf failed: ',sys.exc_info()[1])
          47) autoGui/1.15
 14) netbeans/7.3 return None
         del(conn)
    else:
        EXP=None
    31) itm-netcdf/4.4
    return EXP

###########


host='jet'

discharge=99357

# data to download
data={}
data['dda']='hrts'
data['uid'] = 'jetppf'
data['seq']=0
data['dtype']=['TE','DTE','NE','DNE','Z']

EXP=readExperimental(data,host)

if EXP:
    a_file = open('data_jet_fetched_'+str(discharge)+'_'+data['dda']+'_'+str(data['seq'])+'.json', "w")
    json.dump(EXP, a_file)
    a_file.close()


IMAS UDA

It is possible to access and fetch and map data from several  experiments WEST, JET , TCV and AUG using UDA protocol which id described in detailed on ITER confulence pages (requires iter account). Accessing data with UDA needs to be adapted due to recent (Aug 2021) change in connection protocol.

Saving data to IMAS

Before saving the experimental data to imas it is important check which version of imas data dictonary we are using.

You may load (or you may use scripts that load) IMAS environment without specifying the version

Code Block
module purge
module load cineca
module load imasenv

The last line loads imas data dictionary and also idstools which will be used later.

However, loading imasenv does not necessarily provide you with the latest version of data dictionary. In this case: 

Code Block
languagebash
title>module list
collapsetrue
~>module list
Currently Loaded Modulefiles:
  1) profile/archive                      48) ggd/1.9.1/intel/17.0/imas/3.29.0
 15) itm-maven/3.3.9                      32) nag/mark26--binary                   49) libbds/1.0.2/intel/17.0/imas/3.29.0
 16) scripts/R4.9                         33) itm-nag/mark26--binary               5018) amnscmake/1.3.3/intel/17.0/imas5.2                          35) IMAS/3.29.0/AL/4.8.3
  172) totalview/2017.3.8cineca                   34) uda/2.2.5           19) mdsplus/7.92.0/gcc/4.8                5136) imasenvitm-blas/3.298.0/intel/rc

...

17.0
  3) intel/pe-xe-2017--binary             20) blitz/1.0.1                          37) itm-lapack/3.8.0/intel/

...

17.0
  4) itm-intel/17.0                       21) jaxfront/R1.1                        38) interpos/9.2.0/intel/17.0
  5) intelmpi/2017--binary                22) git/2.23                             39) xmllib/3.3.1/intel/17.0
  6) itm-intelmpi/2017                    23) itm-fftw/3.3.4                       40) libfortranparser/0.0.6/intel/17.0
  7) gnu/7.3.0                            24) szip/2.1--gnu--6.1.0                 41) keplertools/1.8.9
  8) itm-gcc/7.3.0                        25) zlib/1.2.8--gnu--6.1.0               42) kepler/2.5p5-3.1.1
  9) jdk/1.8.0_111                        26) itm-hdf5/1.8.17-old                  43) imas-fc2k/4.13.9
 10) itm-java/1.8.0_111                   27) pspline/20161207                     44) itm-qt/5.8.0
 11) itm-python/3.6                       28) slatec/4.1                           45) imas-viz/2.4.4
 12) matlab/2018b                         29) itm-mkl/2017.1                       46) idstools/1.5.1
 13) itm-matlab/2018b                     30) itm-matheval/1.1.11                  47) autoGui/1.15
 14) netbeans/7.3                         31) itm-netcdf/4.4                       48) ggd/1.9.1/intel/17.0/imas/3.29.0
 15) itm-maven/3.3.9                      32) nag/mark26--binary                   49) libbds/1.0.2/intel/17.0/imas/3.29.0
 16) scripts/R4.9                         33) itm-nag/mark26--binary               50) amns/1.3.3/intel/17.0/imas/3.29.0
 17) totalview/2017.3.8                   34) uda/2.2.5                            51) imasenv/3.29.0/intel/rc

we loaded version 3.29.0/intel/rc . If you want to load the latest version data dictionary check first what versions are available with a command "module avail <required module>":

Code Block
languagebash
title>module avail imasenv
collapsetrue
~>module avail imasenv

---------------------------------------------------------- /gw/modules/environment ----------------------------------------------------------
imasenv/3.10.2                imasenv/3.23.1/ual/4.0.3/1.4  imasenv/3.26.0/gcc/7.3.0/rc   imasenv/3.31.0/intel/17.0/1.0
imasenv/3.11.0                imasenv/3.23.1/ual/4.0.3/1.5  imasenv/3.26.0/intel/17.0/rc  imasenv/3.31.0/intel/17.0/1.1
imasenv/3.12.1                imasenv/3.23.1/ual/4.0.3/1.6  imasenv/3.26.0/intel/rc       imasenv/3.31.0/intel/17.0/rc
imasenv/3.15.1                imasenv/3.23.1/ual/4.0.4/1.0  imasenv/3.26.0/rc             imasenv/3.31.0/intel/rc
imasenv/3.16.0                imasenv/3.23.1/ual/4.0.4/1.1  imasenv/3.28.0/gcc/7.3.0/rc   imasenv/3.31.0/rc
imasenv/3.17.0                imasenv/3.23.1/ual/4.0.4/1.2  imasenv/3.28.0/intel/17.0/rc  imasenv/3.32.0/gcc/7.3.0/rc
imasenv/3.17.1                imasenv/3.23.1/ual/4.1.0/1.0  imasenv/3.28.0/intel/rc       imasenv/3.32.0/intel/17.0/rc
imasenv/3.18.0                imasenv/3.23.2/rc             imasenv/3.28.0/rc             imasenv/3.32.0/intel/rc
imasenv/3.19.0                imasenv/3.23.2/ual/4.1.1/1.0  imasenv/3.28.1/gcc/7.3.0/1.0  imasenv/3.32.0/rc
imasenv/3.19.1                imasenv/3.23.2/ual/4.1.2/0.2  imasenv/3.28.1/gcc/7.3.0/rc   imasenv/3.32.1/gcc/7.3.0/rc
imasenv/3.20.0                imasenv/3.23.2/ual/4.1.2/1.0  imasenv/3.28.1/intel/17.0/1.0 imasenv/3.32.1/intel/17.0/rc
imasenv/3.21.0/ual/3.8.10/1.0 imasenv/3.23.2/ual/4.1.4/0.2  imasenv/3.28.1/intel/17.0/rc  imasenv/3.32.1/intel/rc
imasenv/3.21.0/ual/3.8.5/1.0  imasenv/3.23.2/ual/4.1.4/1.0  imasenv/3.28.1/intel/rc       imasenv/3.32.1/rc
imasenv/3.21.0/ual/3.8.8/1.0  imasenv/3.23.2/ual/4.1.5/1.0  imasenv/3.28.1/rc             imasenv/3.33.0/gcc/7.3.0/rc
imasenv/3.21.1/ual/4.0.0/1.0  imasenv/3.23.2/ual/4.1.5/1.1  imasenv/3.29.0/gcc/7.3.0/1.0  imasenv/3.33.0/intel/17.0/rc
imasenv/3.21.1/ual/4.0.1/1.0  imasenv/3.23.2/ual/4.1.5/1.2  imasenv/3.29.0/gcc/7.3.0/rc   imasenv/3.33.0/intel/rc
imasenv/3.22.0/ual/4.0.2/1.0  imasenv/3.24.0/rc             imasenv/3.29.0/intel/17.0/1.0 imasenv/3.33.0/rc
imasenv/3.22.0/ual/4.0.2/1.1  imasenv/3.24.0/ual/4.1.5/1.0  imasenv/3.29.0/intel/17.0/rc  imasenv/3.7.4
imasenv/3.22.0/ual/4.0.2/1.2  imasenv/3.24.0/ual/4.2.0/1.0  imasenv/3.29.0/intel/rc       imasenv/3.8.0
imasenv/3.22.0/ual/4.0.2/1.3  imasenv/3.25.0/gcc/6.1.0/1.0  imasenv/3.29.0/rc             imasenv/3.9.0
imasenv/3.22.0/ual/4.0.2/1.4  imasenv/3.25.0/gcc/6.1.0/rc   imasenv/3.30.0/gcc/7.3.0/rc   imasenv/3.9.1
imasenv/3.22.0/ual/4.0.2/1.5  imasenv/3.25.0/gcc/7.3.0/1.0  imasenv/3.30.0/intel/17.0/rc  imasenv/newLL/3.18.0
imasenv/3.22.0/ual/4.0.2/1.6  imasenv/3.25.0/gcc/7.3.0/rc   imasenv/3.30.0/intel/rc       imasenv/test
imasenv/3.22.0/ual/4.0.2/1.7  imasenv/3.25.0/gcc/rc         imasenv/3.30.0/rc             imasenvX/3.19.1/ual/3.8.2/1.0
imasenv/3.22.0/ual/4.0.2/1.8  imasenv/3.25.0/intel/17.0/1.0 imasenv/3.31.0/1.0            imasenvX/3.20.0/ual/3.8.3/1.0
imasenv/3.23.1/ual/4.0.3/1.0  imasenv/3.25.0/intel/17.0/rc  imasenv/3.31.0/1.1            imasenvX/3.20.0/ual/3.8.5/1.0
imasenv/3.23.1/ual/4.0.3/1.1  imasenv/3.25.0/intel/rc       imasenv/3.31.0/gcc/7.3.0/1.0  imasenvX/3.21.0/ual/3.8.5/1.0
imasenv/3.23.1/ual/4.0.3/1.2  imasenv/3.25.0/rc             imasenv/3.31.0/gcc/7.3.0/1.1
imasenv/3.23.1/ual/4.0.3/1.3  imasenv/3.25.0/ual/4.2.0/1.0  imasenv/3.31.0/gcc/7.3.0/rc

From the above output we conclude that the latest data dictionary version is 'imasenv/3.33.0/rc'. Using the above list you can also choose a different version if there is such a need.

Let's switch to the latest imas release available on the gateway:

Code Block
module unload imasenv
module load imasenv/3.33.0/rc


You can now check if there exists ids to store the experimental data by typing: 

Code Block
dd_doc

Above command opens data dictionary by default in Konqueror. If option "Show/hide error bars" doesn't work, copying the address to Firefox will help. 

By browsing data dictionaries you will find needed fiields. If there are no required fields then a request has to be raised.

Image Added

Image Added


Saving Thomson scattering data

In our example we want to save Thomson scattering data. You can find the corresponding ids in the list above.  Let's browse this ids.


Image Added

We can imediately notice that there are structures introduced in imas version 3.32.1. Apart from experimentally measured values we can also save other experimental data like coordinates of line-of-sight of particular measurement.

Data is structured in such a way that we have to choose channel first to browse further for place to save measured values:

Image Added

Note: channel[i1].position.r and channel[i1].position.z are scalars.

Let's assume we want to save measured HRTS profiles of electron temperature and density with errors for the JET shot 99357. 

After fetching data from JET (dda='hrts', uid = 'jetppf', seq=0, dtype= ['TE', 'DTE', 'NE', 'DNE', 'Z']) we saved it in a dictionary with the following structure:

Code Block
titleFetched HRTS data
# hrts data with sig='TE','DTE','NE','DNE','Z' 
#    hrts[sig]={
#        'time': t, #1D float
#        'x':x, #1D float R coordinate
#        'data': data, #2D float except sig='Z'
#        'signal': signal,
#        'seq':sequence,
#        'uid':owner,
#        'dda':dda
#               }
# 'data' is 2D data[i,j] where i=time_slice index and j= x_value index 

'data' array consist of 701 time slices (from around t=40s to t=75s) and 63 experimental points.

Code Block
titlesaving to imas
import json
import imas,os,datetime,sys
import getpass
import numpy as np
from imas import imasdef
 

db = 'data_access_tutorial'
shot=99357 
run=1

#creates the Data Entry object 'data_entry', a kind of handler of the pulse file with sho, run, belonging to database 'data_access_tutorial' of the current user, using the MDS+ backend
data_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, db, shot, run, user_name=getpass.getuser())
#data_entry = imas.DBEntry(imasdef.HDF5_BACKEND, db, shot, run, user_name=getpass.getuser())
# Open save data_entry to data base

# Tries to open data_entry
op = data_entry.open()
#open() and create(0 return a tuple (x_int,y_int) where x<0, y>0, x number of failures, y number of successes in the current session. 
#if open fails, create data_entry
if op[0]<0:
     cp=data_entry.create()
     if cp[0]==0:
        print("data entry created")
elif op[0]==0:
    print("data entry opened")	

# Open file with fetched data, the data is not numpy array format
with open("data/data_jet_hrts_99357.json") as json_file:
    hrts=json.load(json_file)

x_coord=np.array(hrts['TE']['x'])
# no. of space points
nb_points = len(x_coord)
#no of time slices
nb_slices=len(hrts['TE']['time'])

#creating the 'thomson_scattering' auxiliary IDS and initializing it
thomson = imas.thomson_scattering() #creates a 'thomson scattering' IDS
thomson.ids_properties.homogeneous_time=1 #setting the homogeneous time (mandatory)	
thomson.ids_properties.comment='IDS created for testing the IMAS Data Access layer' #setting the ids_properties.comment attribute
#thomson.time=np.array([0.]) #the time(vector) basis must be not empty if homogeneous_time==1 otherwise an error will occur at runtime

# since all data is available we can save whole time vector at once
thomson.time=np.array(hrts['TE']['time'])

thomson.ids_properties.creation_date = datetime.datetime.now().strftime("%y-%m-%d")
# the number of channel corresponds to number of data points
thomson.channel.resize(nb_points)

for j in range(nb_points):
    thomson.channel[j].t_e.data.resize(1)
    thomson.channel[j].t_e.data_error_upper.resize(1)
    thomson.channel[j].n_e.data.resize(1)
    thomson.channel[j].n_e.data_error_upper.resize(1)

# python interface accepts only numpy arrays to be saved in ids
te_data = np.array(hrts['TE']['data']) #2D
dte_data = np.array(hrts['DTE']['data'])#2D
ne_data = np.array(hrts['NE']['data'])#2D
dne_data = np.array(hrts['DNE']['data'])#2D	
z_data = np.array(hrts['Z']['data']) #1D
r_data = np.array(hrts['TE']['x']) #1D
	
for j in range(nb_points):
    thomson.channel[j].position.r=r_data[j]
    thomson.channel[j].position.z=z_data[j] 
    thomson.channel[j].t_e.data=te_data[:,j]
    thomson.channel[j].t_e.data_error_upper=dte_data[:,j]
    thomson.channel[j].n_e.data=ne_data[:,j]
    thomson.channel[j].n_e.data_error_upper=dne_data[:,j]

sequence = hrts['TE']['seq'] 
data_entry.put(thomson,seq)# the last number is the occurence which can be used to store the data sequence number
#closing the Data Entry
data_entry.close()  

Note, that we used (once and outside the loop) only one command 'data_entry.put(thomson)' to save the data. Since we had all data available at once we didn't need to use put and putSlice commands to save time slice by time slice. However, the two approaches should be equivalent and provide the same ids. The first one is faster as procedure of saving the data in the physical memory is performed only once.

If the data was saved with MDSPLUS backend , the shot number is included in the data files names and is saved in the following folder:

Code Block
> ~/public/imasdb/data_access_tutorial/3/0>ls
ids_150000001.characteristics  ids_150000001.tree             ids_993570001.datafile
ids_150000001.datafile         ids_993570001.characteristics  ids_993570001.tree

If the data is saved using HDF5 backend, the shot number is included in the data tree folder names and is saved in the following folder:

Code Block
> ~/public/imasdb/data_access_tutorial/3/99357/1>ls
master.h5  thomson_scattering.h5

If you used HDF5 backend you can check if the data was stored correctly in the ids directly with the command:

Code Block
>~/public/imasdb/data_access_tutorial/3/99357/1>h5dump thomson_scattering.h5  |less


Code Block
titleh5dump output
collapsetrue
HDF5 "thomson_scattering.h5" {
GROUP "/" {
   ATTRIBUTE "HDF5_BACKEND_VERSION" {
      DATATYPE  H5T_STRING {
         STRSIZE 10;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_UTF8;
         CTYPE H5T_C_S1;
      }
      DATASPACE  SCALAR
      DATA {
      (0): "1.0"
      }
   }
   ATTRIBUTE "RUN" {
      DATATYPE  H5T_STD_I32LE
      DATASPACE  SCALAR
      DATA {
      (0): 1
      }
   }
   ATTRIBUTE "SHOT" {
      DATATYPE  H5T_STD_I32LE
      DATASPACE  SCALAR
      DATA {
      (0): 99357
      }
   }
   GROUP "thomson_scattering" {
      DATASET "channel[]&AOS_SHAPE" {
         DATATYPE  H5T_STD_I32LE
         DATASPACE  SIMPLE { ( 1 ) / ( H5S_UNLIMITED ) }
         DATA {
         (0): 63
         }
      }
      DATASET "channel[]&n_e&data" {
         DATATYPE  H5T_IEEE_F64LE
         DATASPACE  SIMPLE { ( 63, 701 ) / ( H5S_UNLIMITED, H5S_UNLIMITED ) }
         DATA {
         (0,0): 1e-20, 1e-20, 1.74005e+18, 3.30191e+18, 4.63574e+18,
         (0,5): 5.01502e+18, 7.16228e+18, 9.61972e+18, 1.14838e+19,
         (0,9): 1.26156e+19, 1.40738e+19, 1.49135e+19, 1.7819e+19,
         (0,13): 1.69414e+19, 1.83607e+19, 1.80031e+19, 1.95752e+19,
         (0,17): 1.92397e+19, 1.74838e+19, 1.87457e+19, 1.84743e+19,
         (0,21): 1.99327e+19, 1.93234e+19, 1.93735e+19, 2.02663e+19,
         (0,25): 1.82691e+19, 1.79814e+19, 1.55414e+19, 1.5825e+19,
         (0,29): 1.47801e+19, 1.63837e+19, 1.40053e+19, 1.41187e+19,
         (0,33): 1.46383e+19, 1.25988e+19, 1.40001e+19, 1.20421e+19,
         (0,37): 1.31313e+19, 1.51261e+19, 1.39026e+19, 1.41953e+19,
         (0,41): 1.52628e+19, 1.4697e+19, 1.56486e+19, 1.55934e+19,
         (0,45): 1.79571e+19, 1.52815e+19, 1.73831e+19, 1.69241e+19,
         (0,49): 1.80319e+19, 1.77864e+19, 1.8345e+19, 1.91198e+19,
         (0,53): 1.7536e+19, 2.03026e+19, 1.91662e+19, 1.97445e+19,
:               
Code Block
languagebash
title>module avail imasenv
collapsetrue
~>module avail imasenv

---------------------------------------------------------- /gw/modules/environment ----------------------------------------------------------
imasenv/3.10.2                imasenv/3.23.1/ual/4.0.3/1.4  imasenv/3.26.0/gcc/7.3.0/rc   imasenv/3.31.0/intel/17.0/1.0
imasenv/3.11.0                imasenv/3.23.1/ual/4.0.3/1.5  imasenv/3.26.0/intel/17.0/rc  imasenv/3.31.0/intel/17.0/1.1
imasenv/3.12.1                imasenv/3.23.1/ual/4.0.3/1.6  imasenv/3.26.0/intel/rc       imasenv/3.31.0/intel/17.0/rc
imasenv/3.15.1                imasenv/3.23.1/ual/4.0.4/1.0  imasenv/3.26.0/rc             imasenv/3.31.0/intel/rc
imasenv/3.16.0                imasenv/3.23.1/ual/4.0.4/1.1  imasenv/3.28.0/gcc/7.3.0/rc   imasenv/3.31.0/rc
imasenv/3.17.0                imasenv/3.23.1/ual/4.0.4/1.2  imasenv/3.28.0/intel/17.0/rc  imasenv/3.32.0/gcc/7.3.0/rc
imasenv/3.17.1                imasenv/3.23.1/ual/4.1.0/1.0  imasenv/3.28.0/intel/rc       imasenv/3.32.0/intel/17.0/rc
imasenv/3.18.0                imasenv/3.23.2/rc             imasenv/3.28.0/rc             imasenv/3.32.0/intel/rc
imasenv/3.19.0                imasenv/3.23.2/ual/4.1.1/1.0  imasenv/3.28.1/gcc/7.3.0/1.0  imasenv/3.32.0/rc
imasenv/3.19.1                imasenv/3.23.2/ual/4.1.2/0.2  imasenv/3.28.1/gcc/7.3.0/rc   imasenv/3.32.1/gcc/7.3.0/rc
imasenv/3.20.0                imasenv/3.23.2/ual/4.1.2/1.0  imasenv/3.28.1/intel/17.0/1.0 imasenv/3.32.1/intel/17.0/rc
imasenv/3.21.0/ual/3.8.10/1.0 imasenv/3.23.2/ual/4.1.4/0.2  imasenv/3.28.1/intel/17.0/rc  imasenv/3.32.1/intel/rc
imasenv/3.21.0/ual/3.8.5/1.0  imasenv/3.23.2/ual/4.1.4/1.0  imasenv/3.28.1/intel/rc       imasenv/3.32.1/rc
imasenv/3.21.0/ual/3.8.8/1.0  imasenv/3.23.2/ual/4.1.5/1.0  imasenv/3.28.1/rc             imasenv/3.33.0/gcc/7.3.0/rc
imasenv/3.21.1/ual/4.0.0/1.0  imasenv/3.23.2/ual/4.1.5/1.1  imasenv/3.29.0/gcc/7.3.0/1.0  imasenv/3.33.0/intel/17.0/rc
imasenv/3.21.1/ual/4.0.1/1.0  imasenv/3.23.2/ual/4.1.5/1.2  imasenv/3.29.0/gcc/7.3.0/rc   imasenv/3.33.0/intel/rc
imasenv/3.22.0/ual/4.0.2/1.0  imasenv/3.24.0/rc             imasenv/3.29.0/intel/17.0/1.0 imasenv/3.33.0/rc
imasenv/3.22.0/ual/4.0.2/1.1  imasenv/3.24.0/ual/4.1.5/1.0  imasenv/3.29.0/intel/17.0/rc  imasenv/3.7.4
imasenv/3.22.0/ual/4.0.2/1.2  imasenv/3.24.0/ual/4.2.0/1.0  imasenv/3.29.0/intel/rc                  imasenv/3.8.0
imasenv/3.22.0/ual/4.0.2/1.3  imasenv/3.25.0/gcc/6.1.0/1.0  imasenv/3.29.0/rc                     


Reading data


Once the data is saved to ids we can open it and for example plot it:

Code Block
titleopening ids
import imas
import numpy as np
import matplotlib.pyplot  imasenv/3.9.0
imasenv/3.22.0/ual/4.0.2/1.4  imasenv/3.25.0/gcc/6.1.0/rc   imasenv/3.30.0/gcc/7.3.0/rc   imasenv/3.9.1
imasenv/3.22.0/ual/4.0.2/1.5  imasenv/3.25.0/gcc/7.3.0/1.0  imasenv/3.30.0/intel/17.0/rc  imasenv/newLL/3.18.0
imasenv/3.22.0/ual/4.0.2/1.6  imasenv/3.25.0/gcc/7.3.0/rc   imasenv/3.30.0/intel/rc       imasenv/test
imasenv/3.22.0/ual/4.0.2/1.7  imasenv/3.25.0/gcc/rc         imasenv/3.30.0/rc             imasenvX/3.19.1/ual/3.8.2/1.0
imasenv/3.22.0/ual/4.0.2/1.8  imasenv/3.25.0/intel/17.0/1.0 imasenv/3.31.0/1.0            imasenvX/3.20.0/ual/3.8.3/1.0
imasenv/3.23.1/ual/4.0.3/1.0  imasenv/3.25.0/intel/17.0/rc  imasenv/3.31.0/1.1            imasenvX/3.20.0/ual/3.8.5/1.0
imasenv/3.23.1/ual/4.0.3/1.1  imasenv/3.25.0/intel/rc       imasenv/3.31.0/gcc/7.3.0/1.0  imasenvX/3.21.0/ual/3.8.5/1.0
imasenv/3.23.1/ual/4.0.3/1.2  imasenv/3.25.0/rc             imasenv/3.31.0/gcc/7.3.0/1.1
imasenv/3.23.1/ual/4.0.3/1.3  imasenv/3.25.0/ual/4.2.0/1.0  imasenv/3.31.0/gcc/7.3.0/rc

From the above output we conclude that the latest data dictionary version is 'imasenv/3.33.0/rc'. Using the above list you can also choose a different version if there is such a need.

Let's switch to the latest imas release available on the gateway:

Code Block
module unload imasenv
module load imasenv/3.33.0/rc

You can now check if there exists ids to store the experimental data by typing: 

Code Block
dd_doc

Above command opens data dictionary by default in Konqueror. If option "Show/hide error bars" doesn't work, copying the address to Firefox will help. 

as plt
import sys
from imas import imasdef

db = 'data_access_tutorial'
shot=99357 
run=1

#creating the Data Entry object which handles the pulse file with shot=15000, run=1, belonging to database 'data_access_tutorial' of the current user, using the MDS+ backend
#data_entry = imas.DBEntry(imasdef.HDF5_BACKEND, db, shot, run, user_name=getpass.getuser())
data_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, db, shot, run, user_name=getpass.getuser())


#opening the pulse file handled by the Data Entry object previously created
data_entry.open()
 
#getting a slice at time=1s using the closest time slice interpolation
time_requested=50.
sslice = data_entry.get_slice('thomson_scattering', time_requested, imasdef.CLOSEST_INTERP)

no_channels=len(sslice.channel)

#[te,dte,ne,dne,r,z] =[np.array([0.0]*no_channels)]*6
te=np.array([])
dte=np.array([])
ne=np.array([])
dne=np.array([])
r=np.array([])

for i in range(no_channels):
    te=np.append(te,sslice.channel[i].t_e.data)
    dte= np.append(dte,sslice.channel[i].t_e.data_error_upper)
    ne=np.append(ne,sslice.channel[i].n_e.data)
    dne= np.append(dne,sslice.channel[i].n_e.data_error_upper)
    r= np.append(r,sslice.channel[i].position.r)
    z[i]= sslice.channel[i].position.z

#closing the Data Entry
data_entry.close()

# plotting
fig1=plt.figure(1)
elinewidth=0.9
capsize=3
ax1=fig1.add_subplot(121)
ax1.errorbar(r,te,yerr=dte,fmt='o',elinewidth=elinewidth,capsize=capsize, color='blue',label=r'$T_e$ at $t='+str(time_requested)+'$ s')
ax1.set_ylim([0.,6.0e3])
ax1.set_xlabel("r (m)",fontsize=14)
ax1.set_ylabel("eV",fontsize=14)
ax1.legend(loc='lower left', bbox_to_anchor=(0.0, 0.0),fontsize=12)

ax2=fig1.add_subplot(122)
ax2.errorbar(r,ne,yerr=dne,fmt='o',elinewidth=elinewidth,capsize=capsize, color='red',label=r'$n_e$ at $t='+str(time_requested)+'$ s')
ax2.set_ylim([0.,7.2e19])
ax2.set_xlabel("r (m)",fontsize=14)
ax2.set_ylabel("$m^{-3}$",fontsize=14)
ax2.legend(loc='lower left', bbox_to_anchor=(0.0, 0.0),fontsize=12)
plt.show()

Image Added


As it can be seen from the plot, the fetched data has not been yet filteredBy browsing data dictionaries you will find needed fiields. If there are no required fields then a request has to be raised.

Unknown User (michal.poradzinski@ifpilm.pl)