manoharan-lab / holopy

Hologram processing and light scattering in python
GNU General Public License v3.0
131 stars 50 forks source link

Problem running "Simple Example Scattering Calculations" ValueError: conflicting MultiIndex level #415

Closed 1-NoLimits closed 7 months ago

1-NoLimits commented 1 year ago

I went through the tutorial and all went well, but the scattering example here:

https://holopy.readthedocs.io/en/master/tutorial/calc_tutorial.html

gives an error:

Output exceeds the size limit. Open the full output data in a text editor

ValueError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_12308/437939144.py in 9 detector = hp.detector_grid(shape=100, spacing=0.1) 10 ---> 11 holo = calc_holo(detector, sphere, medium_index, illum_wavelen, 12 illum_polarization, theory='auto') 13 hp.show(holo)

c:\Users\XXXXX\anaconda3\lib\site-packages\holopy\scattering\interface.py in calc_holo(detector, scatterer, medium_index, illum_wavelen, illum_polarization, theory, scaling) 203 theory = interpret_theory(scatterer, theory) 204 imageformer = ImageFormation(theory) --> 205 scattered_field = imageformer.calculate_scattered_field(scatterer, uschema) 206 reference_field = uschema.illum_polarization 207 holo = scattered_field_to_hologram(

c:\Users\XXXXX\anaconda3\lib\site-packages\holopy\scattering\imageformation.py in calculate_scattered_field(self, scatterer, schema) 36 self._calculate_multiple_color_scattered_field(scatterer, schema) 37 if is_multicolor_hologram else ---> 38 self._calculate_single_color_scattered_field(scatterer, schema)) 39 return field 40

c:\Users\XXXXX\anaconda3\lib\site-packages\holopy\scattering\imageformation.py in _calculate_single_color_scattered_field(self, scatterer, schema) 103 else: ...

ValueError: conflicting MultiIndex level / variable name(s): x y z

Any clue what it could be?

ViolaClem commented 1 year ago

I also had problems. For me, it was due to the version of Python and the packages. At the beginning I tried with Python 3.9 - but it never worked. Now I use version 3.6.13. With that it worked. I also use the following versions now (look at xarray in particular): I hope it works!

Name Version Build Channel

astropy 4.1 py36h6434af4_2 conda-forge ca-certificates 2022.12.7 h5b45459_0 conda-forge cached-property 1.5.2 hd8ed1ab_1 conda-forge cached_property 1.5.2 pyha770c72_1 conda-forge certifi 2021.5.30 py36ha15d459_0 conda-forge cloudpickle 2.0.0 pyhd3eb1b0_0 colorama 0.4.5 pyhd8ed1ab_0 conda-forge cycler 0.11.0 pyhd3eb1b0_0 cytoolz 0.11.0 py36he774522_0 dask-core 2021.3.0 pyhd3eb1b0_0 decorator 5.1.1 pyhd3eb1b0_0 emcee 3.0.2 pyh5ca1d4c_0 conda-forge freetype 2.12.1 h546665d_0 conda-forge geos 3.9.1 h39d44d4_2 conda-forge h5netcdf 1.1.0 pyhd8ed1ab_0 conda-forge h5py 3.1.0 nompi_py36hf359dfe_100 conda-forge hdf5 1.10.6 nompi_he0bbb20_101 conda-forge holopy 3.5.0 py36h68aa20f_0 conda-forge icu 58.2 ha925a31_3 imageio 2.9.0 pyhd3eb1b0_0 intel-openmp 2022.2.1 h57928b3_19741 conda-forge jpeg 9e h8ffe710_2 conda-forge kiwisolver 1.3.1 py36hd77b12b_0 lcms2 2.12 h2a16943_0 conda-forge lerc 3.0 h0e60522_0 conda-forge libblas 3.9.0 16_win64_mkl conda-forge libcblas 3.9.0 16_win64_mkl conda-forge libdeflate 1.10 h8ffe710_0 conda-forge liblapack 3.9.0 16_win64_mkl conda-forge liblapacke 3.9.0 16_win64_mkl conda-forge libpng 1.6.37 h1d00b33_4 conda-forge libtiff 4.3.0 hc4061b1_4 conda-forge libwebp 1.0.2 hfa6e2cd_5 conda-forge libzlib 1.2.12 h8ffe710_2 conda-forge lz4-c 1.9.3 h8ffe710_1 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge matplotlib 3.3.4 py36haa95532_0 matplotlib-base 3.3.4 py36h49ac443_0 mkl 2022.1.0 h6a75c08_874 conda-forge msys2-conda-epoch 20160418 1 conda-forge networkx 2.5 py_0 numpy 1.19.5 py36h4b40d73_2 conda-forge olefile 0.46 pyh9f0ad1d_1 conda-forge opencv 4.1.1 py36h6afde12_1 conda-forge openjpeg 2.5.0 hb211442_0 conda-forge openssl 1.1.1q h8ffe710_0 conda-forge packaging 21.3 pyhd8ed1ab_0 conda-forge pandas 1.1.5 py36he38d939_0 conda-forge pillow 8.3.2 py36h10c25d6_0 conda-forge pip 21.2.2 py36haa95532_0 pymiescatt 1.7.5.4 py_1 conda-forge pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge pyqt 5.9.2 py36h6538335_2 pyreadline 2.1 py36ha15d459_1004 conda-forge python 3.6.13 h3758d61_0 python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python_abi 3.6 2_cp36m conda-forge pytz 2022.6 pyhd8ed1ab_0 conda-forge pywavelets 1.1.1 py36he774522_2 pyyaml 5.4.1 py36h68aa20f_1 conda-forge qt 5.9.7 vc14h73c81de_0 schwimmbad 0.3.2 py36ha15d459_0 conda-forge scikit-image 0.17.2 py36h1e1f486_0 scipy 1.5.3 py36h27d303f_1 conda-forge setuptools 58.0.4 py36haa95532_0 shapely 1.7.1 py36ha9f6fdf_5 conda-forge sip 4.19.8 py36h6538335_0 six 1.16.0 pyh6c4a22f_0 conda-forge sqlite 3.40.0 h2bbff1b_0 tbb 2021.5.0 h2d74725_1 conda-forge tifffile 2020.10.1 py36h8c2d366_2 tk 8.6.12 h8ffe710_0 conda-forge toolz 0.11.2 pyhd3eb1b0_0 tornado 6.1 py36h2bbff1b_0 tqdm 4.64.1 pyhd8ed1ab_0 conda-forge vc 14.2 h21ff451_1 vs2015_runtime 14.27.29016 h5e58377_2 wheel 0.37.1 pyhd3eb1b0_0 wincertstore 0.2 py36h7fe50ca_0 xarray 0.18.2 pyhd8ed1ab_0 conda-forge xz 5.2.6 h8d14728_0 conda-forge yaml 0.2.5 h8ffe710_2 conda-forge zlib 1.2.12 h8ffe710_2 conda-forge zstd 1.5.2 h6255e5f_4 conda-forge

VitanPy commented 1 year ago

Exact same issue here. It comes up when I'm trying to fit holograms with hp.fit(). How do I fix this?

Everything was working a couple of days ago.

VitanPy commented 1 year ago

Managed to fix it by just updating xarray to the version you had written down. The python version didn't matter for me.

Thanks