Versions Compared

Key

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

...

Code Block
titleopening ids
import imas
import numpy as np
import matplotlib.pyplot 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 filtered.

Unknown User (michal.poradzinski@ifpilm.pl)