Exemple #1
0
    def __getArrayInfo(self, array):
        info = {}
        info["SourceType"] = SOURCE_TYPE
        info["SourceName"] = self.name
        info["Key"] = array

        arrayinfo = sps.getarrayinfo(self.name, array)
        info["rows"] = arrayinfo[0]
        info["cols"] = arrayinfo[1]
        info["type"] = arrayinfo[2]
        info["flag"] = arrayinfo[3]
        counter = sps.updatecounter(self.name, array)
        info["updatecounter"] = counter

        envdict = {}
        keylist = sps.getkeylist(self.name, array + "_ENV")
        for i in keylist:
            val = sps.getenv(self.name, array + "_ENV", i)
            envdict[i] = val
        info["envdict"] = envdict
        scantest = (info['flag'] & sps.TAG_SCAN) == sps.TAG_SCAN
        if (array in ["SCAN_D"]) or scantest:
            if 'axistitles' in info["envdict"]:
                info["LabelNames"] = self._buildLabelsList(info['envdict']['axistitles'])
            if 'H' in info["envdict"]:
                if 'K' in info["envdict"]:
                    if 'L' in info["envdict"]:
                        info['hkl'] = [envdict['H'],
                                       envdict['K'],
                                       envdict['L']]
        calibarray = array + "_PARAM"
        if calibarray in sps.getarraylist(self.name):
            try:
                data = sps.getdata(self.name, calibarray)
                updc = sps.updatecounter(self.name, calibarray)
                info["EnvKey"] = calibarray
                # data is an array
                info["McaCalib"] = data.tolist()[0]
                info["env_updatecounter"] = updc
            except:
                # Some of our C modules return NULL without setting
                # an exception ...
                pass

        if array in ["XIA_DATA", "XIA_BASELINE"]:
            envarray = "XIA_DET"
            if envarray in sps.getarraylist(self.name):
                try:
                    data = sps.getdata(self.name, envarray)
                    updc = sps.updatecounter(self.name, envarray)
                    info["EnvKey"] = envarray
                    info["Detectors"] = data.tolist()[0]
                    info["env_updatecounter"] = updc
                except:
                    pass
        return info
Exemple #2
0
    def __GetArrayInfo(self,array):
        info={}
        info["SourceType"]=SOURCE_TYPE
        info["SourceName"]=self.SourceName
        info["Key"]=array
        info["Source"]=self.Source
        
        arrayinfo=sps.getarrayinfo (self.SourceName,array)
        info["rows"]=arrayinfo[0]
        info["cols"]=arrayinfo[1]
        info["type"]=arrayinfo[2]
        info["flag"]=arrayinfo[3]
        counter=sps.updatecounter (self.SourceName,array)
        info["updatecounter"]=counter

        envdict={}
        keylist=sps.getkeylist (self.SourceName,array+"_ENV")
        for i in keylist:
            val=sps.getenv(self.SourceName,array+"_ENV",i)
            envdict[i]=val
        info["envdict"]=envdict

        calibarray= array + "_PARAM"
        if calibarray in sps.getarraylist(self.SourceName):
            try:
                data= sps.getdata(self.SourceName, calibarray)
                updc= sps.updatecounter(self.SourceName, calibarray)
                info["EnvKey"]= calibarray
                info["McaCalib"]= data.tolist()[0]
                info["env_updatecounter"]= updc
            except:
                pass

        if array in ["XIA_DATA", "XIA_BASELINE"]:
            envarray= "XIA_DET"
            if envarray in sps.getarraylist(self.SourceName):
                try:
                    data= sps.getdata(self.SourceName, envarray)
                    updc= sps.updatecounter(self.SourceName, envarray)
                    info["EnvKey"]= envarray
                    info["Detectors"]= data.tolist()[0]
                    info["env_updatecounter"]= updc
                except:
                    pass
	
        return info
Exemple #3
0
    def __GetArrayInfo(self,array):
        info={}
        info["SourceType"]=SOURCE_TYPE
        info["SourceName"]=self.SourceName
        info["Key"]=array
        info["Source"]=self.Source

        arrayinfo=sps.getarrayinfo (self.SourceName,array)
        info["rows"]=arrayinfo[0]
        info["cols"]=arrayinfo[1]
        info["type"]=arrayinfo[2]
        info["flag"]=arrayinfo[3]
        counter=sps.updatecounter (self.SourceName,array)
        info["updatecounter"]=counter

        envdict={}
        keylist=sps.getkeylist (self.SourceName,array+"_ENV")
        for i in keylist:
            val=sps.getenv(self.SourceName,array+"_ENV",i)
            envdict[i]=val
        info["envdict"]=envdict

        calibarray= array + "_PARAM"
        if calibarray in sps.getarraylist(self.SourceName):
            try:
                data= sps.getdata(self.SourceName, calibarray)
                updc= sps.updatecounter(self.SourceName, calibarray)
                info["EnvKey"]= calibarray
                info["McaCalib"]= data.tolist()[0]
                info["env_updatecounter"]= updc
            except:
                pass

        if array in ["XIA_DATA", "XIA_BASELINE"]:
            envarray= "XIA_DET"
            if envarray in sps.getarraylist(self.SourceName):
                try:
                    data= sps.getdata(self.SourceName, envarray)
                    updc= sps.updatecounter(self.SourceName, envarray)
                    info["EnvKey"]= envarray
                    info["Detectors"]= data.tolist()[0]
                    info["env_updatecounter"]= updc
                except:
                    pass

        return info
Exemple #4
0
    def __getArrayInfo(self, array):
        info = {}
        info["SourceType"] = SOURCE_TYPE
        info["SourceName"] = self.name
        info["Key"] = array

        arrayinfo = sps.getarrayinfo(self.name, array)
        info["rows"] = arrayinfo[0]
        info["cols"] = arrayinfo[1]
        info["type"] = arrayinfo[2]
        info["flag"] = arrayinfo[3]
        counter = sps.updatecounter(self.name, array)
        info["updatecounter"] = counter


        envdict = {}
        keylist = sps.getkeylist(self.name, array + "_ENV")
        for i in keylist:
            val = sps.getenv(self.name, array + "_ENV", i)
            envdict[i] = val
        info["envdict"] = envdict
        scantest = (info['flag'] & sps.TAG_SCAN) == sps.TAG_SCAN
        metdata = None
        if array in ["SCAN_D"]:
            # try to get new style SCAN_D metadata
            metadata = sps.getmetadata(self.name, array)
            if metadata is not None:
                motors, metadata = metadata
                #info["LabelNames"] = metadata["allcounters"].split(";")
                labels = list(motors.keys())
                labels.sort()
                if len(labels):
                    info["LabelNames"] = [motors[x] for x in labels]
                if len(metadata["allmotorm"]):
                    info["MotorNames"] = metadata["allmotorm"].split(";")
                    info["MotorValues"] = [float(x) \
                                for x in metadata["allpositions"].split(";")]
                info["nopts"] = int(metadata["npts"])
                supplied_info = sps.getinfo(self.name, array)
                if len(supplied_info):
                    info["nopts"] = int(supplied_info[0]) 
                if 'hkl' in metadata:
                    if len(metadata["hkl"]):
                        info['hkl'] = [float(x) \
                                for x in metadata["hkl"].split(";")]
                # current SCAN
                info["scanno"] = int(metadata["scanno"])
                # current SPEC file
                info["datafile"] = metadata["datafile"]
                # put any missing information
                info["selectedcounters"] = [x \
                                for x in metadata["selectedcounters"].split()]
                # do not confuse with unhandled keys ...
                #for key in metadata:
                #    if key not in info:
                #        info[key] = metadata[key]
        if (metdata is None) and ((array in ["SCAN_D"]) or scantest):
            # old style SCAN_D metadata
            if 'axistitles' in info["envdict"]:
                info["LabelNames"] = self._buildLabelsList(info['envdict']['axistitles'])
            if 'H' in info["envdict"]:
                if 'K' in info["envdict"]:
                    if 'L' in info["envdict"]:
                        info['hkl'] = [envdict['H'],
                                       envdict['K'],
                                       envdict['L']]
        calibarray = array + "_PARAM"
        if calibarray in sps.getarraylist(self.name):
            try:
                data = sps.getdata(self.name, calibarray)
                updc = sps.updatecounter(self.name, calibarray)
                info["EnvKey"] = calibarray
                # data is an array
                info["McaCalib"] = data.tolist()[0]
                info["env_updatecounter"] = updc
            except:
                # Some of our C modules return NULL without setting
                # an exception ...
                pass

        if array in ["XIA_DATA", "XIA_BASELINE"]:
            envarray = "XIA_DET"
            if envarray in sps.getarraylist(self.name):
                try:
                    data = sps.getdata(self.name, envarray)
                    updc = sps.updatecounter(self.name, envarray)
                    info["EnvKey"] = envarray
                    info["Detectors"] = data.tolist()[0]
                    info["env_updatecounter"] = updc
                except:
                    pass
        return info
Exemple #5
0
    def __getArrayInfo(self, array):
        info = {}
        info["SourceType"] = SOURCE_TYPE
        info["SourceName"] = self.name
        info["Key"] = array

        arrayinfo = sps.getarrayinfo(self.name, array)
        info["rows"] = arrayinfo[0]
        info["cols"] = arrayinfo[1]
        info["type"] = arrayinfo[2]
        info["flag"] = arrayinfo[3]
        counter = sps.updatecounter(self.name, array)
        info["updatecounter"] = counter

        envdict = {}
        keylist = sps.getkeylist(self.name, array + "_ENV")
        for i in keylist:
            val = sps.getenv(self.name, array + "_ENV", i)
            envdict[i] = val
        info["envdict"] = envdict
        scantest = (info['flag'] & sps.TAG_SCAN) == sps.TAG_SCAN
        metadata = None
        if (array in ["SCAN_D"]) or scantest:
            # try to get new style SCAN_D metadata
            metadata = sps.getmetadata(self.name, array)
            if metadata is not None:
                motors, metadata = metadata
                #info["LabelNames"] = metadata["allcounters"].split(";")
                labels = list(motors.keys())
                try:
                    labels = [(int(x), x) for x in labels]
                except:
                    _logger.warning(
                        "SpsDataSource error reverting to old behavior")
                    labels = [(x, x) for x in labels]
                labels.sort()
                if len(labels):
                    info["LabelNames"] = [motors[x[1]] for x in labels]
                if len(metadata["allmotorm"]):
                    info["MotorNames"] = metadata["allmotorm"].split(";")
                    info["MotorValues"] = [float(x) \
                                for x in metadata["allpositions"].split(";")]
                info["nopts"] = int(metadata["npts"])
                supplied_info = sps.getinfo(self.name, array)
                if len(supplied_info):
                    info["nopts"] = int(supplied_info[0])
                if 'hkl' in metadata:
                    if len(metadata["hkl"]):
                        info['hkl'] = [float(x) \
                                for x in metadata["hkl"].split(";")]
                # current SCAN
                if 'scanno' in metadata:
                    envdict["scanno"] = int(metadata["scanno"])
                # current SPEC file and title
                for key in ["datafile", "title"]:
                    if key in metadata:
                        envdict[key] = metadata[key]
                # put any missing information
                if "selectedcounters" in metadata:
                    info["selectedcounters"] = [x \
                                for x in metadata["selectedcounters"].split()]
                # do not confuse with unhandled keys ...
                #for key in metadata:
                #    if key not in info:
                #        info[key] = metadata[key]
        if (metadata is None) and ((array in ["SCAN_D"]) or scantest):
            # old style SCAN_D metadata
            if 'axistitles' in info["envdict"]:
                info["LabelNames"] = self._buildLabelsList(
                    info['envdict']['axistitles'])
            if 'H' in info["envdict"]:
                if 'K' in info["envdict"]:
                    if 'L' in info["envdict"]:
                        info['hkl'] = [
                            envdict['H'], envdict['K'], envdict['L']
                        ]
        calibarray = array + "_PARAM"
        if calibarray in sps.getarraylist(self.name):
            try:
                data = sps.getdata(self.name, calibarray)
                updc = sps.updatecounter(self.name, calibarray)
                info["EnvKey"] = calibarray
                # data is an array
                info["McaCalib"] = data.tolist()[0]
                info["env_updatecounter"] = updc
            except:
                # Some of our C modules return NULL without setting
                # an exception ...
                pass

        if array in ["XIA_DATA", "XIA_BASELINE"]:
            envarray = "XIA_DET"
            if envarray in sps.getarraylist(self.name):
                try:
                    data = sps.getdata(self.name, envarray)
                    updc = sps.updatecounter(self.name, envarray)
                    info["EnvKey"] = envarray
                    info["Detectors"] = data.tolist()[0]
                    info["env_updatecounter"] = updc
                except:
                    pass
        return info