# -*- coding: utf-8 -*-
"""
Created on Fri Nov 25 14:00:03 2016
@author: Ondrej
"""
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as scisig
import urllib2
def downl_save_prak(shot,OSC):
"""
Checks if file with data from 4 channel rigol osciloscope has been already
downloaded. If not, it downloads it and saves as txt, returns all channels
as a numpy array
Arguments:
shot -- discharge number
OSC -- oscilloscope specification letter ('a', 'c', etc.)
"""
osciloscope_data='//DAS/0417RigolDS1074{}.ON/data_all'.format(OSC)
diag='prak_osc_{}'.format(OSC)
url='http://golem.fjfi.cvut.cz/shots/'+ str(shot) + osciloscope_data
try:
X=np.loadtxt('Golem_{}_{}.txt'.format(shot, diag))
except:
print("Downloading {}".format(url))
file=urllib2.urlopen(url)
X=np.loadtxt(file)
np.savetxt('Golem_{}_{}.txt'.format(shot, diag),X)
#3print "Cannot reach given url"
print('Dimensions of the array: {}'.format(np.shape(X)))
return X
X=downl_save_prak(23732,'c')
plt.plot(X[:,0])
plt.show()