Vectorizing and Parallelizing JB2008
Published:
JB2008 is an emperical atmospheric neutral density model (long name Jacchia-Bowman 2008). It is the most recent itteration of the Jacchia-Bowman family at atmospheric models and incorporates both Solar and Geomagnetic activity into the modelling of atmospheric neutral denisty, temperature, and exospheric temperature.
The model is written in Fortran and has been translated to other languages including Python (e.g., Pyatmos) and Matlab(e.g., DESTO). Models predictions can also be requested through NASA’s CCMC.
The Pyatmos is particularly useful as it provides a wrapper to run JB2008 in Python, arguabally the most popular language for research, data science and machine learning. However, Pyatmos can be slow when performing a large number of predictions. This can inhibit larger studies which require a larger number of predictions (e.g., statistical or machine learning studies).
To that end I set out to speed up the Python version of JB2008 by vectorizing portions of the code as well as leveraging parallelization. The vectorization is applied to a number of input and data prep functions. The parallelization takes advantage of the swifter module which first aims to vectorize a function call and then determines if Dask should can be used to speed up code via parallel processing. The combination of vectorization and swifter signifcantly speeds up JB2008 predictions. When ran on colab the vector-parallelized codes sees an ~11x speed boost compared to Pyatmos, 40s compared to nearly 8 minutes when predicting density for ~70,000 points (see below). On faster machines, the same calculation can take as little as 20 seconds!
The vector-parallelized code can be found here.