hep系统中的单位和常数
hepunits的Python项目详细描述
hepunits收集 从最初由CLHEP项目定义的基本单位派生的hep单位制, 它们是not与国际单位制相同:
Quantity Name Unit Length millimeter mm Time nanosecond ns Energy Mega electron Volt MeV Positron charge eplus Temperature kelvin K Amount of substance mole mol Luminous intensity candela cd Plane angle radian rad Solid angle steradian sr
它主要基于国际单位制(SI)
Quantity Name Unit Length meter m Time second s Mass kilogram kg Electric current ampere A Temperature kelvin K Amount of substance mole mol Luminous intensity candela cd
但它增加了方便的定义,改变了基本的长度和时间单位。
安装
像任何其他python包一样安装hepunits:
pip install hepunits
或者类似的(如果愿意,可以使用--user、virtualenv等)。
开始
模块hepunits.constants包含两种常量: 物理常数和常用常数。
典型用法如下:
>>>fromhepunits.constantsimportc_light>>>fromhepunits.unitsimportpicosecond,micrometer>>>tau_Bs=1.5*picosecond# a particle lifetime, say the Bs meson's>>>ctau_Bs=c_light*tau_Bs# ctau of the particle, ~450 microns>>>printctau_Bs# result in HEP units, so mm0.449688687>>>printctau_Bs/micrometer# result in micrometers449.688687
hepunits.units模块的典型用法:
>>># add two quantities with length units and get the result in meters>>>fromhepunitsimportunitsasu>>>(1*u.meter+5*u.cm)/u.meter1.05>>># the default result is, of course, in HEP units, so mm>>>1*u.meter+5*u.cm1050.0
>>>fromhepunits.unitsimportMeV,GeV>>>massWindow=100*MeV# define a 100 MeV mass window>>>defenergy_resolution():...# returns the energy resolution of 100 MeV...return100*MeV...>>>energy_resolution()/GeV# get the energy resolution in GeV0.1