diff --git a/.gitignore b/.gitignore index eead9f1..38acfbb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ *.png *.so *.pyx.py -build lightrayrider.egg-info old lightrayrider/parallel.c diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo new file mode 100644 index 0000000..16f2fbc --- /dev/null +++ b/docs/build/html/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 95087ab1a56d501089f781962fb52a81 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/html/_modules/index.html b/docs/build/html/_modules/index.html new file mode 100644 index 0000000..63ee707 --- /dev/null +++ b/docs/build/html/_modules/index.html @@ -0,0 +1,111 @@ + + +
+ + +' + + '' + + _("Hide Search Matches") + + "
" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); diff --git a/docs/build/html/contributing.html b/docs/build/html/contributing.html new file mode 100644 index 0000000..1e3d336 --- /dev/null +++ b/docs/build/html/contributing.html @@ -0,0 +1,248 @@ + + + + + + +Contributions are welcome, and they are greatly appreciated! Every little bit +helps, and credit will always be given.
+You can contribute in many ways:
+Report bugs at https://github.com/JohannesBuchner/snowline/issues.
+If you are reporting a bug, please include:
+Your operating system name and version.
Any details about your local setup that might be helpful in troubleshooting.
Detailed steps to reproduce the bug.
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help +wanted” is open to whoever wants to implement it.
+Look through the GitHub issues for features. Anything tagged with “enhancement” +and “help wanted” is open to whoever wants to implement it.
+snowline could always use more documentation, whether as part of the +official snowline docs, in docstrings, or even on the web in blog posts, +articles, and such.
+The best way to send feedback is to file an issue at https://github.com/JohannesBuchner/snowline/issues.
+If you are proposing a feature:
+Explain in detail how it would work.
Keep the scope as narrow as possible, to make it easier to implement.
Remember that this is a volunteer-driven project, and that contributions +are welcome :)
Ready to contribute? Here’s how to set up snowline for local development.
+Fork the snowline repo on GitHub.
Clone your fork locally:
+$ git clone git@github.com:JohannesBuchner/snowline.git
+
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
+$ mkvirtualenv snowline
+$ cd snowline/
+$ python setup.py develop
+
Create a branch for local development:
+$ git checkout -b name-of-your-bugfix-or-feature
+
Now you can make your changes locally.
+When you’re done making changes, check that your changes pass flake8 and the +tests, including testing other Python versions with tox:
+$ flake8 snowline tests
+$ python setup.py test # or pytest
+$ tox
+
To get flake8 and tox, just pip install them into your virtualenv.
+Commit your changes and push your branch to GitHub:
+$ git add .
+$ git commit -m "Your detailed description of your changes."
+$ git push origin name-of-your-bugfix-or-feature
+
Submit a pull request through the GitHub website.
Before you submit a pull request, check that it meets these guidelines:
+The pull request should include tests.
If the pull request adds functionality, the docs should be updated. Put +your new functionality into a function with a docstring, and add the +feature to the list in README.rst.
The pull request should work for Python 2.7, 3.5, 3.6 and 3.7, and for PyPy. Check +https://travis-ci.org/JohannesBuchner/snowline/pull_requests +and make sure that the tests pass for all supported Python versions.
To run a subset of tests:
+$ pytest tests.test_snowline
+
A reminder for the maintainers on how to deploy. +Make sure all your changes are committed (including an entry in HISTORY.rst). +Then run:
+$ bump2version patch # possible: major / minor / patch
+$ git push
+$ git push --tags
+
Travis will then deploy to PyPI if tests pass.
++ |
|
+
|
+
A fast library for calculating intersections of a line with many spheres or inhomogeneous material.
+Technically speaking, the library performs three-dimensional line integrals +through various geometric bodies, such as millions of spheres of various sizes, +three-dimensional uniform grids, and arbitrary density fields approximated by their +point densities and voronoi tesselation.
+In astrophysics, a point source can be obscured by a gas distribution along the line-of-sight. +For hydrodynamic simulations which produce such a gas distribution, this code can compute +the total density along a arbitrary ray. The output is a column density, +also known as N_H if hydrogen gas is irradiated.
+ + +Input:
+Points in space representing sphere centres.
Sphere radii and densities.
One or more arbitrary lines from the origin.
Output:
+This computes the total length / column density cut.
From distance 0 or another chosen minimal distance (or multiple).
Method:
+Simple quadratic equations.
Input:
+Points in space.
Densities.
One or more arbitrary lines from the origin
Output:
+This computes the total length along the line, +where every point on the line is assigned the density from the +nearest point (Voronoi segmentation).
From distance 0 or another chosen minimal distance (or multiple).
Method:
+Segmentation of the line where points become equi-distant. +Performs approximately linearly with number of points.
Input:
+3D Grid with densities at each location
One or more arbitrary lines from a point
Output:
+This computes the total length along the line, +where every point on the line is assigned the density from the +grid cell it passes through.
From distance 0 or another chosen minimal distance (or multiple).
Method:
+Finding intersections of the cell borders (planes) with the lines, and +checking which cell to consider next.
Compile the c library first with:
+$ make
+
To use from Python, use raytrace.py:
+from raytrace import *
+
You can find the declaration of how to call these functions in raytrace.py. +Basically, you pass the coordinates of your gas particles, the associated +densities and the starting point and direction of your raytracing.
+Example usage is demonstrated in irradiate.py. This was used for Illustris and +EAGLE particle in the associated paper. +There are additional unit test examples in test/.
+LightRayRider supports multiple processors through OpenMP. +Set the variable OMP_NUM_THREADS to the number of processors you want to use, +and the parallel library ray-parallel.so will be loaded.
+If you use this code, please cite “Galaxy gas as obscurer: II. Separating the galaxy-scale and +nuclear obscurers of Active Galactic Nuclei”, by Buchner & Bauer (2017), https://arxiv.org/abs/1610.09380
+Bibcode:
+@ARTICLE{2017MNRAS.465.4348B,
+ author = {{Buchner}, J. and {Bauer}, F.~E.},
+ title = "{Galaxy gas as obscurer - II. Separating the galaxy-scale and nuclear obscurers of active galactic nuclei}",
+ journal = {\mnras},
+archivePrefix = "arXiv",
+ eprint = {1610.09380},
+ primaryClass = "astro-ph.HE",
+ keywords = {dust, extinction, ISM: general, galaxies: active, galaxies: general, galaxies: ISM, X-rays: ISM},
+ year = 2017,
+ month = mar,
+ volume = 465,
+ pages = {4348-4362},
+ doi = {10.1093/mnras/stw2955},
+ adsurl = {http://adsabs.harvard.edu/abs/2017MNRAS.465.4348B},
+ adsnote = {Provided by the SAO/NASA Astrophysics Data System}
+}
+
The code is licensed under AGPLv3 (see LICENSE file).
+To install lightrayrider, run this command in your terminal:
+$ python -m pip install lightrayrider
+
This is the preferred method to install lightrayrider, as it will always install the most recent stable release.
+If you don’t have pip installed, this Python installation guide can guide +you through the process.
+The sources for lightrayrider can be downloaded from the Github repo.
+You can either clone the public repository:
+$ git clone git://github.com/JohannesBuchner/lightrayrider
+
Or download the tarball:
+$ curl -OJL https://github.com/JohannesBuchner/lightrayrider/tarball/master
+
Once you have a copy of the source, you can install it with:
+$ python setup.py install
+
See Contributing for how to report bugs and ask questions. (hint: open a github issue)
+Please cite Buchner & Bauer (2017), http://adsabs.harvard.edu/abs/2017MNRAS.465.4348B
+They describe the underlying techniques.
+This file is part of LightRayRider, a fast column density computation tool.
+Perform ray tracing through a sphere/cone cuts.
+Sphere radius is 1, each cone angle defines a region of a certain density.
+This function raytraces from the starting coordinates in the direction +given and compute the column density of the intersecting segments. +Then it will go along the ray in the positive direction until the +column density d is reached. The coordinates of that point are stored into +(x, y, z).
+cones (regarding the)
+the opening angles of the cones
+density of the cones. For conversion from length to column density.
+ray start coordinate, x component
+ray start coordinate, y component
+ray start coordinate, z component
+ray direction, x component
+ray direction, y component
+ray direction, z component
+column density where the ray should terminate.
+t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Ray tracing on a grid.
+rho (array) – 3D cube of densities (in units of 1e22/cm^2). For conversion from length to column density. +Must be same size in each axis.
lenrho (int) – length of rho.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHout – column density from the origin to infinity. shape is len(a).
+array
+Ray tracing on a grid.
+rho (array) – 3D cube of densities (in units of 1e22/cm^2). For conversion from length to column density. +Must be same size in each axis.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHmax (array) – column density where the ray should terminate.
t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Ray tracing on a grid.
+rho_flat (array) – flattened 3D cube of densities. For conversion from length to column density.
lenrho (int) – length of each 3D cube axis
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHmax (array) – column density where the ray should terminate.
t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Ray tracing on a grid.
+rho_flat (array) – flattened 3D cube of densities. For conversion from length to column density.
lenrho (int) – length of the original rho cube in each axis.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHout – column density from the origin to infinity. shape is len(a).
+array
+Perform ray tracing using sphere intersections.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
rho (array) – sphere densities (in units of 1e22/cm^2). For conversion from length to column density.
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
mindistances (array) – distance from the origin for each subtotal to consider.
NHout – column density from the origin to infinity. shape is (len(mindistances), len(a)).
+array
+Count number of spheres lying (partially or completely) between point a,b,c and origin.
+Stops counting at 1.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
n – number of spheres
+int
+Perform ray tracing using sphere intersections.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
rho (array) – sphere densities (in units of 1e22/cm^2). For conversion from length to column density.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHmax (array) – column density where the ray should terminate.
t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Marks the first kstop non-intersecting spheres.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
k (int) – number of spheres desired
NHout (array) – 1 if collides with another sphere of lower index, +2 if okay.
Parameters regarding the spheres
Ray tracing using nearest point density.
+xx (array) – x coordinates
yy (array) – y coordinates
zz (array) – z coordinates
RR (array) – radii
rho (array) – sphere densities. For conversion from length to column density.
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
mindistances (array) – distance from the origin for each subtotal to consider.
NHout – column density from the origin to infinity. shape is (len(mindistances), len(a)).
+array
+This file is part of LightRayRider, a fast column density computation tool.
+Perform ray tracing through a sphere/cone cuts.
+Sphere radius is 1, each cone angle defines a region of a certain density.
+This function raytraces from the starting coordinates in the direction +given and compute the column density of the intersecting segments. +Then it will go along the ray in the positive direction until the +column density d is reached. The coordinates of that point are stored into +(x, y, z).
+cones (regarding the)
+the opening angles of the cones
+density of the cones. For conversion from length to column density.
+ray start coordinate, x component
+ray start coordinate, y component
+ray start coordinate, z component
+ray direction, x component
+ray direction, y component
+ray direction, z component
+column density where the ray should terminate.
+t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Ray tracing on a grid.
+rho (array) – 3D cube of densities (in units of 1e22/cm^2). For conversion from length to column density. +Must be same size in each axis.
lenrho (int) – length of rho.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHout – column density from the origin to infinity. shape is len(a).
+array
+Ray tracing on a grid.
+rho (array) – 3D cube of densities (in units of 1e22/cm^2). For conversion from length to column density. +Must be same size in each axis.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHmax (array) – column density where the ray should terminate.
t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Ray tracing on a grid.
+rho_flat (array) – flattened 3D cube of densities. For conversion from length to column density.
lenrho (int) – length of each 3D cube axis
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHmax (array) – column density where the ray should terminate.
t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Ray tracing on a grid.
+rho_flat (array) – flattened 3D cube of densities. For conversion from length to column density.
lenrho (int) – length of the original rho cube in each axis.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHout – column density from the origin to infinity. shape is len(a).
+array
+Perform ray tracing using sphere intersections.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
rho (array) – sphere densities (in units of 1e22/cm^2). For conversion from length to column density.
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
mindistances (array) – distance from the origin for each subtotal to consider.
NHout – column density from the origin to infinity. shape is (len(mindistances), len(a)).
+array
+Count number of spheres lying (partially or completely) between point a,b,c and origin.
+Stops counting at 1.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
n – number of spheres
+int
+Perform ray tracing using sphere intersections.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
rho (array) – sphere densities (in units of 1e22/cm^2). For conversion from length to column density.
x (array) – ray start coordinate, x component
y (array) – ray start coordinate, y component
z (array) – ray start coordinate, z component
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
NHmax (array) – column density where the ray should terminate.
t – end position in multiples of the direction vector. -1 if infinite. +Of shape len(x).
+array
+Marks the first kstop non-intersecting spheres.
+xx (array) – sphere x coordinates
yy (array) – sphere y coordinates
zz (array) – sphere z coordinates
RR (array) – sphere radii
k (int) – number of spheres desired
NHout (array) – 1 if collides with another sphere of lower index, +2 if okay.
Parameters regarding the spheres
Ray tracing using nearest point density.
+xx (array) – x coordinates
yy (array) – y coordinates
zz (array) – z coordinates
RR (array) – radii
rho (array) – sphere densities. For conversion from length to column density.
a (array) – ray direction, x component
b (array) – ray direction, y component
c (array) – ray direction, z component
mindistances (array) – distance from the origin for each subtotal to consider.
NHout – column density from the origin to infinity. shape is (len(mindistances), len(a)).
+array
+LightRayRider is a tiny fast library to compute column densities along a ray.
+Supported geometries:
+Uniform density grids.
Spheres of varying size, density and position.
Co-centred cones of varying opening angles and density.
+ l | ||
+ |
+ lightrayrider | + |
+ |
+ lightrayrider.parallel | + |
+ |
+ lightrayrider.raytrace | + |
A fast library for calculating intersections of a line with many spheres or inhomogeneous material.
+Technically speaking, the library performs three-dimensional line integrals +through various geometric bodies, such as millions of spheres of various sizes, +three-dimensional uniform grids, and arbitrary density fields approximated by their +point densities and voronoi tesselation.
+In astrophysics, a point source can be obscured by a gas distribution along the line-of-sight. +For hydrodynamic simulations which produce such a gas distribution, this code can compute +the total density along a arbitrary ray. The output is a column density, +also known as N_H if hydrogen gas is irradiated.
+ + +Input:
+Points in space representing sphere centres.
Sphere radii and densities.
One or more arbitrary lines from the origin.
Output:
+This computes the total length / column density cut.
From distance 0 or another chosen minimal distance (or multiple).
Method:
+Simple quadratic equations.
Input:
+Points in space.
Densities.
One or more arbitrary lines from the origin
Output:
+This computes the total length along the line, +where every point on the line is assigned the density from the +nearest point (Voronoi segmentation).
From distance 0 or another chosen minimal distance (or multiple).
Method:
+Segmentation of the line where points become equi-distant. +Performs approximately linearly with number of points.
Input:
+3D Grid with densities at each location
One or more arbitrary lines from a point
Output:
+This computes the total length along the line, +where every point on the line is assigned the density from the +grid cell it passes through.
From distance 0 or another chosen minimal distance (or multiple).
Method:
+Finding intersections of the cell borders (planes) with the lines, and +checking which cell to consider next.
Compile the c library first with:
+$ make
+
To use from Python, use raytrace.py:
+from raytrace import *
+
You can find the declaration of how to call these functions in raytrace.py. +Basically, you pass the coordinates of your gas particles, the associated +densities and the starting point and direction of your raytracing.
+Example usage is demonstrated in irradiate.py. This was used for Illustris and +EAGLE particle in the associated paper. +There are additional unit test examples in test/.
+LightRayRider supports multiple processors through OpenMP. +Set the variable OMP_NUM_THREADS to the number of processors you want to use, +and the parallel library ray-parallel.so will be loaded.
+If you use this code, please cite “Galaxy gas as obscurer: II. Separating the galaxy-scale and +nuclear obscurers of Active Galactic Nuclei”, by Buchner & Bauer (2017), https://arxiv.org/abs/1610.09380
+Bibcode:
+@ARTICLE{2017MNRAS.465.4348B,
+ author = {{Buchner}, J. and {Bauer}, F.~E.},
+ title = "{Galaxy gas as obscurer - II. Separating the galaxy-scale and nuclear obscurers of active galactic nuclei}",
+ journal = {\mnras},
+archivePrefix = "arXiv",
+ eprint = {1610.09380},
+ primaryClass = "astro-ph.HE",
+ keywords = {dust, extinction, ISM: general, galaxies: active, galaxies: general, galaxies: ISM, X-rays: ISM},
+ year = 2017,
+ month = mar,
+ volume = 465,
+ pages = {4348-4362},
+ doi = {10.1093/mnras/stw2955},
+ adsurl = {http://adsabs.harvard.edu/abs/2017MNRAS.465.4348B},
+ adsnote = {Provided by the SAO/NASA Astrophysics Data System}
+}
+
The code is licensed under AGPLv3 (see LICENSE file).
+