LDEO-CREW / Pythonic-DISORT

Discrete Ordinates Solver for the (1D) Radiative Transfer Equation in a single or multi-layer plane-parallel atmosphere. Coded entirely in Python 3. Based on Stamnes' FORTRAN DISORT (see references in the Jupyter Notebook) and has its main features.
https://pythonic-disort.readthedocs.io/en/latest/
MIT License
11 stars 2 forks source link

Speed up the for-loops in PythonicDISORT using the fact that many np.linalg functions can act on a list of matrices #6

Closed dhjx1996 closed 6 months ago

dhjx1996 commented 1 year ago

As of NumPy version 1.8.0 (remember to update requirements), np.linalg.eig([list of matrices]) will output a list of the eigenpairs for each matrix. This is much faster than using a python for-loop. This should work for many other np.linalg functions as well, see https://numpy.org/doc/stable/reference/routines.linalg.html#module-numpy.linalg.

PythonicDISORT will still require for-loops to assemble the various systems to be solved, but we can potentially speed the algorithm up greatly by using the above on the linear algebra operations which are the most expensive parts of each loop.

dhjx1996 commented 1 year ago

Done for the loops over the atmospheric layers (inside __one_Fouriermode.py).