GSoC Blog#4 (Final Submission)
It’s the end of GSoC 2022; man, it was a great experience! Starting with aimless contributions brought me to a project which united my two passions: programming and astrophysics. The three-month journey and the community bonding period were excellent learning experiences.
From learning a new and robust language like Julia to using Unit Testing for real-world data, I learned a lot about programming. This period also tested my git skills (as open source is one of the best ways to get your hands dirty in it) as I resolved merge conflicts, changed branch heads whenever required, and always kept an eye on the log history. My whole project is presented here in terms of git commits and some explanation of what these are doing. In the end, I will point out what’s next from here, and I hope Stingray will grow up to become a beloved package like many others in the Julia Community.
I did the project in 5PRs (three merged and two open to review), which are listed below:
Implement Workflow (Merged)
Add Fourier methods and tests (Merged)
Implement GTI Reading and Handling (Merged)
Implement EventList (Open)
I also documented this journey in four other blogs: Blog0, Blog1, Blog2, and Blog3.
Starting a package from scratch can look like a behemoth task; you can confuse which methods to begin with, what the architecture will be, and how I will ensure continuous testing. Fortunately, my mentors were very helpful, and in the community bonding period itself, I initialized a basic package with the help of PkgTemplate.jl with integrated CIs.
My mentor Matteo suggested I go on to implement Fourier methods first as they are the primary thing required to create power and cross-spectra from an array. I started on with it, and the PR was a great lesson both in terms of how much code I needed to port with passing tests and how idiomatic I had to keep it to discover the full power of Julia. My initial code was pretty pythonic, and my other mentor, Mosè, gave much good advice on how to fix them and keep the code readable. Still, due to the sheer amount of code and tests I needed to write, the code is currently non-idiomatic for a few functions, and I hope to make them efficient in the future.
After this, I needed a working tool to handle GTIs; trust me; this was the best part of the project. I was having fun with different interval operations I needed to implement, looking at them from different angles and maintaining the code’s sanctity. The tests passed, and I had pretty idiomatic code written there with handling file reading (HDF5 and FITS) for some tests, which helped me in the future.
After the mid-evals, I got somewhat busy due to tests and college courses. After the first week, I started contributing again by considering different ways to represent photon arrival and count data. Using structs and methods for them (including extending Base functions when required) was the way to go, and after half of the second phase, I managed to get a PR on these things though the code is still in review. One can now plot the LightCurves, read data from a FITS file and use the Fourier methods to get the power and cross-spectra and perform operations on the related GTIs. But how?
In the final week, my focus was to provide documentation on the functions mentioned, taking help from the Python package and changing it as required, especially as the markdowns are different for both languages’ docstrings. I followed it with writing a user guide, although it is still incomplete in the current PR, and I hope to get it done well by the end of this month (working outside of GSoC :).
As a whole, this project was exciting to me. I can safely say that I lacked experience in many parts, but my mentors were fantastic, and I had some great discussions with them. The essential power of Julia is how it handles memory and compiles the code as required (JIT), and with this in focus, the project can still grow to various extents.
For example, good use of type systems in the Fourier methods, a clearer way to use generators (the resumable functions), and user APIs for Cross and Power Spectra would be the first thing this package needs working on. After this, we can implement other features like Bi-Spectra and Var-Energy Spectra. In the end, one can see how powerful Julia can be if programmed correctly. Below is the runtime for reading the same files in Python and Julia (Julia is doing almost 40 times faster). This order of speed boost is still an excellent achievement for Julia while keeping all the important arrays and metadata from the file in a struct.
With this, I end this blog and this awesome GSoC program, with a hope to keep contributing to this and other open source projects and learning new things. Great thanks to my mentors, Open Astronomy and Google for providing this opportunity.