Ejemplo n.º 1
0
def euvData(shotno=101393, tStart=_TSTART, tStop=_TSTOP, plot=False):
    """""
	Get EUV fan array data
	
	Parameters
	----------
	shotno : int
		shot number of desired data
	tStart : float
		time (in seconds) to trim data before
		default is 0 ms
	tStop : float
		time (in seconds) to trim data after
		default is 10 ms
	plot : bool
		default is False
		True - plots far array of all 11 (of 16) channels
		'all' - plots 
		
		
	Example
	-------
	::
		
		df=euvData(101393,plot=True)
	""" ""

    # subfunctions
    @_backupDFs
    def dfEUV(shotno, tStart, tStop, dfEUVMeta):
        dfEUV = mdsData(shotno,
                        dfEUVMeta.addresses.to_list(),
                        tStart,
                        tStop,
                        columnNames=dfEUVMeta.index.to_list())
        return dfEUV

    # load meta data
    sensor = 'EUV'
    try:
        directory = _path.dirname(_path.realpath(__file__))
        dfMeta = _readOdsToDF('%s/listOfAllSensorsOnHBTEP.ods' % directory,
                              sensor).set_index('names')
    except:
        dfMeta = _readOdsToDF('listOfAllSensorsOnHBTEP.ods',
                              sensor).set_index('names')

    # load raw data
    df = dfEUV(shotno, tStart, tStop, dfMeta)
    df = _filterDFByTime(df, tStart, tStop)

    if plot == True:
        df.plot()

    return df
Ejemplo n.º 2
0
def magneticSensorData(shotno=98173,
                       tStart=_TSTART,
                       tStop=_TSTOP,
                       plot=False,
                       removeBadSensors=True,
                       sensor='TA',
                       timeFWHMSmoothing=0.4e-3,
                       forceDownload=False):
    """
	Downloads magnetic sensor data.  Presently, only poloidal
	measurements as the radial sensors are not yet implemeted.  
	
	Parameters
	----------

	shotno : int
		shot number of desired data
	tStart : float
		time (in seconds) to trim data before
		default is 0 ms
	tStop : float
		time (in seconds) to trim data after
		default is 10 ms
	plot : bool
		plots all relevant plots if true
		default is False
	removeBadSensors : bool
		removes known bad sensors
	sensor : str
		sensor to evalualte.  Must be in ['TA','PA1','PA2','FB']
	timeFWHMSmoothing : float
		Time constant associated with the offset subtraction filter
		
	Returns
	-------
	dfRaw : pandas.core.frame.DataFrame
		Raw magnetic data.  Time is index.
	dfSmoothed : pandas.core.frame.DataFrame
		Offset subtracted magnetic data.  Time is index.
	dfMeta : pandas.core.frame.DataFrame
		Meta data for the sensors
	
	Notes
	-----
	other possible bad sensors: ['TA02_S1P','TA07_S3P','TA10_S3P'] 
	The sensors that are bad are not necessarily consistent from shot to shot or year to year
 
	
	Examples
	--------
	::
		
		shotno=106000
		a,b,c=magneticSensorData(shotno,sensor='TA',plot=True,tStart=1.5e-3,tStop=5.5e-3)
		a,b,c=magneticSensorData(shotno,sensor='PA1',plot=True,tStart=1.5e-3,tStop=5.5e-3)
		a,b,c=magneticSensorData(shotno,sensor='PA2',plot=True,tStart=1.5e-3,tStop=5.5e-3)
		a,b,c=magneticSensorData(shotno,sensor='FB',plot=True,tStart=1.5e-3,tStop=5.5e-3,forceDownload=True)

	"""

    if sensor not in ['TA', 'PA1', 'PA2', 'FB']:
        raise Exception('Bad sensor name')

    # subfunctions
    @_backupDFs
    def dfTARaw(
        shotno,
        dfTAMeta,
        tStart=_TSTART,
        tStop=_TSTOP,
    ):
        dfTARaw = mdsData(shotno,
                          dfTAMeta.addresses.to_list(),
                          tStart,
                          tStop,
                          columnNames=dfTAMeta.index.to_list())
        return dfTARaw

    @_backupDFs
    def dfPA1Raw(shotno, dfPA1Meta, tStart=_TSTART, tStop=_TSTOP):
        dfPA1Raw = mdsData(shotno,
                           dfPA1Meta.addresses.to_list(),
                           tStart,
                           tStop,
                           columnNames=dfPA1Meta.index.to_list())
        return dfPA1Raw

    @_backupDFs
    def dfPA2Raw(shotno, dfPA2Meta, tStart=_TSTART, tStop=_TSTOP):
        dfPA2Raw = mdsData(shotno,
                           dfPA2Meta.addresses.to_list(),
                           tStart,
                           tStop,
                           columnNames=dfPA2Meta.index.to_list())
        return dfPA2Raw

    @_backupDFs
    def dfFBRaw(shotno, dfFBMeta, tStart=_TSTART, tStop=_TSTOP):
        dfFBRaw = mdsData(shotno,
                          dfFBMeta.addresses.to_list(),
                          tStart,
                          tStop,
                          columnNames=dfFBMeta.index.to_list())
        return dfFBRaw

    # load meta data
    try:
        directory = _path.dirname(_path.realpath(__file__))
        dfMeta = _readOdsToDF('%s/listOfAllSensorsOnHBTEP.ods' % directory,
                              sensor).set_index('names')
    except:
        dfMeta = _readOdsToDF('listOfAllSensorsOnHBTEP.ods',
                              sensor).set_index('names')

    # load raw data
    if sensor == 'TA':
        dfRaw = dfTARaw(shotno, dfMeta, forceDownload=forceDownload)
    elif sensor == 'PA1':
        dfRaw = dfPA1Raw(shotno, dfMeta, forceDownload=forceDownload)
    elif sensor == 'PA2':
        dfRaw = dfPA2Raw(shotno, dfMeta, forceDownload=forceDownload)
    elif sensor == 'FB':
        dfRaw = dfFBRaw(shotno, dfMeta, forceDownload=forceDownload)
    if removeBadSensors:
        dfRaw = dfRaw.drop(columns=dfMeta[dfMeta.bad == True].index.to_list())
        dfMeta = dfMeta.drop(dfMeta[dfMeta.bad == True].index.to_list())
    dfRaw = _filterDFByTime(dfRaw, tStart, tStop)

    # filter data
    dfSmoothed = _gaussianFilter_df(dfRaw,
                                    timeFWHM=timeFWHMSmoothing,
                                    filterType='high',
                                    plot=False)

    # optional stripey plots
    if plot == True:
        if 'PA' in sensor:
            angle = dfMeta.theta.values
            dfSmoothed.columns = angle
            dfSmoothed.index *= 1e3
            fig, ax, cax = _plotHbt.stripeyPlot(
                dfSmoothed * 1e4,
                title='%d' % shotno,
                poloidal=True,
                subtitle=sensor,
                xlabel='Time (ms)',
                ylabel=r'Poloidal angle, $\theta$')
        elif sensor == 'TA':
            angle = dfMeta.phi.values
            dfSmoothed.columns = angle
            dfSmoothed.index *= 1e3
            fig, ax, cax = _plotHbt.stripeyPlot(
                dfSmoothed * 1e4,
                title='%d' % shotno,
                toroidal=True,
                subtitle=sensor,
                xlabel='Time (ms)',
                ylabel=r'Toroidal angle, $\phi$')
        else:  #FB arrays
            for s in ['S1P', 'S2P', 'S3P', 'S4P']:
                dfTemp = _filterDFByColOrIndex(dfSmoothed, s)
                dfTempMeta = _filterDFByColOrIndex(dfMeta, s, col=False)
                angle = dfTempMeta.phi.values
                dfTemp.columns = angle
                dfTemp.index *= 1e3
                fig, ax, cax = _plotHbt.stripeyPlot(
                    dfTemp * 1e4,
                    title='%d' % shotno,
                    toroidal=True,
                    subtitle='FB_' + s,
                    xlabel='Time (ms)',
                    ylabel=r'Toroidal angle, $\phi$')

    return dfRaw, dfSmoothed, dfMeta
Ejemplo n.º 3
0
def solData(shotno=98030,
            tStart=_TSTART,
            tStop=_TSTOP,
            plot=False,
            timeFWHMSmoothing=0.4e-3):
    """
	SOL tile sensor data
	
	Parameters
	----------
	shotno : int
		shot number of desired data
	tStart : float
		time (in seconds) to trim data before
		default is 0 ms
	tStop : float
		time (in seconds) to trim data after
		default is 10 ms
	plot : bool
		plots all relevant plots if true
		default is False
	timeFWHMSmoothing : float
		Time constant associated with the offset subtraction filter
		
	Returns
	-------
	dfRaw : pandas.core.frame.DataFrame
		Raw magnetic data.  Time is index.
	dfSmoothed : pandas.core.frame.DataFrame
		Offset subtracted magnetic data.  Time is index.
	dfMeta : pandas.core.frame.DataFrame
		Meta data for the sensors
	
	Examples
	--------
	::
		
		a,b,c=solData(98173)
	
	"""

    # subfunctions
    @_backupDFs
    def dfSOLRaw(shotno, tStart, tStop, dfSOLMeta):
        dfSOLRaw = mdsData(shotno,
                           dfSOLMeta.addresses.to_list(),
                           tStart,
                           tStop,
                           columnNames=dfSOLMeta.index.to_list())
        return dfSOLRaw

    # load meta data
    sensor = 'SOL'
    try:
        directory = _path.dirname(_path.realpath(__file__))
        dfMeta = _readOdsToDF('%s/listOfAllSensorsOnHBTEP.ods' % directory,
                              sensor).set_index('names')
    except:
        dfMeta = _readOdsToDF('listOfAllSensorsOnHBTEP.ods',
                              sensor).set_index('names')

    # load raw data
    dfRaw = dfSOLRaw(shotno, tStart, tStop, dfMeta)
    dfRaw = _filterDFByTime(dfRaw, tStart, tStop)

    # filter data
    dfSmoothed = _gaussianFilter_df(dfRaw,
                                    timeFWHM=timeFWHMSmoothing,
                                    filterType='high',
                                    plot=False)

    # plot
    if plot == True:
        dfRaw.plot()
        dfSmoothed.plot()

    return dfRaw, dfSmoothed, dfMeta
Ejemplo n.º 4
0
def sxrData(shotno=98170,
            tStart=_TSTART,
            tStop=_TSTOP,
            plot=False,
            dropBadChannels=True,
            forceDownload=False):
    """
	Downloads (and optionally plots) soft xray sensor data.   
	
	Parameters
	----------
	shotno : int
		shot number of desired data
	tStart : float
		time (in seconds) to trim data before
		default is 0 ms
	tStop : float
		time (in seconds) to trim data after
		default is 10 ms
	plot : bool
		default is False
	dropBadChannels : bool
		Drops bad channels
		
	Notes
	-----	
	Channels 5, 8, 10, 13 and 15 are considered "bad".  These particular channels
	are frequently "missing" from the tree, inlclude anamolous data, or their
	signals are attenuated.  
	
	Example
	-------
	::
		
		df=sxrData(106000,plot=True,tStart=1.5e-3,tStop=5.2e-3)

	"""

    # subfunctions
    @_backupDFs
    def dfSXR(shotno, dfSXRMeta):
        dfSXR = mdsData(shotno,
                        dfSXRMeta.addresses.to_list(),
                        columnNames=dfSXRMeta.index.to_list())
        return dfSXR

    # load meta data
    sensor = 'SXR'
    try:
        directory = _path.dirname(_path.realpath(__file__))
        dfMeta = _readOdsToDF('%s/listOfAllSensorsOnHBTEP.ods' % directory,
                              sensor).set_index('names')
    except:
        dfMeta = _readOdsToDF('listOfAllSensorsOnHBTEP.ods',
                              sensor).set_index('names')

    # load raw data
    df = dfSXR(shotno, dfMeta, forceDownload=forceDownload)

    # drop bad channels
    if dropBadChannels == True:
        badSensors = dfMeta[dfMeta.bad == True].index.to_list()
        dfMeta = dfMeta.drop(badSensors, axis=0)
        df = df.drop(columns=badSensors)

    # trim time
    df = _filterDFByTime(df, tStart, tStop)

    # optional high-pass filter
    dfHP = _gaussianFilter_df(df, timeFWHM=0.4e-3)

    # optional plot
    if plot == True:

        if True:  # raw data
            fig, ax, cax = _plot.subplotsWithColormaps(2, sharex=True)
            cax[0].remove()
            for key, val in df.iteritems():

                ax[0].plot(val, label=key)
            _plot.finalizeSubplot(
                ax[0],
                title='%d, raw' % shotno,
            )

            temp = _np.copy(df.columns).astype(str)
            columns = _np.array([
                '%d' % int(temp[i][-2:]) for i in range(len(temp))
            ]).astype(float)
            df2 = df.copy()
            df2.columns = columns
            fig, ax, _ = _plotHbt.stripeyPlot(
                df2,
                fig=fig,
                ax=ax[1],
                cax=cax[1],
                #										title='%d, raw'%shotno,
                colorMap='magma_r',
                zlim=[0, df.max().max()],
                levels=_np.linspace(0,
                                    df.max().max(), 41),
                ylabel='Channel #')
            _plot.finalizeFigure(fig)

        if True:  # filtered data
            fig, ax, cax = _plot.subplotsWithColormaps(2, sharex=True)
            cax[0].remove()
            for key, val in dfHP.iteritems():

                ax[0].plot(val, label=key)
            _plot.finalizeSubplot(
                ax[0],
                title='%d, high-pass filtered' % shotno,
            )

            temp = _np.copy(dfHP.columns).astype(str)
            columns = _np.array([
                '%d' % int(temp[i][-2:]) for i in range(len(temp))
            ]).astype(float)
            dfHP2 = dfHP.copy()
            dfHP2.columns = columns
            fig, ax, _ = _plotHbt.stripeyPlot(
                dfHP2,
                fig=fig,
                ax=ax[1],
                cax=cax[1],
                #								 title='%d, high-pass filtered'%shotno,
                ylabel='Channel #')
            _plot.finalizeFigure(fig)

    return df, dfHP
Ejemplo n.º 5
0
def quartzJumperAndGroundingBusData(shotno=96530,
                                    tStart=_TSTART,
                                    tStop=_TSTOP,
                                    plot=False,
                                    timeFWHMSmoothing=0.4e-3,
                                    forceDownload=False):
    """
	External rogowski data
	
	Parameters
	----------
	shotno : int
		shot number of desired data
	tStart : float
		time (in seconds) to trim data before
		default is 0 ms
	tStop : float
		time (in seconds) to trim data after
		default is 10 ms
	plot : bool
		plots all relevant plots if true
		default is False
	timeFWHMSmoothing : float
		Time constant associated with the offset subtraction filter
		
		
		
	Notes
	-----
	Rog. D is permanently off for the time being
	Rog. C is permanently off for the time being
	
	"""

    # subfunctions
    @_backupDFs
    def dfJumperRaw(shotno, tStart, tStop, dfJumperMeta):
        dfJumperRaw = mdsData(shotno,
                              dfJumperMeta.addresses.to_list(),
                              tStart,
                              tStop,
                              columnNames=dfJumperMeta.index.to_list())
        return dfJumperRaw

    # load meta data
    sensor = 'Jumper'
    try:
        directory = _path.dirname(_path.realpath(__file__))
        dfMeta = _readOdsToDF('%s/listOfAllSensorsOnHBTEP.ods' % directory,
                              sensor).set_index('names')
    except:
        dfMeta = _readOdsToDF('listOfAllSensorsOnHBTEP.ods',
                              sensor).set_index('names')

    # load raw data
    dfRaw = dfJumperRaw(shotno,
                        tStart,
                        tStop,
                        dfMeta,
                        forceDownload=forceDownload)
    dfRaw['WestRackGround'] *= 100
    dfRaw['NorthRackGround'] *= 100
    dfRaw = _filterDFByTime(dfRaw, tStart, tStop)

    # filter data
    dfSmoothed = _gaussianFilter_df(dfRaw,
                                    timeFWHM=timeFWHMSmoothing,
                                    filterType='high',
                                    plot=False)

    # optional plot
    if plot == True:
        fig, ax = _plt.subplots(2, sharex=True)
        for i, (key, val) in enumerate(dfRaw.iteritems()):
            ax[0].plot(val.index * 1e3, val, label=key)
        for i, (key, val) in enumerate(dfSmoothed.iteritems()):
            ax[1].plot(val.index * 1e3, val, label=key)
        _plot.finalizeSubplot(
            ax[0],
            #								xlabel='Time',
            ylabel='A',
            subtitle='Raw',
            title='%d' % shotno,
            #								ylim=[3,15],
            #								legendOn=False,
        )
        _plot.finalizeSubplot(
            ax[1],
            xlabel='Time',
            ylabel='A',
            subtitle='Smoothed',
        )

    return dfRaw, dfSmoothed, dfMeta