LSSTDESC / clevar

GNU General Public License v3.0
7 stars 2 forks source link

add members for member matching not working #164

Open eduardojsbarroso opened 3 weeks ago

eduardojsbarroso commented 3 weeks ago

In the new version of clevar, 16, the functions add_members and read_members are moving all the members to leftover_members even though the ids in members['id_cluster'] are in the cluster catalog. If we move back to clevar 0.15.1, everything works.

m-aguena commented 3 weeks ago

@eduardojsbarroso can you provide an example of this error? I could not reproduce it

eduardojsbarroso commented 3 weeks ago

Here is basically what I have in the catalog I am trying to use:

import clevar
import numpy as np
from astropy.table import Table
from clevar.catalog import ClCatalog, MemCatalog
import matplotlib.pyplot as plt
from clevar.match import MembershipMatch

t1_cl = Table()
t1_m = Table()

t1_cl['halo_id'] = [1,2,3]
t1_cl['halo_mass'] = [10,11,12]

t1_m['galaxy_id'] = [22,23,24,25]
t1_m['halo_id'] = [1,1,2,3]

cl_tags = {'id':'halo_id', 'mass':'halo_mass'}
m_tags = {'id':'galaxy_id', 'id_cluster':'halo_id'}

t1_cl.write('cluster_catalog.fits', format='fits', overwrite=True)
t1_m.write('member_catalog.fits', format='fits', overwrite=True)

cat1 = ClCatalog.read('cluster_catalog.fits', tags=cl_tags, name='cat1')
cat1.read_members('member_catalog.fits', tags=m_tags)
print(cat1.members)

When running this file, the output is:

/pbs/home/e/ebarroso/mambaforge-pypy3/envs/wazp/lib/python3.11/site-packages/clevar-0.16.0-py3.11.egg/clevar/catalog/catalog.py:744: UserWarning: Some galaxies were not members of the cluster catalog. They are stored in leftover_members attribute.
  warnings.warn(
members:
galaxy_id halo_id ind_cl
m-aguena commented 3 weeks ago

@eduardojsbarroso, thanks for reporting this. The problem was happening when the ids were int instead of str. This will be fixed in PR #165