Last week, on a whim, I gave Claude Code (CC) a task that turned out to be both possible and highly useful, because it removed a common annoyance for some colleagues and myself.
See, there is this C-library called CPL that ESO uses for processing of astronomical data. There also is a Python-wrapper for it, pycpl, that allows to use the library from Python, which is great because it's the language that astronomers and data scientists mostly use nowadays.
However, pycpl does not come with CPL, but instead requires it to be installed beforehand, which often implies compiling it oneself because not all operating systems package the right version, if at all. This is not a big hurdle for developers, but if one wants to share a half-finished pipeline with some prospective users, it easily becomes one. Containers and such can help with this but are always a crutch that I would rather avoid.
Claude to the rescue. The off-handed remark in a telecon, that we should just make a pycpl package that comes with CPL (and its dependency libs) included, took hold with me long enough to ask CC to just do it!
I started by downloading the latest CPL source code, and the three libs it needs. Then I asked CC to initialize the git repository and sort out which files to add and which to ignore.
After pushing to Github, I could switch to the online version of CC where I had free credits to burn, so no harm done if this endeavour would turn into failure. Then I just quickly told it what to do like this, typos and all:
pycpl is a python wrapper for C-lib CPL. But it is packaged without the C-lib, so the overall goal is to upgrade the pycpl package to include the build of CPL and its depencencies (which are also present here). start by looking at the build system of pycpl and how to include the other lobraries to it. then move the libs to appropriate places inside pycpl and try the build.
This session log and this follow-up basically show how CC figured it all out. I only skimmed through it at the time and could not tell you what exactly it did. At some point I realized it needed some of the files that were omitted earlier, so I added those back. In the end, I had a package that installed locally -- a success already.
But what would make this really useful would be a Python "wheel", i.e. a package bundle that is pre-compiled for different platforms and Python version. This way, users would be able to install instantly, without any compiling happening at all. So I naturally asked CC about it, and how to set it up such that GitHub Actions do the compiling. This was the most tedious bit. CC needed many iterations to get this right and compiling on GitHub is not fast. So I let it work in the background over an evening, only checking in occasionally. Claude figured it out in the end! The package installs and works nicely for myself and several colleagues.
Initially, the plan was to also upload to PyPI, because ESO does not actually do that. But I was not able to put claim to the name "pycpl" there, and without that it would not work. Plus I did not want to step on people's toes too much by publishing work that is not my own. Even though, in principle, it should be fine with GPL-licensed code.
Thus, for now, one has to provide an "extra index URL" to install this pycpl package. Use uv, for example like this:
(uv) pip install pycpl --extra-index-url https://ivh.github.io/pycpl/simple/
Or try if it works without having anything prepared:
uv run --with pycpl --extra-index-url https://ivh.github.io/pycpl/simple/ python -c "import cpl;"
Or add it to the header of a script file like this:
uv add --script main.py --index https://ivh.github.io/pycpl/simple/ pycpl
One can also add the index URL to one's pyproject.toml, together with ESO index URL that provides tools like pyesorex and edps, which seem to play nicely with my pycpl instead of ESO's own. For how to do that, see the README in the GitHub repo.
I've been using Claude Code (CC) quite extensively in recent weeks, and apart from a few fails it's been a blast. I want to write about a few of the things I got it to do successfully, but in order to do that I need to be able to share the session logs.
Unfortunately, there is no straight-forward way to do this. The logs
are saved as .jsonl files in
$HOME/.claude/projects/-path-to-your-work-directory/ and when using the
online version of CC, all one to do is use the Open
in CLI button and continue locally, then the .jsonl with the whole session
will show up in the project folder.
These file are a bit unweildy. For example, they contain the whole content of files that CC reads and a buch of distracting metadata. I tried Simon Willison's claude_to_markdown.py but that was not quite what I wanted, which is a static HTML file with embedded JavaScript (JS) to hide the long reads and outputs by default, but make them expandable if needed.
What better way to achieve this than just let CC do it? Very meta, I know. So
I donwloaded the JS from https://claude.ai/code/ (after all, they have solved
the same task there already) and put it into a fresh repo with an example
session log. This is the outline I wrote and added to the repo:
# main goal
a script, python or other, that takes session logs from Claude Code (CC)
and converts them into HTML.
## example data
- a06171f9-5f33-4258-84e1-4dc70e84c6dd.jsonl an example session log. all
input files will have this format.
- Screenshot, two example screenshots of how it looks on CC web.
- CCweb_example.html and CCweb_example_files/ , the saved web page of CC
that should contain useful routines to render the session. Ignore the
left half of the page and session management, only the session part
itself is needed.
## requirements
- the output should be a single html-file, named like the input but ending
.jsonl exchanged to .html
- all javascript should be inlined.
- the script does not need to be self-contained, can e.g. read js files or
templates to make the output.
- the html should look similar to the screenshots, i.e. compact with
unnecessary information skipped, file reads hiden, and long diffs
shortened but expandable.
Then all that was let do do was to point CC to the repository and tell it to get crackin'.
I wasn't a perfect one-shot success, as you can see. But with just a little prodding CC figured it out. I then continued in a new short session to have it sum up the elapsed working time and put that on top of the HTML. Not bad at all, I would say. Feel free to check it out on gitHub.
For AI users, this frenzy is a gift. Competition has meant that the models improve rapidly and their prices stay low. There is no reason not to use these products while they are free or almost free.
I fully agree and get lots of value from my 20$ Claude subscription, mostly via ClaudeCode. More on that later, but I am happy to take investors' money by buying a product that is sold under break-even price. May it last as long as possible. But to continue the quote:
For AI investors, the economics are unforgiving. Better chips make models faster—and make yesterday’s chips worthless. Every leap forward accelerates depreciation on the collateral lenders are asked to finance. That is why banks refuse to lend, they prefer assets that last longer than a news cycle.
If you are even remotely interested in the war on Ukraine, and don't know about Danish analyst Anders Puck Nielsen yet, make sure to check out his Youtube channel where he does an excellent job of explaining context and presenting his view on things. No fluff videos that will leave you more informed that following the news.
Start with the latest video on the current situation with the "peace plan".
Oh my! This site has been somewhat neglected, hasn't it? More than a year since the last post. The house and woodshed in that picture not even ours any more! We bought a farm outside of Östhammar this spring, and spent an awful lot of time moving and getting settled.
Taking over such a large place is no easy task, but I now get to do fun things
like driving my tractor into my forest to get timber and firewood.

The farm has its website at https://www.bestbo.se and there you find the social media links, and some occasional updates.
The aforementioned freshly-built woodshed. Apart from the three old pallets that serve as floor, this is made completely from lumber that I made myself, from trees that needed to be taken down because of bark bettles.
Not sure yet, if it will get plainted in the same Falu red as the house, or allowed to grey on its own.
You probably have not noticed, but this site was offline for twelve days. And so was I.
This is because the glass fiber link that leads to our home in the forest was broken in connection with some work further down the road. Then the usual fuckups of privatized and distributed responsibilities ensued. Meaning that I had to lean hard on our network provider (ISP) to finally refer the issue to the network operator after 5 days. And then another week to get the technician to diagnose, and talk to the other company that caused the fault.
This is the kind of thing that would have easily annoyed the hell out of younger me - things not working as they should! The world is mean to me!!
This time, though, I was quite fine with it. I am on holidays anyway and can in fact build a new shed for firewood without internet access (pics will follow!). The notifications for emails had been turned off anyway and for urgent stuff we still had the 4G of our phones - so there really only remained the inconvenience that we imagined ourselves.
Still, it's good to be back online.
A few weeks ago, I bought and started reading The World of the Crusades by Christopher Tyerman. I don't even remember where I saw the book recommended or what made it sound like a good idea, but I admit that the crusades have always been a bit of a gap in my overall layman's picture of history. What were they, actually, how important, and most of all why‽
This book is a bit dense though. While well made, written and illustrated, I rarely make it more than ten pages per night, before I fall asleep. The author has a tendency toward unnecessarily high-brow language but I think it is more the choice of which details to highlight, and the lack of connection between them, that makes it feel tedious to me.
Thus, I will put it aside for a while and dive into some lighter summer reading: The Culture series by Iain M. Banks, which I have heard many good things about over the years but never read.