pro mdswrite ; ; IDL example to write new stripped down MDSplus tree at tokamak-profiledb.ccfe.ac.uk ; Example shows filling each node type: comments, zerod, oned, and twod ; ; Colin Roach + Malcolm Walters March 2004 ; ; First connect to the server ; mdsconnect,'tokamak-profiledb.ccfe.ac.uk' ; ; pick tree and shot number ; eg this example is to submit a d3d discharge to the working profile database ; ( to submit aug discharge to the itb database set tree='i_itb_aug' ) ; nb incoming treename has 'i_' as prefix before the profile database treename ; ;############################################################################### ; strangely MDSplus needs shot number >= 100 to avoid padding with zeros ;############################################################################### ; tree='i_d3d' & shot=100 ; ; check if the tree already exists in the transit area ;############################################################################### ; nb for bizarre reasons we need to call mdsopen even if the tree does not exist! ;############################################################################### ; mdsopen,tree,shot,status=status ; ; if the tree is already there, go straight to adding data if (status) then goto,adddata ; ; otherwise copy the model tree ; mdstcl, 'set tree i_d3d',status=status print,"mdstcl, 'set tree '+tree",status mdstcl, 'create pulse '+strtrim(shot,2),status=status print,"mdstcl, 'create pulse'",status ;############################################################################### ; nb for bizarre reasons we need to reconnect (otherwise get mdsvalue errors) ;############################################################################### ; mdsconnect,'tokamak-profiledb.ccfe.ac.uk' ; Open the new tree ; mdsopen,tree,shot,status=status print,"mdsopen",status adddata: print,'Add data' ; Insert the data ; First some comments MdsPut, '\top.COMMENTS:DESCRIPTION', "$", 'Test of MDSplus writing' print,"mdsput setting comment description = ",mdsvalue('\top.comments:description') stop ; Then some 0D data MdsPut, '\top.ZEROD:TOK', "$", 'D3D' MdsPut, '\top.ZEROD:TIME', "$", 100.0 MdsPut, '\top.ZEROD:IP', "$", 50.0 print,"mdsput setting various 0D nodes " stop ; Now some 1D data ip_time=dindgen(1000) & ip=1.0d6*(1.0d0-exp(-(ip_time)/100)) plot,ip_time,ip,xtitle='time',title='current',charsize=2 MdsPut, '\top.ONED:IP','build_signal(build_with_units($,$),*,build_with_units($,$))',IP,'Amps',IP_TIME,'Seconds' print,"mdsput setting various 1D IP node" stop ; some 2D data ; nt=10 & nx=50 x=dindgen(nx)/double(nx-1) & t=dindgen(nt) ne0=1.0d19*(1.0d0-x^2) dene=dindgen(nx,nt) for i=0,nt-1 do dene(*,i)=ne0*(t(nt-1)^2-0.5d0*(t(i)-t(nt-1))^2) surface,dene,x,t,xtitle='x',ytitle='time',title='Density',charsize=2 MdsPut, '\top.TWOD:NE', 'build_signal(build_with_units($,$),*,build_with_units($,$),build_with_units($,$))',dene,'m-3',x,'rho',t,'Seconds' print,"mdsput setting the 2D NE signal" EQU: ; add PSIRZ to the equilibrium branch ; nr=32 & nz=32 & nt=3 r=dindgen(nr)/double(nr-1) & z=dindgen(nz)/double(nz-1)-0.5d0 & t=dindgen(nt) psirz=dindgen(nr,nz,nt) for it=0,nt-1 do begin for iz=0,nz-1 do begin psirz(*,iz,it)=t[it]*exp(-((r-0.5d0)^2+z[iz]^2)) endfor endfor !p.multi=[0,2,2] surface,psirz[*,*,0],r,z,xtitle='R',ytitle='Z',title='PSIRZ',charsize=2 surface,psirz[*,*,1],r,z,xtitle='R',ytitle='Z',title='PSIRZ',charsize=2 surface,psirz[*,*,2],r,z,xtitle='R',ytitle='Z',title='PSIRZ',charsize=2 ; MdsPut, '\top.EQUIL:PSIRZ', 'build_signal(build_with_units($,$),*,build_with_units($,$),build_with_units($,$),build_with_units($,$))',psirz,'Wb/rad',r,'R (m)',z,'Z (m)',t,'t (s)' print,"mdsput setting signal EQUIL:PSIRZ" ; Close this pulse close: mdsclose ;Since we aren't doing any more pulses disconnect. mdsdisconnect end