Revision a01ea66b19cc5715f642320c7e9a459bb2ecfd72 (click the page title to view the current version)

Handling/BasicExamples

Changes from a01ea66b19cc5715f642320c7e9a459bb2ecfd72 to 9ac2ea42cdaf3c5f6879cc10ad79ce3c02afedc4

---
format:markdown
...
 
 
# Computer systems 4 GOLEM  (basic examples)

## $U_l$ @ #33993

### Python (e.g. through [the Jupyter Notebook](jupyter.org))

<table>
<tr><td>
~~~
import numpy as np
import matplotlib.pyplot as plt

shot_no = 33993
identifier = "LoopVoltageCoil_raw.csv"
DAS='DASs/StandardDAS/'
# 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()


#Run it: save it as script.py and run "python script.py" or execute in a ceel in a Jupyter Notebook
~~~

</td><td><img src="/Handling/CompAlgSystems4Golem/python/v3/Jupyter/Demos/33993/Ul/code/graph.jpg"></img></td></tr>
</table>

### Gnuplot

<table>
<tr><td>
~~~


identifier = 'LoopVoltageCoil_raw.csv' ;
ShotNo = '33993'
# Create a path to the data
DAS='DASs/StandardDAS/'
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:0.02];set xlabel 'Time [s]';set ylabel 'U_l [V]'
plot identifier u 1:2 w l t 'Uloop'


#Run it interactively or  save it as script.gp and run "gnuplot --persist script.gp" 
~~~

</td><td><img src="/Handling/CompAlgSystems4Golem/gnuplot/Demos/33993/Ul/code/graph.jpg"></img></td></tr>
</table>

### Matlab

<table>
<tr><td>
~~~
ShotNo=33993
baseURL='http://golem.fjfi.cvut.cz/shots/';
diagnPATH='/DASs/StandardDAS/LoopVoltageCoil_raw.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 
f = figure('visible', 'off');
hold on
plot(data(:,1)*1000, data(:,2), '.') ;
xlabel('Time [ms]')
ylabel('U_l [V]')
hold off
print -djpeg plot.jpg
close(f)
exit;
~~~

</td><td><img src="/Handling/CompAlgSystems4Golem/matlab/Demos/33993/Ul/code/plot.jpg"></img></td></tr>
</table>

### Octave

<table>
<tr><td>
~~~
ShotNo=33993
baseURL='http://golem.fjfi.cvut.cz/shots/';
diagnPATH='/DASs/StandardDAS/LoopVoltageCoil_raw.csv';
%Create a path to data
dataURL=strcat(baseURL,int2str(ShotNo),diagnPATH); 
% Write data from GOLEM server to a local file
urlwrite(dataURL,'LoopVoltageCoil_raw.csv');
% Load data
data = load('LoopVoltageCoil_raw.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"></img></td></tr>
</table>