lvl_builder is a python script to build an energy level scheme that is normally used in the nuclear physics.
There are several good plotting tools already for energy level scheme, such as a Mathematica plug-in LevelScheme, and well-known Radware program. So...what's new for this lvl_builder program? OK, there are several useful features.
My goal of writing lvl_builder is to let users don't worry about the
calculations or arrangement. (I wish to make the plotting a fun and easy task). The spirit of lvl-builder is similar to using Latex, one just inputs very minimal information for level and gamma, and the program does all the hard work for you.
Meanwhile, the lvl_builder uses the xmgrace,
one of very popular and powerful scientific tool, as the rendering
tool, and so user can get the full control of "ALL" the details.
Still thinking about the input job is too tedious? I have another small program,
parseNNDC2, which can turn the data at the NNDC website into the input file
format for 'lvl_builder' so that you can have a plot in just a second.
Of course, the presentation will be raw, but the adjustment is very quick.
demo1:
Figure: a fake level scheme to demonstrate the basic proprieties
of lvl_builder. (input file)
Here we can see:
The files can be downloaded from my Github.
Since lvl_builder uses xmgrace to plot, xmgrace has to be installed. This script works for both Python2.7 or Python3.X. Run linux command chmod 755 ./lvl_builder.py
to make the file executable.
./lvl_builder.py inputfile [fine_control_paramter_file] [ouput]
The "fine_control_paramter_file" and "output" are optional arguments.
By default, it reads in "fineParameter.txt" file, and the default output is output.ps.
for example:
./lvl_builder demo_general_properties.txt fineParameter.txt
In the package, there is a "preview_tool.py" python script. It may help you quickly make a draft. There is a text box at the bottom. You can type in the syntax for a level and a gamma. Use the "plot" button at the menu bar or
Let's talk about the basic of the input file.
There are only two categories -- level and gamma.
a line starts with "#" will be treated as a comment. and an empty line will be ignore.
The format is @key1 value1 @key2 value2 ....
For a level, there are two required key-value pairs -- lvlE and bandN. For example:
@lvlE 0 @bandN 1
, you create a level at energy 0, and it locates at bandN ( region ) = 1.
@lvlE 100 @bandN 1
, now you know this is to create a level at energy =100, and at bandN 1.
By default, lvlE = 100 or 100.0 or 100.1 will all display as a level at 100, since the levelDigit is set to 0 in the fine_control_paramter_file file.
But they are treated as different levels. You can use this as a trick to set the second "ground state".
bandN can either positive, negative value or 0,
and you can create a level across multiple band by use "_", ex. 2_3,
or -1_3, which will cross from bandN = -1 to bandN = 3.
For a gamma, and we have two required key-value pairs; they are Ei adn Ef -- the energies for the initial state and final state. For example:
@Ei 100 @Ef 0
, we will connect the states with an arrowed line.
You can notice the gamma automatically changes its placement when we adjust its levels. Furthermore, when an initial state and a final state are too far away, we will add an auxiliary dashed line. (You can also define how
far to let the auxiliary line appears, which can be set in the fine_control_paramter_file. )
Now, you have learn the most essential part of lvl_builder program, and you are good to explore more options.
Just remember: for a level, we require "lvlE" and "bandN", for a gamma "Ei" and "Ef" are required.
For a level, your optional keys:
spin
, such as 9/2+, it will appears at the right-hand side of a level, label
, by default, the lvlE value (float type) will be displayed on the left-hand side of a level. showlvlE
, when it is set to 0, then the energy text label will not shown. linestyle
, 0 = not shown, 1 = solid line, 2 = dashed line, ... it just follows the xmgrace setting.
linewidth
, in the 0-100 scale (corresponding to 0-20 scale in xmgrace)
color
, xmgrace only has 16 colors. its value can be black, red, green, blue, yellow, brown, grey, violet, cyan, magenta, orange, indigo, maroon, turquoise, and grey4. When you change the color. The color apply both a given label and line.
boxW
, the width of a box which attached to a level. The thickness of a box varies with the level's linewidth. The range of boxW is from 0. to 1.
boxColor
, control the filled color for a box which attached to a level. There are 16 colors only: black, red, green, blue, yellow, brown, grey, violet, cyan, magenta, orange, indigo, maroon, turquoise, and grey4.
for example:
by
@lvlE 100 @bandN 1 @spin 2+ @color red @linewidth 20 @linestyle 2
by
@lvlE 200 @bandN 1 @label SF=0.8 @boxW 0.8 @boxColor red @linewidth 20
For a gam, your optional keys:
label
, it can be use to label the gamma energy. ( in general, you can put any string.)
arrow
, when it is set to 0, we will just use line instead of arrowed line.
linestyle
, 0 = not shown, 1 = solid line, 2 = dashed line, ... it just follows the xmgrace setting.
linewidth
or I
, these two keys works the same. color
, xmgrace only has 16 colors.
Its value can be black, red, green, blue, yellow, brown, grey, violet, for example:
, the gamma is set by
@Ei 100 @Ef 0 @I 15.2 @label 100? @color blue @arrow 0
You can fine tune the output details in case you want to improve the default output.
For the basic
bandwidth
: the band width for a single unit of band.
bandspacing
: the padding between two bands.
fontsize
" the initial font size. The font size will be changed according to how many bands you have.
smallestFontSize
: the hard limit of the smallest font size.
for a level
auxBandLimit
: the upper limit of the number of bands for a gamma to cross. auxlineExt
: to extend auxlineExt unit for the auxiliary line. Default = 0.
lvlshrink
: to shrink a level by lvlshrink % on each side, for adding the connecting lines to the text label.
lvlDigit
: to control how many digits for the lvlE shown on the left of a level.
lvlEngYOffset
: to control the y offset of a energy label (on the left) for a given level.
lvlSpinYOffset
: to control the y offset of a spin label (on the right ) for a given level.
lvlLabelSplit
: to further split the text labels for overlapped levels.
for a gamma
arrowAdjust
: to fine tune the arrow end point. The higher the value, the higher end point.
arrowLength
: the higher the value, the larger size of an arrow.
minorShift
: the minor shift for a group of gammas that cascades into the same x position.
gamCrosstxtRot
: whether or not to rotate the text label for a cross gam. Default is 1 (to rotate).
for a gamma text label
gamLabeLXOffset
: use it to adjust the X offset of a label.
gamLabeLYOffset
: use it to adjust the Y offset of a label.
gamLabeLXLinear
: use it to adjust the X linear term of a label.
gamLabeLYLinear
: use it to adjust the Y linear term of a label.
output
outformat
: PS, EPS, PNG ( default = PS)
openXmgrace
: open the created agr file and edit by Xmgrace.
outputWidth
: the width of the output image (default = 800).
outputHeight
: the height of the output image (default = 600).
verbose
: whether we print out some messages during the output process. (default = Yes)
page view corners ( you can also drag corner to change it)
cornerxmin
: default = 0.02
cornerymin
: default = 0.02
cornerxmax
: default = 1.3
cornerymax
: default = 0.97
It is possible to add some texts below each band, such as the following figure.
The command will be a little bit longer:
./lvl_builder.py inputfile fineParameter output bandTextfile.
Currently, you cannot skip fineParameter and output.
The format for a bandTextFile is as following:
# this is comment. # bandN "TEXT" 0 "31Si" 1 "33Si"The lvl_builder program will calculate the position of the text, and the text will be placed the bottom.
If you are interested in how gammas are grouped and arranged, here are some short notes for you.
The first concept is the overlapped range. For simplicity, I call it xi-xf range. ( the wedge shape level makes the xi-xf range a little bit complicated)
Then let's talk about the concept of X subgroup first. When the gammas have the same xi-xf range, they will be grouped, and I call the they are in the same X subgroup.
It is also worthy of having a y subgroup within a x subgroup. In this way, we can do some manipulation on each y subgroup, so that we can save more space.
Finally, in a y subgroup under a particular x subgroup, we re-arrange the gammas in such way that the divisions are minimal ( to save space).