Uprooting PhD

software, phd, latex

Today, a bit of a blast from the past. I’m still working on getting some results published from my PhD days, and part of that is getting some old Python 2 scripts to work. Well, thankfully that isn’t very hard, they were written for Python 2(.7), which hasn’t changed and is still very available. Python 2 really is the Latin of programming languages; we (scientists) will be using in for a looooong time precisely because it isn’t receiving updates anymore. Not everyone appreciates that property, but in science, with people ever moving on and nobody having time to do maintenance, it’s actually a nice feature.

Anyway, the main thing that has changed is that I’m no longer a ROOT user (if I ever was) and am too lazy to setup ROOT (and it’s Python (2) bindings). Gate produces ROOT files containing TTree’s (PhaseSpaceActor) or TH1D’s (AugerActor), so I need to read them. At the tail end of my PhD I came across Uproot, a Python implementation of a ROOT file reader. So not of the ROOT software, just the file format. Well, that was the simplest update I’ve ever had the joy of doing, because it’s a very Pythonic library and it just werks. I even could simplify my code from this:

def thist2np_xy_cache(infile,key):
    npzfile = infile+"."+str(key)+".npz"
    if os.path.isfile(npzfile):
        cached = np.load(npzfile)
        return [cached['x'].tolist(),cached['y'].tolist()]
        for item in tfile.GetListOfKeys():
            if outname == key:
                for i in range(item.ReadObj().GetNbinsX()):
                np.savez(npzfile, x=np.array(outdata_x), y=np.array(outdata_y))
                return [outdata_x,outdata_y]

to this:

def thist_to_np_xy(infile,key='reconstructedProfileHisto'):
    return [outdata_x,outdata_y]

Note that I omitted the caching function, which wasn’t necessary anymore because Uproot is also much faster then ROOT’s Python bindings. Fantastico.

Second, TexLive 2019 was released today. It reminded me of my ol’ PhD thesis, which I still hadn’t converted to html using tex4ht. It’s ofcouse a somewhat complex document, and today I gave it my third attempt, but failed. So I’ve given up, and decided to use Mozilla’s pdf.js. See here the result.