nbodykit icon indicating copy to clipboard operation
nbodykit copied to clipboard

FiberCollisions

Open Moctobers opened this issue 6 years ago • 6 comments

Hi,

I notice that the FiberCollisions report an error when the catalog includes ra/dec = 180.0.

"~/.conda/envs/nbodykit-env3/lib/python3.7/site-packages/nbodykit/algorithms/fof.py in run(self)
     91         """
     92         # run the FOF
---> 93         minid = fof(self._source, self._linking_length, self.comm, self.attrs['periodic'], self.attrs['domain_factor'], self.logger)
     94 
     95         # the sorted labels

~/.conda/envs/nbodykit-env3/lib/python3.7/site-packages/nbodykit/algorithms/fof.py in fof(source, linking_length, comm, periodic, domain_factor, logger)
    381 
    382     # balance the load
--> 383     domain.loadbalance(domain.load(Position))
    384 
    385     layout = domain.decompose(Position, smoothing=linking_length * 1)

~/.conda/envs/nbodykit-env3/lib/python3.7/site-packages/pmesh/domain.py in load(self, pos, transform, gamma)
    408                               # the edge is very far off!
    409 
--> 410             particle_domain = numpy.ravel_multi_index(sil, self.shape, mode=mode)
    411             tmp = numpy.bincount(particle_domain, minlength=self.size)
    412         else:

ValueError: invalid entry in coordinates array"

Moctobers avatar May 18 '19 16:05 Moctobers

Was it RA or DEC of 180? DEC of 180 is undefined; it goes from -90 to 90.

Could you do log histograms of your input RA and DEC and see if anything looks strange?

RA you can always run it though RA = RA % 360.

rainwoodman avatar May 18 '19 16:05 rainwoodman

Hi,

it was RA. As I artificially modify the value from 180 to 180.001, it works fine.

Moctobers avatar May 19 '19 12:05 Moctobers

what is the associated DEC of the point with RA=180?

rainwoodman avatar May 19 '19 23:05 rainwoodman

RA = 180.0, DEC = 57.379803

Moctobers avatar May 20 '19 07:05 Moctobers

Hi,

As we are there, I noticed some time ago that:

ra = numpy.array([0.,1.,2.]) dec = numpy.array([0.,0.,0.]) labels = FiberCollisions(ra,dec,collision_radius=1.5,seed=None).labels print labels['Collided'].compute()

prints [0 0 0], while one would expect [0 1 0] from the Guo et al. algorithm, just as:

ra = numpy.array([0.,1.,2.,10.]) dec = numpy.array([0.,0.,0.,0.]) labels = FiberCollisions(ra,dec,collision_radius=1.5,seed=None).labels print labels['Collided'].compute()

correctly prints [0 1 0 0].

I also noticed numerical issues while running FiberCollisions on a set of mocks; these disappear by sightly increasing the BoxSize (l. 59 of fibercollisions.py): source = ArrayCatalog(pos, BoxSize=numpy.array([2., 2., 2.])+1e-9, comm=comm) # margin of 1e-9, otherwise may fail due to numerical errors

Also, if you are interested, I can suggest a slight (personal -- not published) modification to account for priority targets. I I added a "priority" argument to FiberCollisions:

  • when the multiplicity of a collision group is 2, the target with lowest priority is declared as collided (if there is, else one of them is picked randomly)
  • when the multiplicity > 2, the selection order to declare a target as collided is:
    • lowest priority
    • collisions with the highest number of other targets
    • collisions with targets that have the lowest number of collisions with other targets
    • random

Cheers

adematti avatar May 20 '19 14:05 adematti

Thanks for looking into this and sharing the tips. @moctobers @adematti

PR #587 and PR #586 may address the issues described here.

rainwoodman avatar May 22 '19 04:05 rainwoodman