pro get_profile,comments,zerod,oned,twod,$ shot=shot,treestub=treestub,pub=pub,work=work,local=local,server=server ; ; IDL procedure to get data from international profile database in mdsplus ; format then load into structures comments,zerod,oned,twod respectively ; ; Begun 3/00 - M. Greenwald ; Modified by C M Roach ; ; Parameters: ; comments, zerod, oned, twod : IDL structures containing data ; shot : shot number ; treestub : tree name (defaults to 'cmod') ; pub : set server to public DB (opt, overrides server) ; work : set server to working DB(opt, overrides server) ; local : set to access localhost (opt, overrides server) ; server : MDSplus server name (opt) ; ; ; For PR98: treestub='pr98_'+tok ; server='tokamak-profiledb.ccfe.ac.uk' ; ; For WDB: treestub=tok ; server='tokamak-profiledb.ccfe.ac.uk:8001' ; (Are you registered?) ; if not keyword_set(shot) then shot ='960116024' if not keyword_set(treestub) then tree_name = "cmod" else tree_name = treestub ; if no server specified, set default server to point to working database ; NB If you can't get access, HAVE YOU REGISTERED? ; To use PR98, set server='tokamak-profiledb.ccfe.ac.uk' if not keyword_set(server) then server='tokamak-profiledb.ccfe.ac.uk' if keyword_set(pub) then server='tokamak-profiledb.ccfe.ac.uk' if keyword_set(work) then server='tokamak-profiledb.ccfe.ac.uk:8001' if keyword_set(local) then server='localhost' if (server ne 'localhost') then mdsconnect,server mdsopen,tree_name,shot,/quiet,status=status if not status then begin print,'-> Error opening shot '+shot+ ' for '+ treestub print,'-> File not found' return end mdstcl,'set default \top' ;make sure default is set ;to top of tree print,'at comments' ;get comments data ; ;note, only get data and structures where data is present ;first get all the nodes under .comments that contain data nids = mdsvalue('getnci(".comments:*","nid_number")',status=status) if ((status/2)*2 eq status) then goto,zerod length = mdsvalue('getnci($,"length")',nids) nids = nids(where (length gt 0)) comment_nodes = strtrim(mdsvalue('getnci($,"node_name")',nids),2) n_comment_nodes = n_elements(comment_nodes) str3 = "comments = {" ;used later to build the structure for i = 0,n_comment_nodes-1 do begin ;loop over each variable ;build the mdsvalue string str = comment_nodes(i) + "= mdsvalue('\top.comments:" + $ comment_nodes(i) + "',/quiet)" result = execute(str) ;optional printout of variables and values ; result2 = execute("print,'" + comment_nodes(i)+" = ',"+comment_nodes(i)) str3 = str3 + comment_nodes(i) +":"+ comment_nodes(i) +"," endfor str3_len = strlen(str3) strput,str3,"}",str3_len-1 print result3 = execute(str3) ;create structure for comments print,'at zerod' ;zerod data ;same approach as above ; ;note, only get data and structures where data is present zerod: nids =mdsvalue('getnci(".zerod:*","nid_number")',status=status) if ((status/2)*2 eq status) then goto,oned length = mdsvalue('getnci($,"length")',nids) nids = nids(where (length gt 0)) zerod_nodes = strtrim(mdsvalue('getnci($,"node_name")',nids),2) n_zerod_nodes = n_elements(zerod_nodes) str3 = "zerod = {" for i = 0,n_zerod_nodes-1 do begin str = zerod_nodes(i) + "= mdsvalue('\top.zerod:" + $ zerod_nodes(i) + "',/quiet)" result = execute(str) ;result2 = execute("print,'" + zerod_nodes(i)+" = ',"+zerod_nodes(i)) str3 = str3 + zerod_nodes(i) +":"+ zerod_nodes(i) +"," endfor str3_len = strlen(str3) strput,str3,"}",str3_len-1 result3 = execute(str3) ;oned data ;for these signals we need to get the time bases as well ;we'll use a more complex structure ;each named variable will have a corresponding _t ;for example amin and amin_t oned = {amin:amin,amin_t:amin_t} ; ;note, only get data and structures where data is present oned: print,'at oned' nids =mdsvalue('getnci(".oned:*","nid_number")',status=status) if ((status/2)*2 eq status) then goto,twod length = mdsvalue('getnci($,"length")',nids) nids = nids(where (length gt 0)) oned_nodes = strtrim(mdsvalue('getnci($,"node_name")',nids),2) n_oned_nodes = n_elements(oned_nodes) str3 = "oned = {" print,'1d nodes=',oned_nodes for i = 0,n_oned_nodes-1 do begin str = oned_nodes(i) + "= mdsvalue('\top.oned:" + $ oned_nodes(i) + "')" result = execute(str) str_t = oned_nodes(i) + "_t = mdsvalue('dim_of(\top.oned:" + $ oned_nodes(i) + ")')" result = execute(str_t) str_u = oned_nodes(i) + "_units = mdsvalue('units_of(\top.oned:" + $ oned_nodes(i) + ")')" result = execute(str_u) str_tu = oned_nodes(i) + "_tunits = mdsvalue('units_of(dim_of(\top.oned:" + $ oned_nodes(i) + "))')" result = execute(str_tu) str3 = str3 + oned_nodes(i) +":"+ oned_nodes(i) +"," + $ oned_nodes(i) +"_t:"+ oned_nodes(i) +"_t," + $ oned_nodes(i) +"_units:"+ oned_nodes(i) +"_units," + $ oned_nodes(i) +"_tunits:"+ oned_nodes(i) +"_tunits," endfor str3_len = strlen(str3) strput,str3,"}",str3_len-1 print,str3 result3 = execute(str3) ;twod data ;for these signals we need to get the time bases and radial ;grid as well ;we'll use a more complex structure ;each named variable will have a corresponding _t and _r ;for example te, te_t and te_r ;twod = {te:te,te_t:te_t,te_r:te_r} ; ;note, only get data and structures where data is present twod: print,'at twod' nids =mdsvalue('getnci(".twod:*","nid_number")',status=status) if ((status/2)*2 eq status) then goto,close length = mdsvalue('getnci($,"length")',nids) nids = nids(where (length gt 0)) twod_nodes = strtrim(mdsvalue('getnci($,"node_name")',nids),2) print,twod_nodes n_twod_nodes = n_elements(twod_nodes) str3 = "twod = {" ;note - if statement to fix IDL problem with variable name ne ;structure will contain dene,dene_t,dene_r - sorry about that j = where(twod_nodes eq "NE") if (j(0) ne -1) then twod_nodes(j) = "DENE" for i = 0,n_twod_nodes-1 do begin if twod_nodes(i) eq "DENE" then begin str = twod_nodes(i) + "= mdsvalue('\top.twod:ne',/quiet)" str_t = twod_nodes(i) + "_t = mdsvalue('dim_of(\top.twod:ne,1)',/quiet)" str_r = twod_nodes(i) + "_r = mdsvalue('dim_of(\top.twod:ne,0)',/quiet)" str_u = twod_nodes(i) + "_units = mdsvalue('units_of(\top.twod:ne)')" str_tu = twod_nodes(i) + "_tunits = mdsvalue('units_of(dim_of(\top.twod:ne,1))')" str_ru = twod_nodes(i) + "_runits = mdsvalue('units_of(dim_of(\top.twod:ne,0))')" str_add = "dene:dene,dene_t:dene_t,dene_r:dene_r,dene_units:dene_units,dene_tunits:dene_tunits,dene_runits:dene_runits," endif else begin str = twod_nodes(i) + "= mdsvalue('\top.twod:" + $ twod_nodes(i) + "',/quiet)" str_t = twod_nodes(i) + "_t = mdsvalue('dim_of(\top.twod:" + $ twod_nodes(i) + ",1)',/quiet)" str_r = twod_nodes(i) + "_r = mdsvalue('dim_of(\top.twod:" + $ twod_nodes(i) + ",0)',/quiet)" str_u = twod_nodes(i) + $ "_units = mdsvalue('units_of(\top.twod:" + twod_nodes(i) + ")')" str_tu = twod_nodes(i) + $ "_tunits = mdsvalue('units_of(dim_of(\top.twod:" + $ twod_nodes(i) + ",1))')" str_ru = twod_nodes(i) + $ "_runits = mdsvalue('units_of(dim_of(\top.twod:" + $ twod_nodes(i) + ",0))')" str_add = twod_nodes(i) +":"+ twod_nodes(i) +"," + $ twod_nodes(i) +"_t:"+ twod_nodes(i) +"_t," +$ twod_nodes(i) +"_r:"+ twod_nodes(i) +"_r," +$ twod_nodes(i) +"_units:"+ twod_nodes(i) +"_units," +$ twod_nodes(i) +"_tunits:"+ twod_nodes(i) +"_tunits," +$ twod_nodes(i) +"_runits:"+ twod_nodes(i) +"_runits," endelse result = execute(str) result = execute(str_t) result = execute(str_r) result = execute(str_u) result = execute(str_tu) result = execute(str_ru) str3 = str3 + str_add endfor str3_len = strlen(str3) strput,str3,"}",str3_len-1 result3 = execute(str3) close: mdsclose if (server ne 'localhost') then mdsdisconnect return end