本文整理汇总了Python中Stoner.Data.normalise方法的典型用法代码示例。如果您正苦于以下问题:Python Data.normalise方法的具体用法?Python Data.normalise怎么用?Python Data.normalise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stoner.Data
的用法示例。
在下文中一共展示了Data.normalise方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Data
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import normalise [as 别名]
"""Example customising a plot using default style."""
from Stoner import Data, __home__
from Stoner.plot.formats import DefaultPlotStyle
import os.path as path
from cycler import cycler
filename = path.realpath(path.join(__home__, "..", "doc", "samples", "sample.txt"))
d = Data(filename, setas="xyy", template=DefaultPlotStyle)
d.normalise(2, scale=(0.0, 10.0)) # Just to keep the plot sane!
# Change the color and line style cycles
d.template["axes.prop_cycle"] = cycler(color=["Blue", "Purple"]) + cycler(
linestyle=["-", "--"]
)
# Can also access as an attribute
d.template.template_lines__linewidth = 2.0
# Set the default figure size
d.template["figure.figsize"] = (6, 8)
d.template["figure.autolayout"] = True
# Make figure (before using subplot method) and select first subplot
d.figure()
d.subplot(211)
# Pkot with our customised defaults
d.plot()
d.grid(True, color="green", linestyle="-.")
d.title = "Customised Plot settings"
# Reset the template to defaults and switch to next subplot
d.template.clear()
示例2: enumerate
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import normalise [as 别名]
data=Data(filename) #Use FALSE to get a dialog box to the file containing Tc data
#Define my working x and y axes
#Split one file into a folder of two files by the iterator column
fldr=data.split(iterator)
result=Data()
for data in fldr: #For each iteration ramp in the Tc data
row=[data.mean(iterator)]
data.figure(figsize=(8,4))
for i,r_col in enumerate(r_cols):
data.setas(x=t_col,y=r_col)
data.del_rows(isnan(data.y))
#Normalise data on y axis between +/- 1
data.normalise(base=(-1.,1.), replace=True)
#Swap x and y axes around so that R is x and T is y
data=~data
#Curve fit a straight line, using only the central 90% of the resistance transition
data.curve_fit(linear,bounds=lambda x,r:-threshold<x<threshold,result=True,p0=[7.0,0.0]) #result=True to record fit into metadata
#Plot the results
data.setas[-1]="y"
data.subplot(1,len(r_cols),i+1)
data.plot(fmt=["k.","r-"])
data.annotate_fit(linear,x=-1.,y=7.3c,fontsize="small")
data.title="Ramp {}".format(data[iterator][0])
row.extend([data["linear:intercept"],data["linear:intercept err"]])
data.tight_layout()
示例3: Data
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import normalise [as 别名]
#################### Important - if using multiprocessing on Windows, this block must be ######
#################### Inside a if __name__=="__main__": test. ###################################
###############################################################################################
if __name__ == "__main__":
# Load data
d = Data(join(__home__, "..", "sample-data", "FMR-data.txt"))
# Rename columns and reset plot labels
d.rename("multi[1]:y", "Field").rename("multi[0]:y", "Frequency").rename(
"Absorption::X", "FMR"
)
d.labels = None
# Deine x and y columns and normalise to a big number
d.setas(x="Field", y="FMR")
d.normalise(base=(-1e6, 1e6))
fldr = d.split(field_sign, "Frequency")
# Split the data file into separate files by frequencies and sign of field
fldr = PlotFolder(fldr) # Convert to a PlotFolder
fldr.template = template # Set my custom plot template
for f in fldr[-1]: # Invert the negative field side
f.x = -f.x[::-1]
f.y = -f.y[::-1]
resfldr = PlotFolder() # Somewhere to keep the results from +ve and -ve fields
for s in fldr.groups: # Fit each FMR spectra
subfldr = fldr[s]
subfldr.metadata["Field Sign"] = s