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

ValueError when trying to make an empirical model basis using basis_utils.makebasis #20

Open
Markiribu opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Markiribu
Copy link
Contributor

When using positions and masses of particles and trying to make an empirical model, during the computing of the model and exception is thrown:

    # >>>pos.shape
    # (10626687, 3)
    # >>>mass.shape
    # (10626687,)
    # >>>pos[0:5],mass[0:5]
    # (array([[-0.11921653, -0.09900432,  0.0413737 ],
    #        [-0.06802396,  0.04788647,  0.35164757],
    #        [ 0.08446022,  0.23606988,  0.25285447],
    #        [-0.24171911, -0.16270979,  0.01886733],
    #        [ 0.19743108,  0.20786581,  0.5299721 ]]),
    # array([457632.12282256, 457632.12282256, 457632.12282256, 457632.12282256,
    #        457632.12282256]))
    basis, coefs = EXPtools.basis_builder.basis_utils.makebasis(pos,mass,'empirical',
            lmax=6,nmax=20,
            modelname='empirical_model.txt',cachename='empirical_halo.cache',coef_file='empirical_halo.h5',
            nbins=500, rmin=1.5, rmax=300)

This throws the following exception:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[/tmp/ipykernel_2729/3970811905.py](http://127.0.0.1:8888/tmp/ipykernel_2729/3970811905.py) in <module>
      1 # makebasis por defecto normaliza por la masa total al crear los coeficientes
----> 2 basis, coefs = EXPtools.basis_builder.basis_utils.makebasis(pos,mass,'empirical',lmax=6,nmax=20,
      3                                              modelname='empirical_model.txt',cachename='empirical_halo.cache',coef_file='empirical_halo.h5',
      4                                              nbins=500, rmin=1.5, rmax=300
      5                                             )

[~/.local/lib/python3.10/site-packages/EXPtools/basis_builder/basis_utils.py](http://127.0.0.1:8888/home/marcoritou/.local/lib/python3.10/site-packages/EXPtools/basis_builder/basis_utils.py) in makebasis(pos, mass, basis_model, config, basis_id, time, r_s, r_c, nbins, rmin, rmax, log_space, lmax, nmax, scale, norm_mass_coef, modelname, cachename, add_coef, coef_file)
     94             #rho = empirical_density_profile(pos, mass, rbins)
     95 
---> 96             R, D, M, P = makemodel.makemodel(makemodel.empirical_density_profile, M=np.sum(mass),
     97                                    funcargs=[pos, mass], rvals=rbins)
     98 

[~/.local/lib/python3.10/site-packages/EXPtools/basis_builder/makemodel.py](http://127.0.0.1:8888/home/marcoritou/.local/lib/python3.10/site-packages/EXPtools/basis_builder/makemodel.py) in makemodel(func, M, funcargs, rvals, pfile, plabel, verbose)
    163 
    164     # evaluate potential (see theory document)
--> 165     pvals = -mvals[/](http://127.0.0.1:8888/)(rvals+1.e-10) - (pwvals[dvals.size-1] - pwvals)
    166 
    167     # get the maximum mass and maximum radius

ValueError: operands could not be broadcast together with shapes (500,) (501,)
@jngaravitoc jngaravitoc self-assigned this Apr 24, 2024
@jngaravitoc jngaravitoc added the bug Something isn't working label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants