Skip to content
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

Memory issue when subsample catalogs #4

Open
echaussidon opened this issue Jan 30, 2023 · 0 comments
Open

Memory issue when subsample catalogs #4

echaussidon opened this issue Jan 30, 2023 · 0 comments

Comments

@echaussidon
Copy link
Contributor

echaussidon commented Jan 30, 2023

The following code should raise a memory issue:

import numpy as np
import mpytools as mpy
from mpi4py import MPI
mpicomm = MPI.COMM_WORLD

# read a catalog on several ranks
cat = mpy.Catalog.read('one_catalog.fits', columns=['X', 'Y'], mpicomm=mpicomm)
# select a sub part of the catalog
sel = np.random.rand(cat.size) <= 0.5
cat = cat[sel]

print(cat['Y'])  # --> create a memory error

A dirty fix is to ready before the selection all the column that you need after the subselection:

import numpy as np
import mpytools as mpy
from mpi4py import MPI
mpicomm = MPI.COMM_WORLD

# read a catalog on several ranks
cat = mpy.Catalog.read('one_catalog.fits', columns=['X', 'Y'], mpicomm=mpicomm)
_, _ = cat['X'], cat['Y']
# select a sub part of the catalog
sel = np.random.rand(cat.size) <= 0.5
cat = cat[sel]

print(cat['Y'])  # --> create a memory error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant