How to read input files: YAML

YAML stands for “Yet Another Markup Language (YAML) Ain’t Markup Language (YAML^2)”. Somewhat confusing it may seem. The aim of the project which started in early 2000s was first to create yet another markup language with a different syntax. The purpose later changed from just a pure markup language to data oriented and hence the YAML^2. One of the main focusses is user readability.

YAML’s approach is similar to XML and JSON, where parsing data in files into structures of the most common programming language is targeted. Actually, YAML is a superset of JSON, i.e. it allows JSON syntax. The language allows encoding of scalars (i.e. integers, strings etc), lists and associated arrays (cf. python’s dictionaries or hashes). What follows is the syntax of how scalars, list and associated arrays (in that specific order) are created in a .yaml file:


nbr_students: 2 

grades:
  - "A"
  - "B"

student_grades:
  Anne: "A"
  Danny: "A"

Note how easy it is to read and understand the content. And now observe how easy it is to write a c++ script (with yaml-cpp) and obtain the grade of student Anne:


#include "yaml-cpp/yaml.h"
...

YAML::Node file = YAML::LoadFile("test.yaml");
std::string annes_grade = file["student_grades"]["Anne"].as<std::string>(); 

From now on this is how I provide manual inputs to my analyses.

 

Jupyter-Notebooks

Jupyter Notebook documents are documents which contain both programming code and rich text elements such as links, equations, figures and movies etc. The most attractive feature of these documents is the ability to execute it and modify its content directly in the web browser. When it comes to presenting analyses, this tool becomes very powerful. In education and teaching, subjects which include coding can be taught more efficiently and jupyter enables a richer learning process. Furthermore, in research Jupyter Notebooks is a great opportunity to present detailed advanced analyses which can be accessed and easily followed by anyone. LIGO has done this with its gravitational wave data analysis.

As with all software, one needs to install and configure Jupyter Notebook prior to run and use it. Especially in the classroom such a process presents a significant barrier. With Microsoft Azure Notebooks it is possible to easily tunnel through that barrier and directly access and use the notebook. Alternatively, JupyterHub enables  a multi-user and host support of Jupyter Notebooks. With plotly and/or bqplot the plots will be astonishing and your notebook is complete.

As a teacher you will at some point realise that jupyter notebooks is a perfect tool for student assignments. When this occurs you will want to use nbgrader. It is an extension to Jupyter which guides you as a teacher to create, manage and grade assignments. Similarly, with GitHub Classroom larger coding projects including jupyter notebooks can easily be managed by the instructor.

At Lund University I am responsible for a laboratory exercise on gamma spectroscopy. To complete the lab the students are required to perform a data analysis independently. To facilitate this part of the exercise, I implemented a Jupyter-Notebook and it can be found here: https://notebooks.azure.com/n/RMQdTC5HgFs/notebooks/DataAnalysis_GammaSpectroscopy.ipynb

I acknowledge Erik Sundell for the expertise and inspiration.

PyNE – The Nuclear Engineering Toolkit

As a nuclear physicist you sometimes desire quick and easy access to a large amount of nuclear data. You find yourself searching the web for complete data sets of the specific property your interested in. If you find a data set, it might not be as complete as you wanted and above all it requires some proper file parsing to read in the data.

With PyNE your problems are solved. It is called a Nuclear Engineering Toolkit and provides a Python API where e.g. nuclear decay data based on ENSDF can be obtained.

The Superheavy Element Factory

In Russia, Dubna, a new facility is built purely dedicated to superheavy element research. Its name, “The Superheavy Element Factory”, speaks for itself, the objective is to synthesise new chemical elements.

The following video gets you properly introduced to the factory and also the current status of superheavy element research.

https://www.youtube.com/watch?v=SBz_NDq6g6E&app=desktop

Meanwhile, we are developing the best particle-photon coincidence setup for the study of nuclear structure properties in the superheavy element region. The future is exciting!

Did you know that GitHub can be used as an LMS?

Git is an awesome version control software and it is a given for all my projects. I usually use GitHub to host my repositories. GitHub has a superb user and collaboration interface where you can e.g.:

  • Describe your repository through a Readme that interprets markdown and views it at the front page.
  • Post issues and discuss them in a forum-like system.
  • Create a Wiki to describe your project in detail.

Additionally , the webpage offers, what they denote, GitHub Classroom.  It functions as a Learning Management System (LMS) and it strongly helps the teacher to deliver material to the students, administer tests and other assignments, track student progress, and manage record-keeping.

Have a look on its possibilities: https://classroom.github.com/videos.

I know I will integrate GitHub Classroom into my teaching when the moment present itself.

Make your python script execution professional with the ArgParser

Programming in python and want to provide command line arguments easily and make it look awesome? Python’s ArgParser is definitely the thing for you!

Add flags with help descriptions with a simple command, e.g.: parser.add_argument("-v", action="store_true", help="View current settings.")

Nicely formatted output is provided via the -h flag as:

usage: Specify how many steps that should be taken in as: 'steps_x steps_y'
[-h] [-v]

optional arguments:
-h, –help show this help message and exit
-v View current settings.

Learn more: https://docs.python.org/2/howto/argparse.html#id1

Do you also love to make lists?

I am addicted to lists. Lists are so easy to interpret and write. I use them all the time at work and I make lists of:

  • To-do:s
  • What I have done
  • Instructions

Oh, see even a list here.

I always use a primitive text editor, VIM for these purposes. VIM alone is not perfect as it comes to readability and portability, hence also not sharing. The combination of the MultiMarkdown flavour of markdown syntax [http://fletcherpenney.net/multimarkdown/], Pandoc and vim-pandoc enriches and simplifies my life. Now it is a piece of cake to share my otherwise cryptic notes with others in styled .pdf and .html.

Of course this post was made this way.

The Thorium Molten Salt Reactor – Why aren’t we doing this?

Apparently, a nuclear reactor type unlike any others we are utilising today, was developed in the 1960s. It is called the Molten salt reactor (MSR) and the project was cancelled in the US much due to its non-existent alignment with the nuclear weapon’s programme. The MSR fuelled with thorium, denoted TMSR, possesses various safety advantages, much better fuel efficiency, less and not as long-lived nuclear waste such as a larger proliferation resistance.

The UK newspaper BusinessInsider have written a comprehensive description of the TMSR: http://uk.businessinsider.com/thorium-molten-salt-reactors-sorensen-lftr-2017-2?r=US&IR=T

The SciShow introduces the perhaps most promising TMSR desgin:

The rather old idea attracts several start-up companies and nations, such as China and India, and this video makes a summary of the progress of the TMSR in the world: http://www.thoriumenergyworld.com/news/tmsr-progress-summary