Revision 3da6082ee4b98852c54f30bb09bef273a93934f9 (click the page title to view the current version)
Changes from 3da6082ee4b98852c54f30bb09bef273a93934f9 to current
---
format:markdown
...
# Computer systems 4 GOLEM (basic examples)
## $U_l$ @ #33993
### Python (e.g. through [the Jupyter Notebook](jupyter.org))
<table>
<tr><td>
~~~
%matplotlib inline #If interactive mode
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
shot_no = 37897
identifier = "U_loop.csv"
DAS='Diagnostics/BasicDiagnostics/Results/'
# create data cache in the 'golem_cache' folder
ds = np.DataSource('golem_cache')
#Create a path to data and download and open the file
base_url = "http://golem.fjfi.cvut.cz/shots/"
data_file = ds.open(base_url + str(shot_no)+ '/' +DAS +identifier)
#Load data from the file and plot to screen and to disk
data = np.loadtxt(data_file,delimiter=",")
plt.plot(data[:,0], data[:,1]) #1. column vs 2. column
plt.xlabel('Time [ms]');plt.ylabel('$U_l$ [V]');
plt.savefig('graph.jpg')
plt.show()
shot_no = 33993
data_URL = "http://golem.fjfi.cvut.cz/shots/{shot_no}/DASs/StandardDAS/{identifier}.csv"
ds = np.DataSource(destpath='/tmp')
#Run it: save it as script.py and run "python script.py" or execute in a ceel in a Jupyter Notebook
~~~
def open_remote(shot_no, identifier, url_template):
return ds.open(url_template.format(shot_no=shot_no, identifier=identifier))
</td><td><img src="/Handling/CompAlgSystems4Golem/python/v3/Jupyter/Demos/33993/Ul/code/graph.jpg" width="500"></img></td></tr>
</table>
def read_signal(shot_no, identifier):
file = open_remote(shot_no, identifier, data_URL)
return pd.read_csv(file, names=['Time',identifier],
index_col='Time', squeeze=True) # squeeze makes simple 1-column signals a Series
### Gnuplot
loop_voltage = read_signal(shot_no, 'LoopVoltageCoil_raw')
ax = loop_voltage.plot(grid=True)
ax.set(xlabel="Time [s]", ylabel="$U_l$ [V]", title="Loop voltage $U_l$ #{}".format(shot_no));
<table>
<tr><td>
~~~
plt.show()
plt.savefig('graph.jpg')
identifier = 'U_loop.csv' ;
ShotNo = '37897'
# Create a path to the data
DAS='Diagnostics/BasicDiagnostics/Results/'
baseURL='http://golem.fjfi.cvut.cz/shots/'
DataURL= baseURL.ShotNo.'/'.DAS.identifier
set datafile separator ',';
set title "Uloop for #".ShotNo;
# Write data from GOLEM erver to a local file
! wget -q @DataURL ;
# Plot the graph from a local file
set xrange [0:20];set xlabel 'Time [s]';set ylabel 'U_l [V]'
plot identifier u 1:2 w l t 'Uloop'
#Run it: save it as script.py and run "python script.py" or execute in a ceel in a Jupyter Notebook
#Run it interactively or save it as script.gp and run "gnuplot --persist script.gp"
~~~
</td><td><img src="/Handling/CompAlgSystems4Golem/python/v3/Jupyter/Demos/33993/Ul/code/graph.jpg"></img></td></tr>
</td><td><img src="/Handling/CompAlgSystems4Golem/gnuplot/Demos/33993/Ul/code/graph.jpg" width="500"></img></td></tr>
</table>
Command line exectution:
~~~
shot_no=37897;ylabel='U_l [V]';signal_id=Diagnostics/BasicDiagnostics/Results/U_loop.csv;gnuplot -p -e "set title 'Golem #`wget -q -O - http://golem.fjfi.cvut.cz/shots/$shot_no/shot_no`';set datafile separator ',';set xlabel 't [s]';set ylabel '$ylabel';plot '< wget -q -O - http://golem.fjfi.cvut.cz/shots/$shot_no/$signal_id' w l t '$ylabel\@$shot_no'"
~~~
[Other examples](http://golem.fjfi.cvut.cz/wiki/Handling/CompAlgSystems4Golem/gnuplot/index)
### Matlab
<table>
<tr><td>
~~~
ShotNo=37897
baseURL='http://golem.fjfi.cvut.cz/shots/';
diagnPATH='/Diagnostics/BasicDiagnostics/Results/U_loop.csv';
%Create a path to data
dataURL=strcat(baseURL,int2str(ShotNo),diagnPATH);
% Write data from GOLEM server to a local file
urlwrite(dataURL,'LoopVoltage');
% Load data
data = load('LoopVoltage', '\t');
% Plot and save the graph
figure;
hold on
plot(data(:,1), data(:,2), '.') ;
xlabel('Time [ms]')
ylabel('U_l [V]')
hold off
~~~
</td><td><img src="/Handling/CompAlgSystems4Golem/matlab/Demos/33993/Ul/code/plot.jpg" width="500"></img></td></tr>
</table>
### Octave
<table>
<tr><td>
~~~
ShotNo=37897
baseURL='http://golem.fjfi.cvut.cz/shots/';
diagnPATH='/Diagnostics/BasicDiagnostics/Results/';
%Create a path to data
dataURL=strcat(baseURL,int2str(ShotNo),diagnPATH);
% Write data from GOLEM server to a local file
urlwrite(dataURL,'U_loop.csv');
% Load data
data = load('U_loop.csv', '\t');
% Plot and save the graph
plot(data(:,1), data(:,2), '.') ;
xlabel('time [ms]')
ylabel('U_loop [V]')
saveas(gcf, 'plot', 'jpg');
exit;
~~~
</td><td><img src="/Handling/CompAlgSystems4Golem/octave/Demos/33993/Ul/code/plot.jpg" width="500"></img></td></tr>
</table>