用于科学代码和脚本的小型工具和函数集。
sciscripttools的Python项目详细描述
科学工具
用于科学代码和脚本的小型工具和函数集。在
安装
pip
pip install sciscripttools
源代码构建
^{pr2}$示例
IO
IO工具入门示例。 它可以保存相对基本的python对象,例如值、字符串、数组和 这些项目的字典。在
importsciscripttoolsasstpower=[4,5,6]st.save_data("power_exp_01",power)# save a value, arrary, or dictionaryexp_info={"id":20200117,"wire_r":0.005,"lengths_1":[0.1,0.5,1.5]}st.save_data("exp_01",exp_info,directory="data/")w1=[0.1,0.5,1.5]w2=[0.1,0.3,1.7]w3=[0.1,0.6,1.2]radii=st.create_dictionary("w1",w1,"w2",w2,"w3",w3)st.save_data("radii",radii)
加载以前保存的数据
importsciscripttoolsasstexp_info=st.load_dictionary("exp_01",directory="data/")keys,radii=st.load_data("radii",keys=["w1","w3"])# load straight into arrayspower=st.load_item("power_exp_01")
绘图
开始使用打印工具的示例。
注意:standard_font
类和{
importnumpyasnpimportmatplotlib.pyplotaspltimportsciscripttoolsasst# datax=np.linspace(0,2)y=x+np.random.rand(len(x))y2=x+np.random.rand(len(x))# figurefig_params=st.figure_parameters()# generate parametersst.standard_font(font_size=fig_params.font_size)# standarise the font# normal matplotlib plottingfig,axes=plt.subplots(1,2,sharey=True)# create matplotlib figureax1,ax2=axes# plot dataax1.plot(x,y)ax2.plot(x,y2)foraxinaxes:ax.set_ylim(0,3)fig.subplots_adjust(wspace=fig_params.adjust_subplot_wspace)# set subplot width spacingsf=st.standard_figure(fig,axes,fig_params)# create standard_figuresf.add_subplot_labels()# add unitsylabel="Power";yunit="\\watt"sf.ylabel(ax1,ylabel,yunit)xlabel="Time";xunit="\\second"sf.xlabel(axes,xlabel,xunit)fig.savefig("quick_plot.png")
贡献
发现了一个bug,想添加功能,还是修复了一个bug? 创建一个issue或pull request。 任何意见或反馈,请写在issue中。在
链接
- 项目
标签: