当前位置: 首页>>代码示例>>Python>>正文


Python CreateWorkspace.mutableRun方法代码示例

本文整理汇总了Python中mantid.simpleapi.CreateWorkspace.mutableRun方法的典型用法代码示例。如果您正苦于以下问题:Python CreateWorkspace.mutableRun方法的具体用法?Python CreateWorkspace.mutableRun怎么用?Python CreateWorkspace.mutableRun使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mantid.simpleapi.CreateWorkspace的用法示例。


在下文中一共展示了CreateWorkspace.mutableRun方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createTestWorkspace

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import mutableRun [as 别名]
    def createTestWorkspace(self):
        """ Create a workspace for testing against with ideal log values
        """
        from mantid.simpleapi import CreateWorkspace
        from mantid.simpleapi import AddSampleLog
        from time import gmtime, strftime,mktime
        import numpy as np

        # Create a matrix workspace
        x = np.array([1.,2.,3.,4.])
        y = np.array([1.,2.,3.])
        e = np.sqrt(np.array([1.,2.,3.]))
        wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=1,UnitX='TOF')

        # Add run_start
        tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())))
        AddSampleLog(Workspace=wksp,LogName='run_start',LogText=str(tmptime))

        tsp_a=kernel.FloatTimeSeriesProperty("SensorA")
        tsp_b=kernel.FloatTimeSeriesProperty("SensorB")
        tsp_c=kernel.FloatTimeSeriesProperty("SensorC")
        for i in arange(25):
            tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())+i))
            tsp_a.addValue(tmptime, 1.0*i*i)
            tsp_b.addValue(tmptime, 2.0*i*i)
            tsp_c.addValue(tmptime, 3.0*i*i)

        wksp.mutableRun()['SensorA']=tsp_a
        wksp.mutableRun()['SensorB']=tsp_b
        wksp.mutableRun()['SensorC']=tsp_c

        return wksp
开发者ID:mducle,项目名称:mantid,代码行数:34,代码来源:ExportSampleLogsToCSVFileTest.py

示例2: createTestWorkspace

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import mutableRun [as 别名]
    def createTestWorkspace(self, run=23456):
        """ Create a workspace for testing against with ideal log values
        """
        from mantid.simpleapi import CreateWorkspace
        from mantid.simpleapi import AddSampleLog
        from time import gmtime, strftime,mktime
        import numpy as np

        # Create a matrix workspace
        x = np.array([1.,2.,3.,4.])
        y = np.array([1.,2.,3.])
        e = np.sqrt(np.array([1.,2.,3.]))
        wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=1,UnitX='TOF')

        # Add run_start
        tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())))
        AddSampleLog(Workspace=wksp,LogName='run_start',LogText=str(tmptime))

        tsp_a=kernel.FloatTimeSeriesProperty("proton_charge")
        tsp_b=kernel.FloatTimeSeriesProperty("SensorA")
        for i in arange(25):
            tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())+i))
            if run == 23456: 
                shift = 0
            else:
                shift = int(run)
            tsp_a.addValue(tmptime, 1.0*i*i + shift)
            tsp_b.addValue(tmptime, 1.234*(i+1))

        wksp.mutableRun()['run_number']=str(run)
        wksp.mutableRun()['duration']=342.3
        wksp.mutableRun()['SensorA'] = tsp_b
        wksp.mutableRun()['proton_charge']=tsp_a

        return wksp
开发者ID:DanNixon,项目名称:mantid,代码行数:37,代码来源:ExportExperimentLogTest.py

示例3: createTestWorkspace2

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import mutableRun [as 别名]
    def createTestWorkspace2(self):
        """ Create a workspace for testing against with more situation
        """
        from mantid.simpleapi import CreateWorkspace
        from mantid.simpleapi import AddSampleLog
        from time import gmtime, strftime,mktime
        from datetime import datetime, timedelta
        import numpy as np

        # Create a matrix workspace
        x = np.array([1.,2.,3.,4.])
        y = np.array([1.,2.,3.])
        e = np.sqrt(np.array([1.,2.,3.]))
        wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=1,UnitX='TOF')

        # Add run_start
        year = 2014
        month = 2
        day = 15
        hour = 13
        minute = 34
        second = 3
        dtimesec = 0.0010

        timefluc = 0.0001

        #tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())))
        runstart = datetime(year, month, day, hour, minute, second)
        AddSampleLog(Workspace=wksp,LogName='run_start',LogText=str(runstart))

        tsp_a = kernel.FloatTimeSeriesProperty("SensorA")
        tsp_b = kernel.FloatTimeSeriesProperty("SensorB")
        tsp_c = kernel.FloatTimeSeriesProperty("SensorC")
        tsp_d = kernel.FloatTimeSeriesProperty("SensorD")
        logs = [tsp_a, tsp_b, tsp_c, tsp_d]

        dbbuf = ""

        random.seed(0)
        for i in arange(25):
            # Randomly pick up log without records
            # first iteration must have all the record
            skiploglist = []
            if i > 0:
                numnorecord = random.randint(-1, 4)
                if numnorecord > 0:
                    for j in xrange(numnorecord):
                        logindex = random.randint(0, 6)
                        skiploglist.append(logindex)
                    # ENDFOR (j)
                # ENDIF (numnorecord)
            # ENDIF (i)

            dbbuf += "----------- %d -------------\n" % (i)

            # Record
            for j in xrange(4):
                # Skip if selected
                if j in skiploglist:
                    continue

                # get random time shifts
                timeshift = (random.random()-0.5)*timefluc

                if i == 0:
                    # first record should have the 'exactly' same time stamps
                    timeshift *= 0.0001

                deltatime = timedelta(i*dtimesec + timeshift)
                tmptime = str(runstart + deltatime)
                tmpvalue = float(i*i*6)+j
                logs[j].addValue(tmptime, tmpvalue)

                dbbuf += "%s: %s = %d\n" % (logs[j].name, tmptime, tmpvalue)

            # ENDFOR (j)
        # ENDFOR (i)

        # print dbbuf

        wksp.mutableRun()['SensorA']=tsp_a
        wksp.mutableRun()['SensorB']=tsp_b
        wksp.mutableRun()['SensorC']=tsp_c
        wksp.mutableRun()['SensorD']=tsp_d

        return wksp
开发者ID:mducle,项目名称:mantid,代码行数:88,代码来源:ExportSampleLogsToCSVFileTest.py

示例4: createTestWorkspace2

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import mutableRun [as 别名]
    def createTestWorkspace2(self):
        """ Create a workspace for testing against with more situation
        """
        from mantid.simpleapi import CreateWorkspace
        from mantid.simpleapi import AddSampleLog
        import numpy
        from numpy import datetime64, timedelta64
        #from time import gmtime, strftime,mktime # in debug prints

        # Create a matrix workspace
        x = np.array([1.,2.,3.,4.])
        y = np.array([1.,2.,3.])
        e = np.sqrt(np.array([1.,2.,3.]))
        wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=1,UnitX='TOF')

        # Add run_start
        dtimesec = 0.0010
        timefluc = 0.0001
        runstart = '2014-02-15T13:34:03'
        # older numpy assumes local timezone
        if LooseVersion(numpy.__version__) < LooseVersion('1.9'):
            runstart = runstart + 'Z'
        runstart = datetime64(runstart, 'us') # microsecond needed for deltas

        AddSampleLog(Workspace=wksp,LogName='run_start',LogText=str(runstart))

        tsp_a = kernel.FloatTimeSeriesProperty("SensorA")
        tsp_b = kernel.FloatTimeSeriesProperty("SensorB")
        tsp_c = kernel.FloatTimeSeriesProperty("SensorC")
        tsp_d = kernel.FloatTimeSeriesProperty("SensorD")
        logs = [tsp_a, tsp_b, tsp_c, tsp_d]

        dbbuf = ""

        np.random.seed(0)
        for i in np.arange(25):
            # Randomly pick up log without records
            # first iteration must have all the record
            skiploglist = []
            if i > 0:
                numnorecord = np.random.randint(-1, 4)
                if numnorecord > 0:
                    for j in range(numnorecord):
                        logindex = np.random.randint(0, 6)
                        skiploglist.append(logindex)
                    # ENDFOR (j)
                # ENDIF (numnorecord)
            # ENDIF (i)

            dbbuf += "----------- %d -------------\n" % (i)

            # Record
            for j in range(4):
                # Skip if selected
                if j in skiploglist:
                    continue

                # get random time shifts
                timeshift = (np.random.random()-0.5)*timefluc

                if i == 0:
                    # first record should have the 'exactly' same time stamps
                    timeshift *= 0.0001

                deltatime = i*dtimesec + timeshift # fraction of a day
                deltatime = timedelta64(int(deltatime * 24 * 3600 * 1e6), 'us') # timedelta64 requires int
                tmptime = runstart + deltatime
                tmpvalue = float(i*i*6)+j
                logs[j].addValue(tmptime, tmpvalue)

                #dbbuf += "{}: {} = {}\n".format(logs[j].name, tmptime, tmpvalue)

            # ENDFOR (j)
        # ENDFOR (i)

        #print(dbbuf)

        wksp.mutableRun()['SensorA']=tsp_a
        wksp.mutableRun()['SensorB']=tsp_b
        wksp.mutableRun()['SensorC']=tsp_c
        wksp.mutableRun()['SensorD']=tsp_d

        return wksp
开发者ID:DanNixon,项目名称:mantid,代码行数:85,代码来源:ExportSampleLogsToCSVFileTest.py


注:本文中的mantid.simpleapi.CreateWorkspace.mutableRun方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。