# fastlens:
Public package of FFT based evaluation of extended source magnification, `fastlens`, which is named after `fast microlensing`.
Please cite [Sugiyama 2022](https://arxiv.org/abs/2203.06637).

FFT based method of extended soruce magnification is implemented in `fastlens/mag_fft.py`. 
FFT based method of time averaged magnification is implemented in `fastlens/timeave.py`.

Please cite my paper if you use my code for your project. 

FFT based method uses public FFTLog code by Xiao Fang, available at [FFTLog-and-beyond](https://github.com/xfangcosmo/FFTLog-and-beyond), and developed in [Fang et al (2019); arXiv:1911.11947](https://arxiv.org/abs/1911.11947).

`fastlens` is open source and distributed with [MIT license](https://opensource.org/licenses/mit).

# Installation
This package is installable with both of pip and conda. Just install by running below on your shell 
```
pip install fastlens
```
for pip user, or
```
conda install -c XXX fastlens
```
for conda user.

If you prefer to download the repo and install the package from source, run
```
python setup.py install
```

## Contents: notebooks and a script
All the ipython notebooks are saved in [ipynb](ipynb) direcotry. Tutorials are available in
- [`howtouse.ipynb`](ipynb/howtouse.ipynb) shows how to use module in `magnification`.
- [`howtouse-previous-methods.ipynb`](ipynb/howtouse-previous-methods.ipynb) shows how to use modeles for methods developed in the previous studies.
Validation and comparison to previous methods are performed in
- [`timeave.ipynb`](ipynb/timeave.ipynb) validate the accuracy of implementation of time averaging effect with FFT.
- [`comparison.ipynb`](ipynb/comparison.ipynb) makes a plot of comparison of residuals by various evaluation methods of extended source magnification.
- [`timeit_methods.ipynb`](ipynb/timeit_methos.ipynb) measures computational time of various methods.
- [`paperfig.ipynb`](ipynb/paperfig.ipynb) can reproduce figures shown in the paper.
- [`testdata.py`](ipynb/testdata.py) is a module to generate reference magnification using `scipy.integrate.quad`, which will be used for validation of the FFT based method.

