-
Notifications
You must be signed in to change notification settings - Fork 25
Fast emitters and integrators for regular grids #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vsnever
wants to merge
26
commits into
raysect:development
Choose a base branch
from
vsnever:feature/regular_grid_emitters
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fast emitters and integrators for regular grids #343
vsnever
wants to merge
26
commits into
raysect:development
from
vsnever:feature/regular_grid_emitters
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I updated the documentation for the API and demonstrations. Regarding the |
Release v0.8.0
Cython 3.0 release introduces breaking changes. Pin to earlier Cython until the code has been updated for compatibility. Make a new post1 release of this so downstream packages will pick up the working version of 0.8.1.
When installing with pip or PyPA's `build` utility, , the `-j` option for parallel builds is not passed by default. This increases the build time on systems where wheels need to be built, e.g. for releases or on systems where no pre-built wheel is available. This commit introduces a modified `build_ext` command which by default parallelises over all available CPUs, with an optional override using the `RAYSECT_BUILD_JOBS` environment variable if for any reason the number of build processes needs to be controlled manually.
Wheels for Python 3.7 to 3.9 can be built using manylinux2010, as there are binary wheels of oldest-supported-numpy available for these versions. For 3.10 onwards manylinux2014 is required for numpy binary wheels. Building numpy from source in the manylinux containers is not viable. There are now two scripts, one for each manylinux version, which will build wheels for all upstream-supported Python versions. These can be run as-is: info is in the first few lines of these files. Also, the dev notes on building wheels wtih manylinux have been updated to reference these files.
V0.8.1 buildfix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft pull request for fast emitters and integrators that work with regular grids, It was originally proposed for Cherab (issue #204) but, as @CnlPepper suggested, these emitters and integrators are more suitable for Raysect.
I tried to address all the issues raised in the discussion.
The emitters work as follows:
continuous
argument, which isTrue
by default.RegularGridEmitter
stores the emission as a compressed sparse column-major matrix (scipy.sparse.csc_matrix) for fast column access required for resampling.SpectralFunction
, theRegularGridEmitter
automatically rebuilds the cache when the existing cache is not match the ray spectral properties. The cache validity is checked each time theemission_function()
orRegularGridIntegrator.integrate()
is called. The cache is stored as a compressed sparse row-major matrix (scipy.sparse.csr_matrix) for fast row access required for volume integration. Ifcontinuous=True
, the resampling is performed the same way as inInterpoatedSF
, but with optional extrapolation. Ifcontinuous=False
, the spectrum is not interpolated, instead the emission at each spectral bin sums the emissions at all spectral lines that fall into that bin, divided by the bin's width. Thus, the cache always contain the emission in W / (m^3 str nm).RegularGridEmitter
is designed to work with very large grids, it has a few memory-saving options.cache_build(min_wavelength, max_wavelength, bins)
function beforecamera.observe()
is called. All processes will use this cache as long as it remains valid (of course building the cache in advance is useless in dispersive rendering).cache_override(new_cache, min_wavelength, max_wavelength)
, so if there is not enough memory to store both the original emission and the cache, the user can provide the cache only by initialising the emitter with an empty csc_matrix and then callingcache_override()
. Again, this will not work in case of dispersive rendering.Currently, building the cache is slow, and it's noticeable for large grids. I'll try to optimise it in the future.
This draft pull request contains 4 demos. The first one is a kind of tutorial.
The code has built-in documentation but I didn't update the .rst files yet. Please look through the code, and if it's OK in general, I'll update the documentation and make this PR ready for review.
Also, I have a question to @CnlPepper. The
SpectralFunction
has custom__getstate__()
,__setstate__()
,__reduce__()
methods. Do I need them inRegularGridEmitter
too?