pymchelper.axis module¶
-
class
pymchelper.axis.AxisId[source]¶ Bases:
enum.IntEnumAn enumeration.
-
diff1= 3¶
-
diff2= 4¶
-
x= 0¶
-
y= 1¶
-
z= 2¶
-
-
class
pymchelper.axis.MeshAxis[source]¶ Bases:
pymchelper.axis.MeshAxisScoring mesh axis data.
It can represent an axis variety of scorers: x,y or z in cartesian scoring, r, rho or z in cylindrical. An axis represents a sequence of
nnumbers, defining linear or logarithmic binning. This sequence of numbers is not stored in the memory, but can be generated using data property method.min_valis lowest bin left edge, max_val is highest bin right edgenamecan be used to define physical quantity (i.e. position, energy, angle).unitgives physical units (i.e. cm, MeV, mrad).MeshAxisis constructed as immutable data structure, thus it is possible to set field values only upon object creation. Later they are available for read only.>>> x = MeshAxis(n=10, min_val=0.0, max_val=30.0, name="Position", unit="cm", binning=MeshAxis.BinningType.linear) >>> x.n, x.min_val, x.max_val (10, 0.0, 30.0) >>> x.n = 5 Traceback (most recent call last): ... AttributeError: can't set attribute
binningfield (use internalBinningType.linearorBinningType.logarithmic) can distinguish log from linear binning-
data¶ Generates linear or logarithmic sequence of
nnumbers.These numbers are middle points of the bins defined by
n,min_valandmax_valparameters.>>> x = MeshAxis(n=10, min_val=0.0, max_val=10.0, name="X", unit="cm", binning=MeshAxis.BinningType.linear) >>> x.data array([ 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5])
Binning may also consist of one bin: >>> x = MeshAxis(n=1, min_val=0.0, max_val=5.0, name=”X”, unit=”cm”, binning=MeshAxis.BinningType.linear) >>> x.data array([ 2.5])
Logarithmic binning works as well, middle bin points are calculated as geometrical mean. Here we define 3 bins: [1,4], [4,16], [16,64]. >>> x = MeshAxis(n=3, min_val=1.0, max_val=64.0, name=”X”, unit=”cm”, binning=MeshAxis.BinningType.logarithmic) >>> x.data array([ 2., 8., 32.])
For the same settings as below linear scale gives as expected different sequence: >>> x = MeshAxis(n=3, min_val=1.0, max_val=64.0, name=”X”, unit=”cm”, binning=MeshAxis.BinningType.linear) >>> x.data array([ 11.5, 32.5, 53.5])
For logarithmic axis min_val has to be positive: >>> x = MeshAxis(n=3, min_val=-2.0, max_val=64.0, name=”X”, unit=”cm”, binning=MeshAxis.BinningType.logarithmic) >>> x.data Traceback (most recent call last): … Exception: Left edge of first bin (-2) is not positive
Returns:
-