| Access |
| Data Access - Examples |
Examples - IDL
An \IPD vs \TIMED scatter plot for all D3D shots The first example will retrieve \IPD and \TIMED from the MDSplus Disruption Database on iddb.gat.com:9000. The function will store the values of \IPD and \TIMED from each shot, and return them to the caller in a structure. This function uses the MDSplus IDL routines: mdsconnect - to connect to the MDSplus Disruption Database server on iddb.gat.com:9000 mdsopen - to open a disruption database tree for a given shot mdsvalue - to retrieve the values of \IPD and \TIMED from the opened MDSplus tree
function fetch_ip,shots,output=output
if (keyword_set(output)) then print,'Connecting to the MDSplus server iddb.gat.com:9000'
mdsconnect,'iddb.gat.com:9000'
ip = findgen(n_elements(shots))
time = findgen(n_elements(shots))
for i=0, n_elements(shots)-1 do begin
if (keyword_set(output)) then print,'Opening MDSplus tree DDB for shot ',shots[i]
mdsopen,'ddb_d3d',shots[i],/quiet
if (keyword_set(output)) then print,'Fetching IP from the D3D data set'
ip[i] = mdsvalue('\IPD',/quiet)
if (keyword_set(output)) then print,'Fetching TIMED from the D3D data set'
time[i] = mdsvalue('\TIMED',/quiet)
endfor
s = create_struct('ip',ip,'time',time)
return,s
end
For this example, we will run the IDL code fetch_ip.pro for all D3D shots in the MDSplus Disruption Database. After the data has been retrieved, a scatter plot is created of \IPD vs \TIMED for all requested shots. IDL Version 6.0, Mac OS X (darwin ppc m32). (c) 2003, Research Systems, Inc.
Installation number: 18436.
Licensed for use by: General Atomics, San Diego
IDL> shots = [73883,81166,81167,81168,82788,84324,84347,84353,84356,84358,84360,84361,
84362,86297,86310,87030,87034,87857,87908,87944,87946,87949,87954,87958,88473,88800,
88805,88807,88809,88812,88815,88816,88817,88819,88821,88824,88826,88961,88968,90205,
90206,90207,90212,93082,95194,95195,95196,96757,96762,96763,96764,96767,104028,104029,
104030,104031,104032,106374,106375,106376,106378,106379,107430,107431,107840,107841,
107844,107846,107847,107850,107851,114878,114879,114881,115508,115509,115510,115512,115513]
IDL> s = fetch_ip(shots)
% Compiled module: FETCH_IP.
% Compiled module: MDSCONNECT.
% Compiled module: MDSDISCONNECT.
% Compiled module: MDSOPEN.
% Compiled module: MDSVALUE.
% Compiled module: MDSCHECKARG.
% Compiled module: MDSISCLIENT.
IDL> plot, s.time, s.ip, /psym, title='IPD vs TIMED (D3D shots)'
![]()
A scatter plot of scaled current quench time vs. initial average current density for all D3D shots The second example will retrieve data from the MDSplus Disruption Database on iddb.gat.com:9000. This procedure will then run the disruption through a small calcuation and automatically produce the scatter plot for scaled current quench time vs. initial average current density. pro recall_plot,shots
mdsconnect,'iddb.gat.com:9000'
nsh=n_elements(shots)
time8=fltarr(nsh) & time2=fltarr(nsh) & ip0=fltarr(nsh)
area=fltarr(nsh) & kappa=fltarr(nsh) & aminor=fltarr(nsh)
tau_a=fltarr(nsh) & tau_k=fltarr(nsh) & jp0=fltarr(nsh)
for i=0,n_elements(shots)-1 do begin
mdsopen,'ddb_d3d',shots[i],/quiet
time8[i]=mdsvalue('\time8',/quiet) ; time is in millisecs
time2[i]=mdsvalue('\time2',/quiet) ; time is in millisecs
ip0[i]=mdsvalue('\ipd',/quiet) ; Ip is in MA
area[i]=mdsvalue('\aread',/quiet) ; crossectional area in m^2
kappa[i]=mdsvalue('\kappad',/quiet)
aminor[i]=mdsvalue('\amind',/quiet)
if(area[i] le 0.0) then area[i]=!VALUES.F_NAN
endfor
tau_a=(time2-time8)/area
tau_k=(time2-time8)/(kappa*aminor*aminor*!PI)
jp0 =ip0/area
jp0_k =ip0/(kappa*aminor*aminor*!PI)
dum=symbol8('c',1)
plot,jp0,tau_a,psym=8,symsize=1.0, $
title='Scaled CQ time v Average initial current density', $
xtitle='j0 [Ip0/S] (MA/m^2)', $
ytitle='Tau_60/S (ms/m^2)'
oplot,[.25,.25],[6.6,6.6],psym=8,symsize=1.0
xyouts,-8e5,0.010,'S = Plasma Cross-section area'
xyouts,-8e5,0.009,'S = PI*kappa0*aminor0^2'
dum=symbol8('c',0)
oplot,[.25,.25],[7.1,7.1],psym=8,symsize=1.0
oplot,jp0_k,tau_k,psym=8,symsize=1.0
end
Now, we will run the IDL code recall_plot.pro for all D3D shots in the Disruption Database. IDL Version 6.0 (linux x86 m32). (c) 2003, Research Systems, Inc.
Installation number: 18436.
Licensed for use by: General Atomics, San Diego
IDL> shots = [73883,81166,81167,81168,82788,84324,84347,84353,84356,84358,84360,84361,
84362,86297,86310,87030,87034,87857,87908,87944,87946,87949,87954,87958,88473,88800,
88805,88807,88809,88812,88815,88816,88817,88819,88821,88824,88826,88961,88968,90205,
90206,90207,90212,93082,95194,95195,95196,96757,96762,96763,96764,96767,104028,104029,
104030,104031,104032,106374,106375,106376,106378,106379,107430,107431,107840,107841,
107844,107846,107847,107850,107851,114878,114879,114881,115508,115509,115510,115512,115513]
IDL> recall_plot,shots
% Compiled module: RECALL_PLOT.
% Compiled module: MDSCONNECT.
% Compiled module: MDSDISCONNECT.
% Compiled module: MDSOPEN.
% Compiled module: MDSVALUE.
% Compiled module: MDSCHECKARG.
% Compiled module: MDSISCLIENT.
% Compiled module: SYMBOL8.
IDL>
![]()
;;;;;;;;;;;;;; define a symbol ;;;;;;;;;;;;;;;;;;;
; This function allows user choice of several open or filled symbols.
; To use these defined symbols set PSYM=8 in the plot call.
;
; The default symbol size is roughly one character high. To halve size,
; use SYMSIZE=0.5 in plot call.
; The symbol is plotted centered on the data point.
;
; INPUTS:
; type = 'c' circle
; 's' square
; 'd' diamond (square rotated 90 degrees)
; 't' triangle
; 'td' downward pointing triangle
; 'star' 4-point star (diamond /w curved sides)
; note type is case sensitive.
;
; filled = 0 open symbol
; 1 solid symbol
;
; thickline = (1) open symbol linewidth default.
; Can be set to any integer; larger
; means thicker line. 1 is thinnest
; OUTPUT:
; dummy = 1 dummy output so function call can be used
; to set user symbol with variable input
; USAGE:
; dum=symbol8() defaults to open unit circle, thin line
; dum=symbol8('t') select triangle symbol, defaults to open symbol
; dum=symbol8('t',1) select triangle, make solid
; dum=symbol8('t',0,2) select triangle, use next thicker line
;
; awh 10-1-98
function symbol8,type,filled,thickline,dummy
dummy=1
if n_elements(thickline) eq 0 then thickline=1
if n_elements(type) eq 0 then type='def'
if n_elements(filled) eq 0 then filled=-1
asym=findgen(37)*(!PI*2/36.0) ; divide 2*pi into 36 points
case type of
'c': begin
xvec=cos(asym) & yvec=sin(asym) ; the unit circle's x,y coords
end
's': begin
xvec=[-1, -1, 1, 1, -1]/sqrt(2) & yvec=[-1, 1, 1, -1, -1]/sqrt(2)
end
'd': begin
xvec=[-1, 0, 1, 0, -1] & yvec=[0, 1, 0, -1, 0]
end
't': begin
xvec=[0, 1.5/sqrt(3), -1.5/sqrt(3), 0] & yvec=[1, -0.5, -0.5, 1]
end
'td': begin
xvec=[0, 1.5/sqrt(3), -1.5/sqrt(3), 0] & yvec=[-1, 0.5, 0.5, -1]
end
'star': begin
Q1=asym(0:8)&Q2=asym(9:17)&Q3=asym(18:26)&Q4=asym(27:35)
xvec=cos(Q1)-1. & yvec=sin(Q1)-1.
xvec=[xvec,cos(Q4)-1.] & yvec=[yvec,sin(Q4)+1.]
xvec=[xvec,cos(Q3)+1.] & yvec=[yvec,sin(Q3)+1.]
xvec=[xvec,cos(Q2)+1.,0] & yvec=[yvec,sin(Q2)-1.,-1.]
end
else: begin
xvec=cos(asym) & yvec=sin(asym) ; the unit circle is the default
end
endcase
case filled of
0: usersym, xvec, yvec, thick=thickline ; open unit symbol
; the unit is about the size of a character
1: usersym, xvec, yvec, /fill ; filled unit symbol
else: usersym, xvec, yvec, thick=thickline ; default unit circle defined by 36 points
endcase
; psym = 8 selects the usersym
return, dummy
end
Retrieving all shot numbers for a given MDSplus tree The following IDL code returns all shot numbers for a given tree name that are available on the MDSplus server. The function makes use of the TDI call FINDFILE, which returns an array of strings (a file name for each shot tree). The second half of the code parses and returns the shot numbers as an array. function getshots,tree
;; USE TDI FUNCTION FINDFILE TO SEARCH FOR MDSPLUS TREES
tree_arg = strtrim(tree,2)+"_path:"+strtrim(tree,2)+"_*.tree"
files = mdsvalue('FINDFILE($)',/quiet,status=s,tree_arg)
;; PARSE SHOT NUMBERS FROM TREE FILE NAMES
if (s) then begin
n = n_elements(files)
shots=lonarr(n)
p0 = strpos(files,'_',/reverse_search)
p1 = strpos(files,'.',/reverse_search)
l = p1-p0-1
for i=0,n-1 do begin
valid=0
ON_IOERROR, not_number
shots[i]=strmid(files[i],p0[i]+1,l[i])
valid=1
not_number: if NOT valid then shots[i] = -1
endfor
shots = temporary(reverse(shots[sort(shots)]))
endif else shots=[0]
return,shots
end
For example, to retrieve a list of all available shots for JET disruption data... eos.gat.com (123): idl
IDL Version 6.0 (linux x86 m32). (c) 2003, Research Systems, Inc.
Installation number: 18436.
Licensed for use by: General Atomics, San Diego
IDL> mdsconnect,'iddb.gat.com:9000'
% Compiled module: MDSCONNECT.
% Compiled module: MDSDISCONNECT.
IDL> jet_shots = getshots("ddb_jet")
% Compiled module: GETSHOTS.
% Compiled module: MDSVALUE.
% Compiled module: MDSCHECKARG.
% Compiled module: MDSISCLIENT.
% Compiled module: REVERSE.
IDL> help,jet_shots
JET_SHOTS LONG = Array[187]
IDL> print,jet_shots[0:10]
63395 63391 63388 63109 63101 62515
62472 60727 60636 60629 60571
|
©2013 General Atomics All Rights Reserved |