...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#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: s = conn.get(c) raw = s.data() dim0 = conn.get('dim_of(_sig,0)').data() try: dim1 = conn.get('dim_of(_sig,1)').data() return {'raw': raw, 'x':dim0, 't':dim1} except: return {'raw': raw, 't':dim0} except: return None def readExperimental(data_exp, host, server='ssh://'): ''' reads experimental data after connecting to the host via ssh server data_exp: data details in dictionary format ''' import sys try: import MDSplus haveMDS = True except: print(' No MDSplus support found.\n') print('\n\n\n Exiting...\n') exit(1) try: conn = MDSplus.Connection(server+host) print('Connection OK') connected = True except: print('in readExperimental, MDSplus failed: ',sys.exc_info()[1]) connected = False if connected: try: EXP={} for sig in data_exp['dtype']: print('reading dtype: ',sig) signal= data_exp['dda']+'/'+sig aux = read_ppf(conn, discharge, signal, seq=data_exp['seq'], uid=data_exp['uid']) #conv = read_ppf(conn,args.Shot, 'WSXP/RHOT', seq=args.seq, uid=args.uid) #print("rhot:dx ", conv['x']-aux['x']) #print('rhot[raw]:', conv['raw']) print('len(x): ',len(aux['x'])) print('time: ',aux['t'][0],aux['t'][-1],len(aux['t'])) print('shape(value):',aux['raw'].shape) print('len(aux)', len(aux)) print('') #EXP=None EXP[sig] = { 'time': aux['t'], 'x':aux['x'], 'data': aux['raw'], 'signal': signal #'rhot' : np.sqrt(conv['raw']) } except: print('in readExperimental, read_ppf failed: ',sys.exc_info()[1]) return None del(conn) else: EXP=None 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 False: a_file = open("data_jet_ssh_fetched.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.
...