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


Python Data.find_col方法代码示例

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


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

示例1: norm_group

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import find_col [as 别名]
def norm_group(pos,_,**kargs):
    """Takes the drain current for each file in group and builds an analysis file and works out the mean drain"""
    if "signal" in kargs:
        signal=kargs["signal"]
    else:
        signal="fluo"
    lfit=kargs["lfit"]
    rfit=kargs["rfit"]

    posfile=Data()
    posfile.metadata=pos[0].metadata
    posfile=posfile&pos[0].column(0)
    posfile.column_headers=['Energy']
    for f in pos:
        print(str(f["run"])+str(f.find_col(signal)))
        posfile=posfile&f.column(signal)
    posfile.add_column(lambda r:np.mean(r[1:]),"mean drain")
    ec=posfile.find_col('Energy')
    md=posfile.find_col('mean drain')
    linearfit=scipy.poly1d(posfile.polyfit(ec,md,1,lambda x,y:lfit[0]<=x<=lfit[1]))
    posfile.add_column(lambda r:r[md]-linearfit(r[ec]),'minus linear')
    highend=posfile.mean('minus',lambda r:rfit[0]<=r[ec]<=rfit[1])
    ml=posfile.find_col('minus linear')
    posfile.add_column(lambda r:r[ml]/highend,"normalised")
    if "group_key" in kargs:
        posfile[kargs["group_key"]]=pos.key
    return posfile
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:29,代码来源:XMCD_Reduction.py

示例2: LoadData

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import find_col [as 别名]
    def LoadData(self, data_item_number, filename):
        """LoadData(self, data_item_number, filename) --> none

        Loads the data from filename into the data_item_number.
        """
        try:
            datafile=Data(str(filename),debug=True) # does all the hard work here
        except Exception as e:
            ShowWarningDialog(self.parent, 'Could not load the file: ' +\
                    filename + ' \nPlease check the format.\n\n Stoner.Data'\
                    + ' gave the following error:\n'  +  str(e))
        else:
            # For the freak case of only one data point
            try:
                if datafile.setas.cols["axes"]==0:
                    self.x_col=datafile.find_col(self.x_col)
                    self.y_col=datafile.find_col(self.y_col)
                    self.e_col=datafile.find_col(self.e_col)
                    datafile.etsas(x=self.x_col,y=self.y_col,e=self.e_col)
                else:
                    self.x_col=datafile.setas.cols["xcol"]
                    self.y_col=datafile.setas.cols["ycol"][0]
                    if len(datafile.setas.cols["yerr"])>0:
                        self.e_col=datafile.setas.cols["yerr"][0]
                    else:
                        datafile.add_column(np.ones(len(datafile)))
                        datafile.setas[-1]="e"
            except Exception as e:
                ShowWarningDialog(self.parent, 'The data file does not contain'\
                        + 'all the columns specified in the opions\n'+e.message)
                # Okay now we have showed a dialog lets bail out ...
                return
            # The data is set by the default Template.__init__ function, neat hu
            # Know the loaded data goes into *_raw so that they are not
            # changed by the transforms
            datafile.y=np.where(datafile.y==0.0,1E-8,datafile.y)
            self.data[data_item_number].x_raw = datafile.x
            self.data[data_item_number].y_raw =  datafile.y
            self.data[data_item_number].error_raw =  datafile.e
            # Run the commands on the data - this also sets the x,y, error memebers
            # of that data item.
            self.data[data_item_number].run_command()

            # Send an update that new data has been loaded
            self.SendUpdateDataEvent()
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:47,代码来源:stoner.py

示例3:

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import find_col [as 别名]
# This has proved most succesful for me looking at some MdV data.
# We then threshold for zero crossing of the derivative
# And check the second derivative to see whether we like the peak as signficant. This is the significance parameter
# and seems to be largely empirical
# Finally we interpolate back to the complete data set to make sure we get the angle as well as the counts.
d.lmfit(ExponentialModel,result=True,replace=False,header="Envelope")
d.subtract("Counts","Envelope",replace=False,header="peaks")
d.setas="xy"
sys.exit()
t=Data(d.interpolate(d.peaks(significance=sensitivity,width=8,poly=4)))

t.column_headers=copy(d.column_headers)
d%='peaks'
t%='peaks'
d.setas="xy"
d.labels[d.find_col('Angle')]=r"Reflection Angle $\theta$"
t.del_rows(0, lambda x,y: x<critical_edge)
t.setas="xy"
t.template.fig_width=7.0
t.template.fig_height=5.0
t.plot(fmt='go',  plotter=pyplot.semilogy)
main_fig=d.plot(figure=t.fig, plotter=pyplot.semilogy)
d.show()
#Now convert the angle to sin^2
t.apply(lambda x: np.sin(np.radians(x[0]/2.0))**2, 0,header=r"$sin^2\theta$")
# Now create the m^2 order
m=np.arange(len(t))+fringe_offset
m=m**2
#And add it to t
t.add_column(m, column_header='$m^2$')
#Now we can it a straight line
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:33,代码来源:Kiessig.py


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