Documentation:Tutorial:APIs:julia - MdsWiki
Navigation
Personal tools

From MdsWiki

Jump to: navigation, search

The open source programming language julia ( [1] ) can be used access and manipulate MDSplus objects using the MDSplus python interface.

A quick example that reads \IP from an Alcator C-Mod tree and draws a picture of it:

jas@mfews05:~$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.0 (2020-08-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   | 

julia> import Pkg; Pkg.add("PyCall")
   Updating registry at `~/.julia/registries/General`
  Resolving package versions...
No Changes to `~/.julia/environments/v1.5/Project.toml`
No Changes to `~/.julia/environments/v1.5/Manifest.toml`

julia> using PyCall
julia> MDSplus = pyimport("MDSplus")
PyObject <module 'MDSplus' from '/usr/local/mdsplus/python/MDSplus/__init__.py'>
julia> tree = MDSplus.Tree("cmod", 1090909009)
PyObject Tree("CMOD",1090909009,"Normal")
julia> ip = tree._IP
PyObject \MAGNETICS::IP
julia> x = ip.dim_of().data()
13312-element Array{Float32,1}:
 -1.9999001
 -1.9997001
   ⋮
  4.2879
  4.2881002
  4.2883
julia> y = ip.data()
13312-element Array{Float32,1}:
    0.0
    0.0
   -2.0493028
    ⋮
     2.0493028
  628.33374
    2.0493028
julia> Pkg.build("GR")
   Building GR → `~/.julia/packages/GR/RlE5Y/deps/build.log`
julia> using Plots
plot
julia> plot(x,y)

Image:JuliaPlot.png