Google Summer of Code 2022 with TARDIS
Google Summer of Code 2022 with TARDIS
Google Summer of Code 2022 is coming to an end. In this report, I summarize what I did over the past few weeks.
TARDIS is an open-source Monte Carlo radiative-transfer spectral synthesis code for 1D models of supernova ejecta and is designed for rapid spectral modelling of supernovae.
Project Summary
This year I worked on:
Adding pytest arraydiff to 2 Carsus modules- made a similar plugin along the way.
Creating a workflow to check if a given Carsus version will produce the correct outputs in TARDIS.
Creating a module to check differences between two atomic files. This module was later intended to be used in a GitHub Action workflow.
Adding Pytest Arraydiff to Carsus
The modules in Carsus package deal with a lot of dataframes and NumPy arrays which are difficult to hard code in testing modules. Pytest Arraydiff is a plugin which saves these objects in files to be retrieved during test runs for comparison. I worked on adding Pytest Arraydiff to the Carsus environment and implementing it in two testing modules- CMFGEN and Chianti. Along with testing the CMFGEN module using Pytest Arraydiff, I also refactored the code:
Hardcoded dataframes were removed after implementing Pytest Arraydiff.
Redundant code was also removed after refactoring.
Pytest Arraydiff generates one file for each test case- which means one test function could have multiple files depending upon how it's parameterized. We thought it would have been better if it could generate just one file to store all the reference data. Overriding the plugin methods in conftest.py was one solution but was overly complicated. I proposed creating a separate plugin and created a small prototype as well. However, we stuck with pytest arraydiff because it was difficult for TARDIS to maintain a separate plugin. I made a few changes to the prototype after the GSoC coding period and plan to release it as a package too.
Workflow to check if Carsus is compatible with TARDIS
TARDIS uses atom data generated by Carsus to run the simulation. It was important to know how the changes made in Carsus atom data were impacting the TARDIS spectrum and other outputs produced during the simulation. To deal with this, I created a workflow using GitHub Actions which generated reference data and compared it with the reference data saved in the TARDIS refdata repository. It used a copy of the reference data comparison notebook for comparison.
Atom Data comparison workflow
The existing atom data comparison notebook was outdated and only compared levels and lines. A more detailed, backward compatible module was required to compare atomic data. The code could then be integrated with a GitHub Action workflow- to run on pull requests and find how the atom data evolved over time.
I haven't yet added the GitHub Action code, but the comparison code is done for the most part- unless more functionality is needed. Adding more versatile plotting functions could be one addition.
Check out the code (including other contributions)!
Implementing pytest arraydiff in Carsus: PR #311, PR #312, PR #12 on carsus-refdata,PR #11 on carsus-refdata,
Adding classmethod to allow creating a TARDISAtomData file from a yaml file: PR # 309
Workflow to check compatibility of TARDIS and Carsus: PR #313 on Carsus
Workflow to Compare Atomic Files: PR #315
Adding lines metadata: PR #303
Note: Other PRs Carsus repository.
Ongoing Work
PR #313 on Carsus was put on hold after the bandwidth of Git LFS quota was reached. I would be finishing that up after GSoC.
Removing old code from PR #315
Future Work
Removing legacy code from Carsus.
Releasing pytest share hdf as a plugin!
And a lot more! For seeing my most recent work, please check this. 😎
Acknowledgement
I am extremely grateful to my mentors- Wolfgang Kerzendorf, Andreas Flörs, Christian Vogl and Ezequiel Pássaro for their much-needed guidance and efforts. I am also very grateful to Andrew Fullard, Jack O'Brien and Sona Chitchyan for being present during the Carsus meetings and reviewing my pull requests.
I am also very grateful to have worked with a lot of amazing people from the TARDIS community. During the summer, I learnt a lot about software development, astronomy, different cultures and so much more.
Lastly, I would thank Google Summer of Code for providing me with this opportunity to work with TARDIS!