From 38404fd467363eb4e53bf86bf2dbfefca3f6b841 Mon Sep 17 00:00:00 2001 From: Siavash Yasini Date: Wed, 16 Sep 2020 15:16:52 -0700 Subject: [PATCH 1/6] remove README.md --- README.md | 287 ------------------------------------------------------ 1 file changed, 287 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index c33a58e..0000000 --- a/README.md +++ /dev/null @@ -1,287 +0,0 @@ -logo - -# AstroPaint -_A python package for painting the sky_ - -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/syasini/AstroPaint/master?filepath=tutorial.ipynb) - -You can install **AstroPaint** by running the following in the command line: - -`git clone https://github.com/syasini/AstroPaint.git` - -`cd AstroPaint` - -`pip install [-e] .` - -the `-e` argument will install the package in editable mode which is suitable for developement. If you want to modify the code use this option. - -**Important Note**: -If you want the sample catalogs to be cloned automatically - along with the - rest of the repository, make sure you have [Git Large File Storage (`git lfs`)](https://git-lfs.github.com/) installed. - -If you are a conda user, please consider creating a new environment before - installation: - - `conda create -n astropaint python=3.7` - - `conda activate astropaint` - - -# Workflow - -Converting catalogs to mock maps with AstroPaint is extremely simple. Here is what an example session looks like: - -```python -from astropaint import Catalog, Canvas, Painter - -catalog = Catalog(data=your_input_data) - -canvas = Canvas(catalog, nside) - -painter = Painter(template=your_radial_profile) - -painter.spray(canvas) -``` - -That's it! Now you can check out your masterpiece using - -`canvas.show_map()` - -![BG](images/BG_websky_cover.png) - -# What is AstroPaint? - -AstroPaint is a python package for generating and visualizing sky maps of a wide range of astrophysical signals -originating from dark matter halos or the gas that they host. AstroPaint creates a whole-sky mock map of the -target signal/observable, at a desired resolution, by combining an input halo catalog and the radial/angular -profile of the astrophysical effect. The package also provides a suite of tools that can facilitate analysis - routines such as catalog filtering, map manipulation, and cutout stacking. The simulation suite has an - Object-Oriented design and runs in parallel, making it both easy to use and readily scalable for production - of high resolution maps with large underlying catalogs. Although the package has been primarily developed - to simulate signals pertinent to galaxy clusters, its application extends to halos of arbitrary size or - even point sources. - -# Package Structure - -While there is no external documentation for the code yet, you can use [this - chart](https://www.mindmeister.com/1417665103/astropaint-astropaint-py?fullscreen=1) - to understand the package structure and see what methods are available so - far. - - -# Examples - -## Nonsense Template - -Here's an example script that paints a nonsense template on a 10 x 10 [sqr deg] - patch of the `Sehgal` catalog: - - -```python -import numpy as np -from astropaint import Catalog, Canvas, Painter - -# Load the Sehgal catalog -catalog = Catalog("Sehgal") - -# cutout a 10x10 sqr degree patch of the catalog -catalog.cut_lon_lat(lon_range=[0,10], lat_range=[0,10]) - -# pass the catalog to canvas -canvas = Canvas(catalog, nside=4096, R_times=5) - -# define a nonsense template and plot it -def a_nonsense_template(R, R_200c, x, y, z): - - return np.exp(-(R/R_200c/3)**2)*(x+y+z) - -# pass the template to the painter -painter = Painter(template=a_nonsense_template) - -# plot the template for halos #0, #10, and #100 for R between 0 to 5 Mpc -R = np.linspace(0,5,100) -painter.plot_template(R, catalog, halo_list=[0,10,100]) -``` -

-template -

-The painter automatically extracts the parameters `R_200c` and `x,y,z -` coordinates of the halo from the catalog that the canvas was initialized - with. Let's spray ths canvas now: - -```python -# spray the template over the canvas -painter.spray(canvas) - -# show the results -canvas.show_map("cartview", lonra=[0,10], latra=[0,10]) -``` -

-map -

- -_Voila!_ - -You can use the `n_cpus` argument in the spray function to paint in parallel and speed things up! -The default value `n_cpus=-1` uses all the available cpus. - -

-parallel -

- -## Stacking -You can easily stack cutouts of the map using the following: - -```python -deg_range = [-0.2, 0.2] # deg -halo_list = np.arange(5000) # stack the first 5000 halos - -# stack the halos and save the results in canvas.stack -stack = canvas.stack_cutouts(halo_list=halo_list, lon_range=deg_range, lat_range=deg_range) - -plt.imshow(canvas.stack) -``` -

-stack -

- If this is taking too long, use `parallel=True` for *parallel stacking*. - -## Line-Of-Sight integration of 3D profiles - -AstroPaint only allows you to paint 2D (line-of-sight integrated) profiles on - your catalog halos, so if you already have the analytical expression of - the projected profile you want to paint, we are in business. However, not - all 3D profiles can be LOS integrated analytically (e.g. generalized NFW - or Einasto, etc), and integrating profiles numerically along every - single LOS is generally expensive. In order to alleviate this problem, AstroPaint offers two python decorators - `@LOS_integrate` and `@interpolate` which make 3D -> 2D projections effortless. - - To convert a 3D profile into a 2D LOS integrated profile, all you need to do - is add the `@LOS_integrate` to the definition. - - For example, here's how you can turn a 3D top hat profile - - ```python -def tophat_3D(r, R_200c): - """Equals 1 inside R_200c and 0 outside""" - - tophat = np.ones_like(r) - tophat[r > R_200c]=0 - - return tophat -``` - -into a 2D projected one: - -```python -from astropaint.lib.utilities import LOS_integrate - -@LOS_integrate -def tophat_2D(R, R_200c): - """project tophat_3D along the line of sight""" - - return tophat_3D(R, R_200c) -``` -This function integrates the `tophat_3D` function along every single line of - sight. If you have many halos in a high resolution map, this can take - forever. The trick to make this faster would be to integrate along a - several LOSs and interpolate the values in between. This is what the - `@interpolate` decorator does. So, a faster version of the `tophat_2D - ` function can be constructed as the following: - - -```python -from astropaint.lib.utilities import interpolate - -@interpolate(n_samples=20) -@LOS_integrate -def tophat_2D_interp(R, R_200c): - """project and interpolate tophat_3D along the line of sight""" - - return tophat_3D(R, R_200c) -``` -This is much faster, but the speed comes at a small price. If your 3D profile - is not smooth, the interpolated 2D projection will slightly deviate from the - exact integration. -

- interp -

-You can minimize this deviation by increasing the `n_samples` argument of the - `@interpolate` decorator, but that will obviously decrease the painting speed. - - Does this plot agree with what you would expect a LOS integrated top hat - profile (a.k.a. a solid sphere) to look like? - -## Painting Optical Depth and kSZ Profiles on the WebSky Catalog - -Let's use the `Battaglia16` gas profiles to paint tau (optical depth) and - kinetic Sunyaev-Zeldovich (kSZ) on the WebSky catalog halos. - - ```python -from astropaint.profiles import Battaglia16 - - tau_painter = Painter(Battaglia16.tau_2D_interp) -``` - - Since the shape of the profile is smooth, we won't lose accuracy by using the - interpolator. -

-tau -

- -Let's paint this on a 5x5 sqr deg patch of the WebSky catalog with a mass - cut of 8E13 M_sun. - - ```python -catalog = Catalog("websky_lite_redshift") -catalog.cut_lon_lat(lon_range=[5,10], lat_range=[5,10]) -catalog.cut_M_200c(8E13) - -canvas = Canvas(catalog, nside=8192, R_times=3) - -tau_painter.spray(canvas) -``` -

-tau_map -

-The `Battaglia16.kSZ_T` function uses this tau and multiplies it by the - dimensionless velocity of the halos to get the kSZ signal. - -```python -kSZ_painter = Painter(Battaglia16.kSZ_T) -kSZ_painter.spray(canvas) -``` -And here is what it looks like: -

-ksz_map -

- - -# Art Gallery - -Just because AstroPaint is developed for probing new science and doing - serious stuff, it doesn't mean you can't have fun with it! Check out our - [cool web app](https://astropaint-art-gallery.herokuapp.com/) to get your hands dirty with some paint. - -**Made with AstroPaint** - - - - -# How to contribute - -If you would like to contribute to AstroPaint, take the following steps: - -1) Fork this repository -2) Clone it on your local machine -3) Create a new branch (be as explicit as possible with the branch name) -4) Add and Commit your changes to the local branch -5) Push the branch to your forked repository -6) Submit a pull request on this repository - -See [this repository](https://github.com/firstcontributions/first-contributions) or [Kevin Markham's step-by-step guide](https://www.dataschool.io/how-to-contribute-on-github/) for more detailed - instructions. - -Developement happens on the `develop` branch, so make sure you are always in sync with the latest version and submit your pull requests to this branch. - From 817d613a693133cf36979bc9860f4037df817f12 Mon Sep 17 00:00:00 2001 From: Siavash Yasini Date: Wed, 16 Sep 2020 15:18:03 -0700 Subject: [PATCH 2/6] change logo size --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9739433..6d5584c 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ .. image:: docs/images/logo.PNG :target: docs/images/logo.PNG - :height: 150 + :height: 100 AstroPaint ========== From ec157ccd774311d0f2be6c586d11545d405898dd Mon Sep 17 00:00:00 2001 From: Siavash Yasini Date: Wed, 16 Sep 2020 15:21:03 -0700 Subject: [PATCH 3/6] Add README.md back --- README.md | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c33a58e --- /dev/null +++ b/README.md @@ -0,0 +1,287 @@ +logo + +# AstroPaint +_A python package for painting the sky_ + +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/syasini/AstroPaint/master?filepath=tutorial.ipynb) + +You can install **AstroPaint** by running the following in the command line: + +`git clone https://github.com/syasini/AstroPaint.git` + +`cd AstroPaint` + +`pip install [-e] .` + +the `-e` argument will install the package in editable mode which is suitable for developement. If you want to modify the code use this option. + +**Important Note**: +If you want the sample catalogs to be cloned automatically + along with the + rest of the repository, make sure you have [Git Large File Storage (`git lfs`)](https://git-lfs.github.com/) installed. + +If you are a conda user, please consider creating a new environment before + installation: + + `conda create -n astropaint python=3.7` + + `conda activate astropaint` + + +# Workflow + +Converting catalogs to mock maps with AstroPaint is extremely simple. Here is what an example session looks like: + +```python +from astropaint import Catalog, Canvas, Painter + +catalog = Catalog(data=your_input_data) + +canvas = Canvas(catalog, nside) + +painter = Painter(template=your_radial_profile) + +painter.spray(canvas) +``` + +That's it! Now you can check out your masterpiece using + +`canvas.show_map()` + +![BG](images/BG_websky_cover.png) + +# What is AstroPaint? + +AstroPaint is a python package for generating and visualizing sky maps of a wide range of astrophysical signals +originating from dark matter halos or the gas that they host. AstroPaint creates a whole-sky mock map of the +target signal/observable, at a desired resolution, by combining an input halo catalog and the radial/angular +profile of the astrophysical effect. The package also provides a suite of tools that can facilitate analysis + routines such as catalog filtering, map manipulation, and cutout stacking. The simulation suite has an + Object-Oriented design and runs in parallel, making it both easy to use and readily scalable for production + of high resolution maps with large underlying catalogs. Although the package has been primarily developed + to simulate signals pertinent to galaxy clusters, its application extends to halos of arbitrary size or + even point sources. + +# Package Structure + +While there is no external documentation for the code yet, you can use [this + chart](https://www.mindmeister.com/1417665103/astropaint-astropaint-py?fullscreen=1) + to understand the package structure and see what methods are available so + far. + + +# Examples + +## Nonsense Template + +Here's an example script that paints a nonsense template on a 10 x 10 [sqr deg] + patch of the `Sehgal` catalog: + + +```python +import numpy as np +from astropaint import Catalog, Canvas, Painter + +# Load the Sehgal catalog +catalog = Catalog("Sehgal") + +# cutout a 10x10 sqr degree patch of the catalog +catalog.cut_lon_lat(lon_range=[0,10], lat_range=[0,10]) + +# pass the catalog to canvas +canvas = Canvas(catalog, nside=4096, R_times=5) + +# define a nonsense template and plot it +def a_nonsense_template(R, R_200c, x, y, z): + + return np.exp(-(R/R_200c/3)**2)*(x+y+z) + +# pass the template to the painter +painter = Painter(template=a_nonsense_template) + +# plot the template for halos #0, #10, and #100 for R between 0 to 5 Mpc +R = np.linspace(0,5,100) +painter.plot_template(R, catalog, halo_list=[0,10,100]) +``` +

+template +

+The painter automatically extracts the parameters `R_200c` and `x,y,z +` coordinates of the halo from the catalog that the canvas was initialized + with. Let's spray ths canvas now: + +```python +# spray the template over the canvas +painter.spray(canvas) + +# show the results +canvas.show_map("cartview", lonra=[0,10], latra=[0,10]) +``` +

+map +

+ +_Voila!_ + +You can use the `n_cpus` argument in the spray function to paint in parallel and speed things up! +The default value `n_cpus=-1` uses all the available cpus. + +

+parallel +

+ +## Stacking +You can easily stack cutouts of the map using the following: + +```python +deg_range = [-0.2, 0.2] # deg +halo_list = np.arange(5000) # stack the first 5000 halos + +# stack the halos and save the results in canvas.stack +stack = canvas.stack_cutouts(halo_list=halo_list, lon_range=deg_range, lat_range=deg_range) + +plt.imshow(canvas.stack) +``` +

+stack +

+ If this is taking too long, use `parallel=True` for *parallel stacking*. + +## Line-Of-Sight integration of 3D profiles + +AstroPaint only allows you to paint 2D (line-of-sight integrated) profiles on + your catalog halos, so if you already have the analytical expression of + the projected profile you want to paint, we are in business. However, not + all 3D profiles can be LOS integrated analytically (e.g. generalized NFW + or Einasto, etc), and integrating profiles numerically along every + single LOS is generally expensive. In order to alleviate this problem, AstroPaint offers two python decorators + `@LOS_integrate` and `@interpolate` which make 3D -> 2D projections effortless. + + To convert a 3D profile into a 2D LOS integrated profile, all you need to do + is add the `@LOS_integrate` to the definition. + + For example, here's how you can turn a 3D top hat profile + + ```python +def tophat_3D(r, R_200c): + """Equals 1 inside R_200c and 0 outside""" + + tophat = np.ones_like(r) + tophat[r > R_200c]=0 + + return tophat +``` + +into a 2D projected one: + +```python +from astropaint.lib.utilities import LOS_integrate + +@LOS_integrate +def tophat_2D(R, R_200c): + """project tophat_3D along the line of sight""" + + return tophat_3D(R, R_200c) +``` +This function integrates the `tophat_3D` function along every single line of + sight. If you have many halos in a high resolution map, this can take + forever. The trick to make this faster would be to integrate along a + several LOSs and interpolate the values in between. This is what the + `@interpolate` decorator does. So, a faster version of the `tophat_2D + ` function can be constructed as the following: + + +```python +from astropaint.lib.utilities import interpolate + +@interpolate(n_samples=20) +@LOS_integrate +def tophat_2D_interp(R, R_200c): + """project and interpolate tophat_3D along the line of sight""" + + return tophat_3D(R, R_200c) +``` +This is much faster, but the speed comes at a small price. If your 3D profile + is not smooth, the interpolated 2D projection will slightly deviate from the + exact integration. +

+ interp +

+You can minimize this deviation by increasing the `n_samples` argument of the + `@interpolate` decorator, but that will obviously decrease the painting speed. + + Does this plot agree with what you would expect a LOS integrated top hat + profile (a.k.a. a solid sphere) to look like? + +## Painting Optical Depth and kSZ Profiles on the WebSky Catalog + +Let's use the `Battaglia16` gas profiles to paint tau (optical depth) and + kinetic Sunyaev-Zeldovich (kSZ) on the WebSky catalog halos. + + ```python +from astropaint.profiles import Battaglia16 + + tau_painter = Painter(Battaglia16.tau_2D_interp) +``` + + Since the shape of the profile is smooth, we won't lose accuracy by using the + interpolator. +

+tau +

+ +Let's paint this on a 5x5 sqr deg patch of the WebSky catalog with a mass + cut of 8E13 M_sun. + + ```python +catalog = Catalog("websky_lite_redshift") +catalog.cut_lon_lat(lon_range=[5,10], lat_range=[5,10]) +catalog.cut_M_200c(8E13) + +canvas = Canvas(catalog, nside=8192, R_times=3) + +tau_painter.spray(canvas) +``` +

+tau_map +

+The `Battaglia16.kSZ_T` function uses this tau and multiplies it by the + dimensionless velocity of the halos to get the kSZ signal. + +```python +kSZ_painter = Painter(Battaglia16.kSZ_T) +kSZ_painter.spray(canvas) +``` +And here is what it looks like: +

+ksz_map +

+ + +# Art Gallery + +Just because AstroPaint is developed for probing new science and doing + serious stuff, it doesn't mean you can't have fun with it! Check out our + [cool web app](https://astropaint-art-gallery.herokuapp.com/) to get your hands dirty with some paint. + +**Made with AstroPaint** + + + + +# How to contribute + +If you would like to contribute to AstroPaint, take the following steps: + +1) Fork this repository +2) Clone it on your local machine +3) Create a new branch (be as explicit as possible with the branch name) +4) Add and Commit your changes to the local branch +5) Push the branch to your forked repository +6) Submit a pull request on this repository + +See [this repository](https://github.com/firstcontributions/first-contributions) or [Kevin Markham's step-by-step guide](https://www.dataschool.io/how-to-contribute-on-github/) for more detailed + instructions. + +Developement happens on the `develop` branch, so make sure you are always in sync with the latest version and submit your pull requests to this branch. + From c59f3def8c32bd419f269b9f5a39ebf8fb24512e Mon Sep 17 00:00:00 2001 From: Siavash Yasini Date: Wed, 16 Sep 2020 15:24:26 -0700 Subject: [PATCH 4/6] Add documentation link to README and index.rst --- README.rst | 337 ----------------------------------------------------- 1 file changed, 337 deletions(-) delete mode 100644 README.rst diff --git a/README.rst b/README.rst deleted file mode 100644 index 6d5584c..0000000 --- a/README.rst +++ /dev/null @@ -1,337 +0,0 @@ -.. role:: raw-html-m2r(raw) - :format: html - - -.. image:: docs/images/logo.PNG - :target: docs/images/logo.PNG - :height: 100 - -AstroPaint -========== - -*A python package for painting the sky* - - -.. image:: https://mybinder.org/badge_logo.svg - :target: https://mybinder.org/v2/gh/syasini/AstroPaint/master?filepath=tutorial.ipynb - :alt: Binder - - -You can install **AstroPaint** by running the following in the command line: - -``git clone https://github.com/syasini/AstroPaint.git`` - -``cd AstroPaint`` - -``pip install [-e] .`` - -the ``-e`` argument will install the package in editable mode which is suitable for developement. If you want to modify the code use this option. - -**Important Note**: -If you want the sample catalogs to be cloned automatically along with the -rest of the repository, make sure you have `Git Large File Storage (git lfs) `_ installed. - -If you are a conda user, please consider creating a new environment before installation: - - ``conda create -n astropaint python=3.7`` - - ``conda activate astropaint`` - -Workflow -======== - -Converting catalogs to mock maps with AstroPaint is extremely simple. Here is what an example session looks like: - -.. code-block:: python - - from astropaint import Catalog, Canvas, Painter - - catalog = Catalog(data=your_input_data) - - canvas = Canvas(catalog, nside) - - painter = Painter(template=your_radial_profile) - - painter.spray(canvas) - -That's it! Now you can check out your masterpiece using - -``canvas.show_map()`` - - -.. image:: docs/images/BG_websky_cover.png - :target: docs/images/BG_websky_cover.png - :alt: BG - -What is AstroPaint? -=================== -AstroPaint is a python package for generating and visualizing sky maps of a wide range of astrophysical signals -originating from dark matter halos or the gas that they host. AstroPaint creates a whole-sky mock map of the target -signal/observable, at a desired resolution, by combining an input halo catalog and the radial/angular profile of the -astrophysical effect. The package also provides a suite of tools that can facilitate analysis routines such as catalog -filtering, map manipulation, and cutout stacking. The simulation suite has an Object-Oriented design and runs in -parallel, making it both easy to use and readily scalable for production of high resolution maps with large underlying -catalogs. Although the package has been primarily developed to simulate signals pertinent to galaxy clusters, its -application extends to halos of arbitrary size or even point sources. - -Package Structure -================= - -While there is no external documentation for the code yet, you can use `this chart `_ -to understand the package structure and see what methods are available so far. - -Examples -======== - -Nonsense Template ------------------ - -Here's an example script that paints a nonsense template on a 10 x 10 [sqr deg] -patch of the ``Sehgal`` catalog: - -.. code-block:: python - - import numpy as np - from astropaint import Catalog, Canvas, Painter - - # Load the Sehgal catalog - catalog = Catalog("Sehgal") - - # cutout a 10x10 sqr degree patch of the catalog - catalog.cut_lon_lat(lon_range=[0,10], lat_range=[0,10]) - - # pass the catalog to canvas - canvas = Canvas(catalog, nside=4096, R_times=5) - - # define a nonsense template and plot it - def a_nonsense_template(R, R_200c, x, y, z): - - return np.exp(-(R/R_200c/3)**2)*(x+y+z) - - # pass the template to the painter - painter = Painter(template=a_nonsense_template) - - # plot the template for halos #0, #10, and #100 for R between 0 to 5 Mpc - R = np.linspace(0,5,100) - painter.plot_template(R, catalog, halo_list=[0,10,100]) - - - -.. image:: docs/images/a_random_template.png - :target: docs/images/a_random_template.png - :height: 300 - :align: center - -The painter automatically extracts the parameters `R_200c` and `x,y,z` -coordinates of the halo from the catalog that the canvas was initialized -with. Let's spray ths canvas now: - -.. code-block:: python - - # spray the template over the canvas - painter.spray(canvas) - - # show the results - canvas.show_map("cartview", lonra=[0,10], latra=[0,10]) - - -.. image:: docs/images/a_random_map.png - :target: docs/images/a_random_map.png - :height: 300 - :align: center - - -*Voila!* - -You can use the `n_cpus` argument in the spray function to paint in parallel and speed things up! -The default value `n_cpus=-1` uses all the available cpus. - - - -.. image:: docs/images/parallel.gif - :target: docs/images/parallel.gif - :height: 450 - :align: center - - - -Stacking --------- - -You can easily stack cutouts of the map using the following: - -.. code-block:: python - - deg_range = [-0.2, 0.2] # deg - halo_list = np.arange(5000) # stack the first 5000 halos - - # stack the halos and save the results in canvas.stack - stack = canvas.stack_cutouts(halo_list=halo_list, lon_range=deg_range, lat_range=deg_range) - - plt.imshow(canvas.stack) - - - -.. image:: docs/images/a_random_stack.png - :target: docs/images/a_random_stack.png - :height: 200 - :align: center - - -If this is taking too long, use `parallel=True` for *parallel stacking*. - -Line-Of-Sight integration of 3D profiles ----------------------------------------- - -AstroPaint only allows you to paint 2D (line-of-sight integrated) profiles on -your catalog halos, so if you already have the analytical expression of -the projected profile you want to paint, we are in business. However, not -all 3D profiles can be LOS integrated analytically (e.g. generalized NFW -or Einasto, etc), and integrating profiles numerically along every -single LOS is generally expensive. In order to alleviate this problem, AstroPaint offers two python decorators -`@LOS_integrate` and `@interpolate` which make 3D -> 2D projections effortless. - -To convert a 3D profile into a 2D LOS integrated profile, all you need to do -is add the `@LOS_integrate` to the definition. - -For example, here's how you can turn a 3D top hat profile - -.. code-block:: python - - def tophat_3D(r, R_200c): - """Equals 1 inside R_200c and 0 outside""" - - tophat = np.ones_like(r) - tophat[r > R_200c]=0 - - return tophat - - -into a 2D projected one: - -.. code-block:: python - - from astropaint.lib.utilities import LOS_integrate - - @LOS_integrate - def tophat_2D(R, R_200c): - """project tophat_3D along the line of sight""" - - return tophat_3D(R, R_200c) - -This function integrates the `tophat_3D` function along every single line of -sight. If you have many halos in a high resolution map, this can take -forever. The trick to make this faster would be to integrate along a -several LOSs and interpolate the values in between. This is what the -`@interpolate` decorator does. So, a faster version of the `tophat_2D` -function can be constructed as the following: - - -.. code-block:: python - - from astropaint.lib.utilities import interpolate - - @interpolate(n_samples=20) - @LOS_integrate - def tophat_2D_interp(R, R_200c): - """project and interpolate tophat_3D along the line of sight""" - - return tophat_3D(R, R_200c) - -This is much faster, but the speed comes at a small price. If your 3D profile -is not smooth, the interpolated 2D projection will slightly deviate from the -exact integration. - -.. image:: docs/images/tophat_interp.png - :align: center - :height: 200 - -You can minimize this deviation by increasing the `n_samples` argument of the -`@interpolate` decorator, but that will obviously decrease the painting speed. - -Does this plot agree with what you would expect a LOS integrated top hat -profile (a.k.a. a solid sphere) to look like? - -Painting Optical Depth and kSZ Profiles on the WebSky Catalog -------------------------------------------------------------- -Let's use the `Battaglia16` gas profiles to paint tau (optical depth) and -kinetic Sunyaev-Zeldovich (kSZ) on the WebSky catalog halos. - -.. code-block:: python - - from astropaint.profiles import Battaglia16 - - tau_painter = Painter(Battaglia16.tau_2D_interp) - - -Since the shape of the profile is smooth, we won't lose accuracy by using the interpolator. - -.. image:: docs/images/battaglia16_tau.png - :target: docs/images/battaglia16_tau.png - :height: 200 - :align: center - - -Let's paint this on a 5x5 sqr deg patch of the WebSky catalog with a mass -cut of 8E13 M_sun. - -.. code-block:: python - - catalog = Catalog("websky_lite_redshift") - catalog.cut_lon_lat(lon_range=[5,10], lat_range=[5,10]) - catalog.cut_M_200c(8E13) - - canvas = Canvas(catalog, nside=8192, R_times=3) - - tau_painter.spray(canvas) - - -.. image:: docs/images/tau_map_battaglia.png - :target: docs/images/tau_map_battaglia.png - :height: 200 - :align: center - -The `Battaglia16.kSZ_T` function uses this tau and multiplies it by the -dimensionless velocity of the halos to get the kSZ signal. - -.. code-block:: python - - kSZ_painter = Painter(Battaglia16.kSZ_T) - kSZ_painter.spray(canvas) - -And here is what it looks like: - -.. image:: docs/images/ksz_map_battaglia.png - :target: docs/images/ksz_map_battaglia.png - :height: 200 - :align: center - - - -Art Gallery -=========== - -Just because AstroPaint is developed for probing new science and doing -serious stuff, it doesn't mean you can't have fun with it! Check out our -`cool web app `_ to get your -hands dirty with some paint. - -**Made with AstroPaint** - -:raw-html-m2r:`` :raw-html-m2r:`` :raw-html-m2r:`` - -How to contribute -================= - -If you would like to contribute to AstroPaint, take the following steps: - -1) Fork this repository -2) Clone it on your local machine -3) Create a new branch (be as explicit as possible with the branch name) -4) Add and Commit your changes to the local branch -5) Push the branch to your forked repository -6) Submit a pull request on this repository - -See `this repository `_ or `Kevin Markham's step-by-step guide `_ for more detailed instructions. - -Developement happens on the ``develop`` branch, so make sure you are always in sync with the latest version and submit your pull requests to this branch. From 7ae872ef240fa2129e0fd5593bfc089658ff3bda Mon Sep 17 00:00:00 2001 From: Siavash Yasini Date: Wed, 16 Sep 2020 15:25:59 -0700 Subject: [PATCH 5/6] Update README.md and index.rst --- README.md | 2 +- docs/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c33a58e..61c8951 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ profile of the astrophysical effect. The package also provides a suite of tools # Package Structure -While there is no external documentation for the code yet, you can use [this +See our [documentation](https://astropaint.readthedocs.io/) and [this chart](https://www.mindmeister.com/1417665103/astropaint-astropaint-py?fullscreen=1) to understand the package structure and see what methods are available so far. diff --git a/docs/index.rst b/docs/index.rst index 7816d86..fd2236e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -81,7 +81,7 @@ application extends to halos of arbitrary size or even point sources. Package Structure ================= -While there is no external documentation for the code yet, you can use `this chart `_ +See our `documentation `_ and `this chart `_ to understand the package structure and see what methods are available so far. Examples From daa7357864bd9c742c827db08e7ab3ccab465533 Mon Sep 17 00:00:00 2001 From: Siavash Yasini Date: Wed, 16 Sep 2020 15:34:26 -0700 Subject: [PATCH 6/6] Update README.md Add readthedocs badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 61c8951..c89349e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ _A python package for painting the sky_ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/syasini/AstroPaint/master?filepath=tutorial.ipynb) +[![Documentation Status](https://readthedocs.org/projects/astropaint/badge/?version=master)](https://astropaint.readthedocs.io/en/master/?badge=master) + You can install **AstroPaint** by running the following in the command line: