galsci / pysm

PySM 3: Sky emission simulations for Cosmic Microwave Background experiments
https://pysm3.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
35 stars 23 forks source link

Error while returning a CAR map #178

Closed Ankurdev-astro closed 2 months ago

Ankurdev-astro commented 5 months ago

I am describing here an issue that I ran into while trying to return a CAR map using pysm3.apply_smoothing_and_coord_transform

I find specifically the error originates when template.py tries to import pixell.sharp here: https://github.com/galsci/pysm/blob/b15425310e8c3ffae4a94b08ea8c8aa7c61b8a09/pysm3/models/template.py#L19-L24

Full traceback error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 sim_map_rot = pysm3.apply_smoothing_and_coord_transform(sim_map, rot=hp.Rotator(coord="GC"),
      2                                                         output_car_resol =  0.25 * u.arcmin,
      3                                                        return_healpix= False,
      4                                                        return_car=True)

File /venvs/toast-venv/lib/python3.10/site-packages/pysm3/models/template.py:261, in apply_smoothing_and_coord_transform(input_map, fwhm, rot, lmax, output_nside, output_car_resol, return_healpix, return_car, input_alm, map2alm_lsq_maxiter, map_dist)
    259 if return_car:
    260     log.info("Alm to map CAR")
--> 261     shape, wcs = pixell.enmap.fullsky_geometry(
    262         output_car_resol.to_value(u.radian),
    263         dims=(3,),
    264         variant="fejer1",
    265     )
    266     ainfo = pixell.sharp.alm_info(lmax=lmax)
    267     output_maps.append(
    268         u.Quantity(
    269             pixell.curvedsky.alm2map(
   (...)
    274         )
    275     )

AttributeError: 'NoneType' object has no attribute 'enmap'

This happens because import pixell.sharp fails and pixell = None is assigned. I do not find pixell.sharp here: https://github.com/simonsobs/pixell/tree/master/pixell

I would like to get a pysm3 map in CAR format, and would greatly appreciate your suggestions in case I am going wrong in the steps. Thanks

Some additional package version info:


import pixell
print(f"pixell version : {pixell.__version__}")
print(f"pysm3 version : {pysm3.__version__}")

import pixell.sharp
pixell version : 0.23.8
pysm3 version : 3.4.0
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[5], line 5
      2 print(f"pixell version : {pixell.__version__}")
      3 print(f"pysm3 version : {pysm3.__version__}")
----> 5 import pixell.sharp

ModuleNotFoundError: No module named 'pixell.sharp'
zonca commented 5 months ago

I'll need to update to a newer pixell version, for now I recommend you downgrade:

https://github.com/galsci/pysm/blob/b15425310e8c3ffae4a94b08ea8c8aa7c61b8a09/setup.cfg#L34

Ankurdev-astro commented 5 months ago

Yes, I shall do that. Thanks.

zonca commented 4 months ago

It would be great if anyone from the community volunteered to work on a pull request to make PySM compatible with newer pixell versions.

msyriac commented 4 months ago

Should be addressed with #183