Closed bluescarni closed 9 years ago
@bluescarni - could the minimum number of samples made to be a parameter in voronoi_grid
? (defaulting to 10)
@bluescarni - could you create a new page in the docs in the advanced section that just describes how to use this? In particular it would be great if you can show a minimal example of how one would use this to find a density in each cell for example.
Using the output that you have at the moment, I think that the most efficient way would be something like (untested code):
def density(x, y, z):
# stuff here
return density_value
xyz = g.samples
idx = g.samples_idx
dens_all = density(xyz[0], xyz[1], xyz[2])
dens_average = np.add.reduceat(dens_all, idx[:-1]) / np.diff(idx)
Can you confirm that something like this works? If so, can you add an example like this to the docs?
@bluescarni - there was an issue with the Travis config which I just fixed in https://github.com/hyperion-rt/hyperion/pull/135 - can you rebase on the latest upstream master? (should be easy since no conflicts). Let me know if you need any instructions.
@astrofrog Thanks for the review, I am adding the configurable option for min samples and writing the docs. I will rebase before pushing the new iteration.
@bluescarni - apart from my comment above, this is good to go! Could you implement the small change I suggested today?
@astrofrog thanks for the review! I just committed the changes you suggested.
@bluescarni - thanks! I will go ahead and merge this. I think it would be nice to be able to access this functionality from the top-level VoronoiGrid
class (the one users are normally exposed to) but that should be easy to add later. Let me know later if you have any ideas on how we could do this.
Actually I might open a quick PR now to add an interface in the top-level class to make it easier for Christine to use.
@astrofrog Thanks! Sounds good for the top level class interface, even though I have not much experience with it. I would imagine we can just expose the same interface as in the helper class and trickle down the construction parameters to voronoi_grid
?
@bluescarni - yes, I'll open a PR shortly and will let you know so you can review it.
@bluescarni - see https://github.com/hyperion-rt/hyperion/pull/138
This is the initial implementation of the sampling code. Example usage:
This will sample at least 1000000 points in the domain. The number of samples for each Voronoi cell is at least 10 and otherwise proportional to the cell volume.
When constructed with a nonzero
n_samples
parameter thevoronoi_grid
object will expose two properties:samples
andsamples_idx
. The first one is the list of coordinates of the sampling points, the second one the indices (in sparse format) of the sampling points for each cell.Example:
This means that, for the first cell, the sampling points are from index 0 to 10 in the first array, for the second cell from index 10 to 20, etc.