PEATDB/Ekin/Convert.py
def ekin2xy(cls, ekindataset, getall=0, geterrors=False):
        """Convert ekin datapoint storage to seprate x-y lists, can be used
           for plotting in gnuplot or Plotter for example"""
        #newer format uses 2 sub-fields for point, old is just a string
        #active field is ignored in final lists
        import copy
        import re
        s=re.compile('[0-9]')
        xlist=[]
        ylist=[]
        activelist=[]
        xerrors=[]
        yerrors=[]
        #to store which points are inactive
        inactivelist=[]
        if not isinstance(ekindataset, dict):
            return None

        # Get the number of data points from the first key
        ks=ekindataset.keys()
        ks.sort()
        first_key=ks[0]
        dps=len(ekindataset[first_key].keys())

        xdatapoints=ekindataset[0].keys()
        ydatapoints=ekindataset[1].keys()
        xdatapoints.sort()
        ydatapoints.sort()
        count=0
        for datapoint in xdatapoints:
            if datapoint=='label' or datapoint=='label_widget':
                continue
            else:
                if ekindataset[0][datapoint].has_key('var'):
                    if ekindataset[0][datapoint]['var'] != '':
                        if not ekindataset[1].has_key(datapoint):
                            continue

                        x = ekindataset[0][datapoint]['var']
                        y = ekindataset[1][datapoint]['var']
                                    
                        if s.search(ekindataset[0][datapoint]['var']) and s.search(ekindataset[1][datapoint]['var']):
                            xlist.append(float(ekindataset[0][datapoint]['var']))
                            ylist.append(float(ekindataset[1][datapoint]['var']))
                            activelist.append(ekindataset[0][datapoint]['active'])
                    else:
                        if getall==1:
                            #we include even empty points
                            xlist.append(ekindataset[0][datapoint]['var'])
                            ylist.append(ekindataset[1][datapoint]['var'])
                            activelist.append(ekindataset[0][datapoint]['active'])
                        else:
                            continue

                    if geterrors == True:
                        #if ekindataset[0][datapoint]['var'] != '' and ekindataset[1][datapoint]['var'] != '':
                        if ekindataset[0][datapoint].has_key('error'):
                            xerrors.append(float(ekindataset[0][datapoint]['error']))
                        else:
                            xerrors.append(float(0))
                        if ekindataset[1][datapoint].has_key('error'):
                            yerrors.append(float(ekindataset[1][datapoint]['error']))
                        else:
                            yerrors.append(float(0))

        if len(xerrors) == 0:
            xerrors=None
        if len(yerrors) == 0:
            yerrors=None
        
        if geterrors == True:
            return xlist, ylist, activelist, xerrors, yerrors
        else:
            return xlist, ylist, activelist
Convert ekin datapoint storage to seprate x-y lists, can be used
           for plotting in gnuplot or Plotter for example
Convert ekin datapoint storage to seprate x-y lists, can be used
for plotting in gnuplot or Plotter for example
Convert ekin datapoint storage to seprate x - y lists can be used for plotting in gnuplot or Plotter for example
def ekin2xy(cls, ekindataset, getall=0, geterrors=False):
        import copy
        import re
        s=re.compile('[0-9]')
        xlist=[]
        ylist=[]
        activelist=[]
        xerrors=[]
        yerrors=[]
        inactivelist=[]
        if not isinstance(ekindataset, dict):
            return None
        ks=ekindataset.keys()
        ks.sort()
        first_key=ks[0]
        dps=len(ekindataset[first_key].keys())
        xdatapoints=ekindataset[0].keys()
        ydatapoints=ekindataset[1].keys()
        xdatapoints.sort()
        ydatapoints.sort()
        count=0
        for datapoint in xdatapoints:
            if datapoint=='label' or datapoint=='label_widget':
                continue
            else:
                if ekindataset[0][datapoint].has_key('var'):
                    if ekindataset[0][datapoint]['var'] != '':
                        if not ekindataset[1].has_key(datapoint):
                            continue
                        x = ekindataset[0][datapoint]['var']
                        y = ekindataset[1][datapoint]['var']
                        if s.search(ekindataset[0][datapoint]['var']) and s.search(ekindataset[1][datapoint]['var']):
                            xlist.append(float(ekindataset[0][datapoint]['var']))
                            ylist.append(float(ekindataset[1][datapoint]['var']))
                            activelist.append(ekindataset[0][datapoint]['active'])
                    else:
                        if getall==1:
                            xlist.append(ekindataset[0][datapoint]['var'])
                            ylist.append(ekindataset[1][datapoint]['var'])
                            activelist.append(ekindataset[0][datapoint]['active'])
                        else:
                            continue
                    if geterrors == True:
                        if ekindataset[0][datapoint].has_key('error'):
                            xerrors.append(float(ekindataset[0][datapoint]['error']))
                        else:
                            xerrors.append(float(0))
                        if ekindataset[1][datapoint].has_key('error'):
                            yerrors.append(float(ekindataset[1][datapoint]['error']))
                        else:
                            yerrors.append(float(0))
        if len(xerrors) == 0:
            xerrors=None
        if len(yerrors) == 0:
            yerrors=None
        if geterrors == True:
            return xlist, ylist, activelist, xerrors, yerrors
        else:
            return xlist, ylist, activelist
def ekin2xy ( cls , ekindataset , getall = 0 , geterrors = False ) : import copy import re s = re . compile ( '[0-9]' ) xlist = [ ] ylist = [ ] activelist = [ ] xerrors = [ ] yerrors = [ ] inactivelist = [ ] if not isinstance ( ekindataset , dict ) : return None ks = ekindataset . keys ( ) ks . sort ( ) first_key = ks [ 0 ] dps = len ( ekindataset [ first_key ] . keys ( ) ) xdatapoints = ekindataset [ 0 ] . keys ( ) ydatapoints = ekindataset [ 1 ] . keys ( ) xdatapoints . sort ( ) ydatapoints . sort ( ) count = 0 for datapoint in xdatapoints : if datapoint == 'label' or datapoint == 'label_widget' : continue else : if ekindataset [ 0 ] [ datapoint ] . has_key ( 'var' ) : if ekindataset [ 0 ] [ datapoint ] [ 'var' ] != '' : if not ekindataset [ 1 ] . has_key ( datapoint ) : continue x = ekindataset [ 0 ] [ datapoint ] [ 'var' ] y = ekindataset [ 1 ] [ datapoint ] [ 'var' ] if s . search ( ekindataset [ 0 ] [ datapoint ] [ 'var' ] ) and s . search ( ekindataset [ 1 ] [ datapoint ] [ 'var' ] ) : xlist . append ( float ( ekindataset [ 0 ] [ datapoint ] [ 'var' ] ) ) ylist . append ( float ( ekindataset [ 1 ] [ datapoint ] [ 'var' ] ) ) activelist . append ( ekindataset [ 0 ] [ datapoint ] [ 'active' ] ) else : if getall == 1 : xlist . append ( ekindataset [ 0 ] [ datapoint ] [ 'var' ] ) ylist . append ( ekindataset [ 1 ] [ datapoint ] [ 'var' ] ) activelist . append ( ekindataset [ 0 ] [ datapoint ] [ 'active' ] ) else : continue if geterrors == True : if ekindataset [ 0 ] [ datapoint ] . has_key ( 'error' ) : xerrors . append ( float ( ekindataset [ 0 ] [ datapoint ] [ 'error' ] ) ) else : xerrors . append ( float ( 0 ) ) if ekindataset [ 1 ] [ datapoint ] . has_key ( 'error' ) : yerrors . append ( float ( ekindataset [ 1 ] [ datapoint ] [ 'error' ] ) ) else : yerrors . append ( float ( 0 ) ) if len ( xerrors ) == 0 : xerrors = None if len ( yerrors ) == 0 : yerrors = None if geterrors == True : return xlist , ylist , activelist , xerrors , yerrors else : return xlist , ylist , activelist
Convert ekin datapoint storage to seprate x-y lists, can be used
for plotting in gnuplot or Plotter for example
Convert ekin datapoint storage to seprate x - y lists can be used for plotting in gnuplot or Plotter for example
"""Convert ekin datapoint storage to seprate x-y lists, can be used
           for plotting in gnuplot or Plotter for example""" #newer format uses 2 sub-fields for point, old is just a string #active field is ignored in final lists #to store which points are inactive # Get the number of data points from the first key #we include even empty points #if ekindataset[0][datapoint]['var'] != '' and ekindataset[1][datapoint]['var'] != '':
cls
ekindataset
getall
geterrors