Beispiel #1
0
def getValueFromChannel(Client, Channel, ShotNumber):
    print("get Value from: " + Channel)
    import matplotlib.pyplot as plt
    from sdas.core.SDAStime import Date, Time, TimeStamp
    import numpy as np
    structArray = Client.getData(Channel, '0x0000', ShotNumber)
    struct = structArray[0]
    Value = struct.getData()
    #TIME
    tstart = struct.getTStart()
    tend = struct.getTEnd()
    #Calculate the time between samples
    tbs = (tend.getTimeInMicros() - tstart.getTimeInMicros()) / (len(Value) *
                                                                 1.0)
    #Get the events  associated with this data
    events = struct.get('events')
    tevent = TimeStamp(tstamp=events[0].get(
        'tstamp'))  #The delay of the start time relative to the event time
    delay = tstart.getTimeInMicros() - tevent.getTimeInMicros()
    #Finally create the time array
    times = np.linspace(delay, delay + tbs * (len(Value) - 1), len(Value))
    plt.plot(times, Value)
    plt.xlabel('time Micros')
    plt.ylabel(Channel)
    plt.grid(True)
    plt.show()
    return Value, times
Beispiel #2
0
 def load_sdas_data(self, channelID, shotnr):
     dataStruct = self.client.getData(channelID, '0x0000', shotnr)
     dataArray = dataStruct[0].getData()
     len_d = len(dataArray)
     tstart = dataStruct[0].getTStart()
     tend = dataStruct[0].getTEnd()
     tbs = (tend.getTimeInMicros() - tstart.getTimeInMicros()) * 1.0 / len_d
     events = dataStruct[0].get('events')[0]
     tevent = TimeStamp(tstamp=events.get('tstamp'))
     delay = tstart.getTimeInMicros() - tevent.getTimeInMicros()
     timeVector = np.linspace(delay, delay + tbs * (len_d - 1), len_d)
     return [dataArray, timeVector]
def LoadSdasData(client, channelID, shotnr):
    dataStruct=client.getData(channelID,'0x0000', shotnr);
    dataArray=dataStruct.getData();
    len_d=len(dataArray);
    tstart = dataStruct.getTStart();
    tend = dataStruct.getTEnd();
    tbs= (tend.getTimeInMicros() - tstart.getTimeInMicros())*1.0/len_d;
    events = dataStruct.get('events')[0];
    tevent = TimeStamp(tstamp=events.get('tstamp'));
    delay = tstart.getTimeInMicros() - tevent.getTimeInMicros();
    timeVector = np.linspace(delay,delay+tbs*(len_d-1),len_d);
    return [dataArray, timeVector]
Beispiel #4
0
def getSignal(sdasClient, channelID, shotNr):
    signalStructArray = sdasClient.getData(channelID, '0x0000', shotNr)
    signalStruct = signalStructArray[0]
    signal = signalStruct.getData()
    tstart = signalStruct.getTStart()
    tend = signalStruct.getTEnd()
    #Calculate the time between samples
    tbs = (tend.getTimeInMicros() - tstart.getTimeInMicros()) / (len(signal) *
                                                                 1.0)
    #Get the events  associated with this data
    events = signalStruct.get('events')
    tevent = TimeStamp(tstamp=events[0].get('tstamp'))
    #The delay of the start time relative to the event time
    delay = tstart.getTimeInMicros() - tevent.getTimeInMicros()
    #Finally create the time array
    times = np.linspace(delay, delay + tbs * (len(signal) - 1), len(signal))
    return times, signal, tbs
Beispiel #5
0
def get_data(shot, channel):
    info = client.getData(channel, '0x0000', shot)
    data = info[0].getData()
    t0 = TimeStamp(tstamp=info[0]['events'][0]['tstamp']).getTimeInMicros()
    t1 = info[0].getTStart().getTimeInMicros()
    t2 = info[0].getTEnd().getTimeInMicros()
    dt = float(t2 - t1) / float(len(data))
    time = np.arange(t1 - t0, t2 - t0, dt, dtype=data.dtype) * 1e-6
    return data, time
Beispiel #6
0
#SAVES MIRNOV DATA IN A MATRIX
coilNr=0
data=[]
for coil in mirnv_corr:
    coilNr+=1
    structArray=client.getData(coil,'0x0000', shotnr)
    struct=structArray[0]
    data.append(struct.getData())

#TIME
tstart = struct.getTStart()
tend = struct.getTEnd()
#Calculate the time between samples
tbs = (tend.getTimeInMicros() - tstart.getTimeInMicros())/(len(data[coilNr-1])*1.0)
#Get the events  associated with this data
events = struct.get('events')
tevent = TimeStamp(tstamp=events[0].get('tstamp'))
#The delay of the start time relative to the event time
delay = tstart.getTimeInMicros() - tevent.getTimeInMicros()
#Finally create the time array
times = np.linspace(delay,delay+tbs*(len(data[coilNr-1])-1),len(data[coilNr-1]))
#plt.plot(times, data[coilNr-1]);

#PLOTS ALL DATA FROM MIRNOVS
coilNr=0
for coil in data:
    coilNr+=1
    ax = plt.subplot(3, 4, coilNr)
    plt.plot(times, coil)
plt.show()
Beispiel #7
0
 def getTEnd(self):
     return TimeStamp(tstamp=self.get("tend"))
Beispiel #8
0
 def getTStart(self):
     return TimeStamp(tstamp=self.get("tstart"))
Beispiel #9
0
    #        #print server.examples.getStateName(41) 'SHOT', 'pt'
    #        print client.searchDeclaredEventsByDescription('S', 'pt')
    #    except Error, v:
    #        print "ERROR xmlrpclib", v
    #    #print client.searchDeclaredEventsByName('SH')
    #    print client.searchMaxEventNumber()
    #    found=client.searchMinEventNumber('0x0000')
    #    #found=client.searchParametersByUniqueID('II')
    #    #found=client.searchDataByEvent('0x0000', 12050)
    #    print client.searchParametersByName('II', 'pt')
    #    found= client.searchDeclaredEventsByUniqueID('SHOT')
    #    for item in found:
    #        print 'item', item
    if client.parameterExists('CENTRAL_OS9_ADC.IIG', '0x0000', 11244):
        dS = client.getData('CENTRAL_OS9_ADC.IIGBT', '0x0000', 11244)
        ic = dS.getData()
        #print 'dS' , dS.get("tstart")
        print len(ic), ic[1]
        tstart = dS.getTStart()
        tend = dS.getTEnd()
        print tstart.getTimeInSeconds()
    date_start = Date(2005, 11, 1)
    date_end = Date(2005, 11, 31)
    #t0=Time()
    tstart = TimeStamp(date_start)
    print tstart.getTimeInMicros()
    tend = TimeStamp(date_end)
    found = client.searchEventsByEventTimeWindow(tstart, tend)
    for item in found:
        print item
Beispiel #10
0
def getDataFromDatabase(ShotNumber):
    from sdas.core.client.SDASClient import SDASClient
    from sdas.core.SDAStime import Date, Time, TimeStamp
    import numpy as np
    import matplotlib.pyplot as plt
    import sys

    def StartSdas():
        host = 'baco.ipfn.ist.utl.pt'
        port = 8888
        client = SDASClient(host, port)
        return client

    #CHANGE SHOT NUMBER HERE
    print("Import data relative to the ShotNumber:" + str(ShotNumber))
    shotnr = ShotNumber
    client = StartSdas()

    #numerical integrated mirnov coils signals
    mirnv = [
        'MARTE_NODE_IVO3.DataCollection.Channel_129',
        'MARTE_NODE_IVO3.DataCollection.Channel_130',
        'MARTE_NODE_IVO3.DataCollection.Channel_131',
        'MARTE_NODE_IVO3.DataCollection.Channel_132',
        'MARTE_NODE_IVO3.DataCollection.Channel_133',
        'MARTE_NODE_IVO3.DataCollection.Channel_134',
        'MARTE_NODE_IVO3.DataCollection.Channel_135',
        'MARTE_NODE_IVO3.DataCollection.Channel_136',
        'MARTE_NODE_IVO3.DataCollection.Channel_137',
        'MARTE_NODE_IVO3.DataCollection.Channel_138',
        'MARTE_NODE_IVO3.DataCollection.Channel_139',
        'MARTE_NODE_IVO3.DataCollection.Channel_140'
    ]

    # mirnv_raw=['MARTE_NODE_IVO3.DataCollection.Channel_145',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_146',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_147',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_148',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_149',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_150',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_151',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_152',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_153',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_154',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_155',
    # 'MARTE_NODE_IVO3.DataCollection.Channel_156']

    #numerical integrated mirnov coils signals with offset correction
    mirnv_corr = [
        'MARTE_NODE_IVO3.DataCollection.Channel_166',
        'MARTE_NODE_IVO3.DataCollection.Channel_167',
        'MARTE_NODE_IVO3.DataCollection.Channel_168',
        'MARTE_NODE_IVO3.DataCollection.Channel_169',
        'MARTE_NODE_IVO3.DataCollection.Channel_170',
        'MARTE_NODE_IVO3.DataCollection.Channel_171',
        'MARTE_NODE_IVO3.DataCollection.Channel_172',
        'MARTE_NODE_IVO3.DataCollection.Channel_173',
        'MARTE_NODE_IVO3.DataCollection.Channel_174',
        'MARTE_NODE_IVO3.DataCollection.Channel_175',
        'MARTE_NODE_IVO3.DataCollection.Channel_176',
        'MARTE_NODE_IVO3.DataCollection.Channel_177'
    ]

    #Calculated external flux on each minov coil through the SS modele
    ext_flux = [
        'MARTE_NODE_IVO3.DataCollection.Channel_214',
        'MARTE_NODE_IVO3.DataCollection.Channel_215',
        'MARTE_NODE_IVO3.DataCollection.Channel_216',
        'MARTE_NODE_IVO3.DataCollection.Channel_217',
        'MARTE_NODE_IVO3.DataCollection.Channel_218',
        'MARTE_NODE_IVO3.DataCollection.Channel_219',
        'MARTE_NODE_IVO3.DataCollection.Channel_220',
        'MARTE_NODE_IVO3.DataCollection.Channel_221',
        'MARTE_NODE_IVO3.DataCollection.Channel_222',
        'MARTE_NODE_IVO3.DataCollection.Channel_223',
        'MARTE_NODE_IVO3.DataCollection.Channel_224',
        'MARTE_NODE_IVO3.DataCollection.Channel_225'
    ]

    #Minov Coils signals with the effect from the external fluxes subtracted
    mirnv_corr_flux = [
        'MARTE_NODE_IVO3.DataCollection.Channel_202',
        'MARTE_NODE_IVO3.DataCollection.Channel_203',
        'MARTE_NODE_IVO3.DataCollection.Channel_204',
        'MARTE_NODE_IVO3.DataCollection.Channel_205',
        'MARTE_NODE_IVO3.DataCollection.Channel_206',
        'MARTE_NODE_IVO3.DataCollection.Channel_207',
        'MARTE_NODE_IVO3.DataCollection.Channel_208',
        'MARTE_NODE_IVO3.DataCollection.Channel_209',
        'MARTE_NODE_IVO3.DataCollection.Channel_210',
        'MARTE_NODE_IVO3.DataCollection.Channel_211',
        'MARTE_NODE_IVO3.DataCollection.Channel_212',
        'MARTE_NODE_IVO3.DataCollection.Channel_213'
    ]

    #Measured currents applied by the Primary, Horizontal and Vertical PowerSupply
    prim = 'MARTE_NODE_IVO3.DataCollection.Channel_093'
    hor = 'MARTE_NODE_IVO3.DataCollection.Channel_091'
    vert = 'MARTE_NODE_IVO3.DataCollection.Channel_092'

    #plasma current measured by the Rogowski coil
    Ip_rog = 'MARTE_NODE_IVO3.DataCollection.Channel_088'
    Ip_rog_value = getValueFromChannel(client, Ip_rog, shotnr)

    #chopper =' MARTE_NODE_IVO3.DataCollection.Channel_141'

    #Plasma current reconstructed by the mirnov coils without the correction from external fluxes
    Ip_magn = 'MARTE_NODE_IVO3.DataCollection.Channel_085'
    Ip_magn_value = getValueFromChannel(client, Ip_magn, shotnr)

    #Plasma current reconstructed by the mirnov coils without the correction from external fluxes
    Ip_magn_corr = 'MARTE_NODE_IVO3.DataCollection.Channel_228'
    Ip_magn_corr_value = getValueFromChannel(client, Ip_magn_corr, shotnr)

    #SAVES MIRNOV DATA IN A MATRIX
    coilNr = 0
    data = []
    for coil in mirnv_corr:
        coilNr += 1
        structArray = client.getData(coil, '0x0000', shotnr)
        struct = structArray[0]
        data.append(struct.getData())

    #TIME
    tstart = struct.getTStart()
    tend = struct.getTEnd()

    #Calculate the time between samples
    tbs = (tend.getTimeInMicros() -
           tstart.getTimeInMicros()) / (len(data[coilNr - 1]) * 1.0)

    #Get the events  associated with this data
    events = struct.get('events')
    tevent = TimeStamp(tstamp=events[0].get('tstamp'))

    #The delay of the start time relative to the event time
    delay = tstart.getTimeInMicros() - tevent.getTimeInMicros()

    #Finally create the time array
    times = np.linspace(delay, delay + tbs * (len(data[coilNr - 1]) - 1),
                        len(data[coilNr - 1]))
    #plt.plot(times, data[coilNr-1]);

    #PLOTS ALL DATA FROM MIRNOVS
    coilNr = 0
    for coil in data:
        coilNr += 1
        #plt.title('Coil' + str(coilNr))
        ax = plt.subplot(4, 3, coilNr)
        ax.set_title('coil' + str(coilNr))
        plt.plot(times, coil)
        plt.grid(True)

    plt.show()

    return [Ip_magn_value, Ip_magn_corr_value, Ip_rog_value]
#        print client.searchDeclaredEventsByDescription('S', 'pt')
#    except Error, v:
#        print "ERROR xmlrpclib", v
#    #print client.searchDeclaredEventsByName('SH')
#    print client.searchMaxEventNumber()
#    found=client.searchMinEventNumber('0x0000')
#    #found=client.searchParametersByUniqueID('II')
#    #found=client.searchDataByEvent('0x0000', 12050)
#    print client.searchParametersByName('II', 'pt')
#    found= client.searchDeclaredEventsByUniqueID('SHOT')
#    for item in found:
#        print 'item', item
    if  client.parameterExists('CENTRAL_OS9_ADC.IIG','0x0000', 11244):
        dS=client.getData('CENTRAL_OS9_ADC.IIGBT','0x0000', 11244)
        ic=dS.getData()
    #print 'dS' , dS.get("tstart")
        print len(ic), ic[1]
        tstart = dS.getTStart()
        tend = dS.getTEnd()
        print tstart.getTimeInSeconds()
    date_start = Date(2005, 11, 1)
    date_end = Date(2005, 11, 31)
    #t0=Time()
    tstart = TimeStamp(date_start)
    print tstart.getTimeInMicros()
    tend = TimeStamp(date_end)
    found=client.searchEventsByEventTimeWindow(tstart, tend)
    for item in found:
        print item