Giter Club home page Giter Club logo

Comments (21)

RebeccaWPerry avatar RebeccaWPerry commented on September 15, 2024

Thank you for reaching out--
since it is failing at the hp.show step, you could try using a different
image viewer until I or another developer have more time to look at it.
Something like this will show you the 0th image from the reconstructed
stack:

from matplotlib import pyplot

from numpyimport linspace
import holopyas hp
from holopy.coreimport Optics
from holopy.propagationimport propagate
from holopy.core.tests.commonimport get_example_data
from holopy.coreimport load

holo= get_example_data('image0001.yaml')
rec_vol= propagate(holo, linspace(4e-6,10e-6,7))

pyplot.imshow(abs(rec_vol[:,:,0]))
pyplot.show()

On 05/06/2015 12:38 PM, Brett M. Morris wrote:

I'm trying to reproduce the tutorial example on reconstruction
http://manoharan.seas.harvard.edu/holopy/users/recon_tutorial.html#recon-tutorial
and it is failing with the following error:

from numpyimport linspace
import holopyas hp
from holopy.coreimport Optics
from holopy.propagationimport propagate
from holopy.core.tests.commonimport get_example_data
from holopy.coreimport load

holo= get_example_data('image0001.yaml')
rec_vol= propagate(holo, linspace(4e-6,10e-6,7))
hp.show(rec_vol)

yields:

|---------------------------------------------------------------------------
FutureWarning Traceback (most recent call last)
in ()
8 holo = get_example_data('image0001.yaml')
9 rec_vol = propagate(holo, linspace(4e-6, 10e-6, 7))
---> 10 hp.show(rec_vol)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/show.pyc in show(o, color)
57 show_sphere_cluster(o,color)
58 elif isinstance(o, (Image, np.ndarray, list, tuple)):
---> 59 show2d(o)
60 elif isinstance(o, Scatterer):
61 show_scatterer(o)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in show2d(im, i, t, phase)
176 axis_names = ['x', 'z']
177
--> 178 im = squeeze(im)
179
180

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/core/marray.pyc in squeeze(arr)
678 """
679 keep = [i for i, dim in enumerate(arr.shape) if dim != 1]
--> 680 if not hasattr(arr,'spacing') or arr.spacing == None:
681 spacing = None
682 else:

FutureWarning: comparison to None will result in an elementwise object comparison in the future.
|

I'm using Python 2.7, Mac OS X 10.10.


Reply to this email directly or view it on GitHub
#27.

from holopy.

vnmanoharan avatar vnmanoharan commented on September 15, 2024

It looks like line 680 in holopy/core/marray.py which currently reads

if not hasattr(arr,'spacing') or arr.spacing == None:

should read:

if not hasattr(arr,'spacing') or arr.spacing is None:

Can you try making this change and letting us know if it fixes this bug?

from holopy.

bmorris3 avatar bmorris3 commented on September 15, 2024

After making that recommended change, the following error occurs:


---------------------------------------------------------------------------
UnicodeWarning                            Traceback (most recent call last)
<ipython-input-1-96a8540cfb8d> in <module>()
      8 holo = get_example_data('image0001.yaml')
      9 rec_vol = propagate(holo, linspace(4e-6, 10e-6, 7))
---> 10 hp.show(rec_vol)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/show.pyc in show(o, color)
     57         show_sphere_cluster(o,color)
     58     elif isinstance(o, (Image, np.ndarray, list, tuple)):
---> 59         show2d(o)
     60     elif isinstance(o, Scatterer):
     61         show_scatterer(o)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in show2d(im, i, t, phase)
    186             im = np.abs(im)
    187 
--> 188     plotter(im, i, t, axis_names = axis_names)
    189 
    190 def show_scatterer_slices(scatterer, spacing):

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in __init__(self, im, i, j, axis_names)
     47         self.plot = None
     48         self.colorbar = None
---> 49         self.draw()
     50         self.fig.canvas.mpl_connect('key_press_event',self)
     51         self.fig.canvas.mpl_connect('button_press_event', self.click)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in draw(self)
     70         else:
     71             self.plot = self.ax.imshow(im, vmin=self.vmin, vmax=self.vmax,
---> 72                                        interpolation="nearest", aspect=ratio)
     73 
     74             #change the numbers displayed at the bottom to be in

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
   4637         if aspect is None:
   4638             aspect = rcParams['image.aspect']
-> 4639         self.set_aspect(aspect)
   4640         im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
   4641                        filternorm=filternorm,

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in set_aspect(self, aspect, adjustable, anchor)
   1055             the option 'normal' for aspect is deprecated. Use 'auto' instead.
   1056         """
-> 1057         if aspect == 'normal':
   1058             cbook.warn_deprecated(
   1059                 '1.2', name='normal', alternative='auto', obj_type='aspect')

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

If you try to look at the loaded hologram using these two lines, do the
results look different?

hp.show(holo)
imshow(holo)

I get a unicode error when I try and use hp.show:

UnicodeWarning: Unicode equal comparison failed to convert both arguments
to Unicode - interpreting them as being unequal

I'm using 10.10 and Python 2.7 as well.

On 6 May 2015 at 20:39, Brett M. Morris [email protected] wrote:

After making that recommended change, the following error occurs:


UnicodeWarning Traceback (most recent call last)
in ()
8 holo = get_example_data('image0001.yaml')
9 rec_vol = propagate(holo, linspace(4e-6, 10e-6, 7))
---> 10 hp.show(rec_vol)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/show.pyc in show(o, color)
57 show_sphere_cluster(o,color)
58 elif isinstance(o, (Image, np.ndarray, list, tuple)):
---> 59 show2d(o)
60 elif isinstance(o, Scatterer):
61 show_scatterer(o)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in show2d(im, i, t, phase)
186 im = np.abs(im)
187
--> 188 plotter(im, i, t, axis_names = axis_names)
189
190 def show_scatterer_slices(scatterer, spacing):

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in init(self, im, i, j, axis_names)
47 self.plot = None
48 self.colorbar = None
---> 49 self.draw()
50 self.fig.canvas.mpl_connect('key_press_event',self)
51 self.fig.canvas.mpl_connect('button_press_event', self.click)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in draw(self)
70 else:
71 self.plot = self.ax.imshow(im, vmin=self.vmin, vmax=self.vmax,
---> 72 interpolation="nearest", aspect=ratio)
73
74 #change the numbers displayed at the bottom to be in

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
4637 if aspect is None:
4638 aspect = rcParams['image.aspect']
-> 4639 self.set_aspect(aspect)
4640 im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
4641 filternorm=filternorm,

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in set_aspect(self, aspect, adjustable, anchor)
1055 the option 'normal' for aspect is deprecated. Use 'auto' instead.
1056 """
-> 1057 if aspect == 'normal':
1058 cbook.warn_deprecated(
1059 '1.2', name='normal', alternative='auto', obj_type='aspect')

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal


Reply to this email directly or view it on GitHub
#27 (comment).

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

This is my example file, 'image0001.yaml'. It looks like wingdings to me.
What do you all see?

On 6 May 2015 at 21:20, Anna Wang [email protected] wrote:

If you try to look at the loaded hologram using these two lines, do the
results look different?

hp.show(holo)
imshow(holo)

I get a unicode error when I try and use hp.show:

UnicodeWarning: Unicode equal comparison failed to convert both arguments
to Unicode - interpreting them as being unequal

I'm using 10.10 and Python 2.7 as well.

On 6 May 2015 at 20:39, Brett M. Morris [email protected] wrote:

After making that recommended change, the following error occurs:


UnicodeWarning Traceback (most recent call last)
in ()
8 holo = get_example_data('image0001.yaml')
9 rec_vol = propagate(holo, linspace(4e-6, 10e-6, 7))
---> 10 hp.show(rec_vol)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/show.pyc in show(o, color)
57 show_sphere_cluster(o,color)
58 elif isinstance(o, (Image, np.ndarray, list, tuple)):
---> 59 show2d(o)
60 elif isinstance(o, Scatterer):
61 show_scatterer(o)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in show2d(im, i, t, phase)
186 im = np.abs(im)
187
--> 188 plotter(im, i, t, axis_names = axis_names)
189
190 def show_scatterer_slices(scatterer, spacing):

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in init(self, im, i, j, axis_names)
47 self.plot = None
48 self.colorbar = None
---> 49 self.draw()
50 self.fig.canvas.mpl_connect('key_press_event',self)
51 self.fig.canvas.mpl_connect('button_press_event', self.click)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in draw(self)
70 else:
71 self.plot = self.ax.imshow(im, vmin=self.vmin, vmax=self.vmax,
---> 72 interpolation="nearest", aspect=ratio)
73
74 #change the numbers displayed at the bottom to be in

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
4637 if aspect is None:
4638 aspect = rcParams['image.aspect']
-> 4639 self.set_aspect(aspect)
4640 im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
4641 filternorm=filternorm,

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in set_aspect(self, aspect, adjustable, anchor)
1055 the option 'normal' for aspect is deprecated. Use 'auto' instead.
1056 """
-> 1057 if aspect == 'normal':
1058 cbook.warn_deprecated(
1059 '1.2', name='normal', alternative='auto', obj_type='aspect')

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal


Reply to this email directly or view it on GitHub
#27 (comment)
.

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

Brett - I think however we've configured our Macs means that the example
.yaml file doesn't work for us. Instead of loading the example data file,
can you try the following example where we first calculate a hologram, then
propagate it?

import holopy as hp
from holopy.scattering.scatterer import Sphere
from holopy.core import ImageSchema, Optics
from holopy.scattering.theory import Mie
from holopy.propagation import propagate

sphere = Sphere(n = 1.59+.0001j, r = .5, center = (4, 3, 5))

schema = ImageSchema(shape = 100, spacing = .1,
optics = Optics(wavelen = .660, index = 1.33,
polarization = [1,0]))

holo = Mie.calc_holo(sphere, schema)
rec_vol = propagate(holo, linspace(4, 10, 7))
hp.show(rec_vol)

On 6 May 2015 at 21:21, Anna Wang [email protected] wrote:

This is my example file, 'image0001.yaml'. It looks like wingdings to me.
What do you all see?

On 6 May 2015 at 21:20, Anna Wang [email protected] wrote:

If you try to look at the loaded hologram using these two lines, do the
results look different?

hp.show(holo)
imshow(holo)

I get a unicode error when I try and use hp.show:

UnicodeWarning: Unicode equal comparison failed to convert both
arguments to Unicode - interpreting them as being unequal

I'm using 10.10 and Python 2.7 as well.

On 6 May 2015 at 20:39, Brett M. Morris [email protected] wrote:

After making that recommended change, the following error occurs:


UnicodeWarning Traceback (most recent call last)
in ()
8 holo = get_example_data('image0001.yaml')
9 rec_vol = propagate(holo, linspace(4e-6, 10e-6, 7))
---> 10 hp.show(rec_vol)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/show.pyc in show(o, color)
57 show_sphere_cluster(o,color)
58 elif isinstance(o, (Image, np.ndarray, list, tuple)):
---> 59 show2d(o)
60 elif isinstance(o, Scatterer):
61 show_scatterer(o)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in show2d(im, i, t, phase)
186 im = np.abs(im)
187
--> 188 plotter(im, i, t, axis_names = axis_names)
189
190 def show_scatterer_slices(scatterer, spacing):

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in init(self, im, i, j, axis_names)
47 self.plot = None
48 self.colorbar = None
---> 49 self.draw()
50 self.fig.canvas.mpl_connect('key_press_event',self)
51 self.fig.canvas.mpl_connect('button_press_event', self.click)

/Users/bmorris/anaconda/lib/python2.7/site-packages/holopy/vis/vis2d.pyc in draw(self)
70 else:
71 self.plot = self.ax.imshow(im, vmin=self.vmin, vmax=self.vmax,
---> 72 interpolation="nearest", aspect=ratio)
73
74 #change the numbers displayed at the bottom to be in

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
4637 if aspect is None:
4638 aspect = rcParams['image.aspect']
-> 4639 self.set_aspect(aspect)
4640 im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
4641 filternorm=filternorm,

/Users/bmorris/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in set_aspect(self, aspect, adjustable, anchor)
1055 the option 'normal' for aspect is deprecated. Use 'auto' instead.
1056 """
-> 1057 if aspect == 'normal':
1058 cbook.warn_deprecated(
1059 '1.2', name='normal', alternative='auto', obj_type='aspect')

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal


Reply to this email directly or view it on GitHub
#27 (comment)
.

from holopy.

bmorris3 avatar bmorris3 commented on September 15, 2024

That works for me, @anna-wang .

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

Great! Hope other things go more smoothly.

from holopy.

vnmanoharan avatar vnmanoharan commented on September 15, 2024

I think Brett is saying that Anna's code worked, but we still don't know why the original example failed. So I'm reopening this because if our examples aren't working, that's a bug.

There are a couple of things going on here that I don't understand. The first is why warnings like FutureWarning and UnicodeWarning are halting hp.show(). Normally a warning won't do that. The second is why imshow is not showing the correct image (instead it's showing what Anna called "wingdings"). Both of these errors seem to be specific to Mac OS X 10.10. They may also be specific to the python distribution. It looks like Brett is using Anaconda. Anna, what are you using?

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

I'm using Canopy

On 8 May 2015 at 13:45, vnmanoharan [email protected] wrote:

I think Brett is saying that Anna's code worked, but we still don't know
why the original example failed. So I'm reopening this because if our
examples aren't working, that's a bug.

There are a couple of things going on here that I don't understand. The
first is why warnings like FutureWarning and UnicodeWarning are halting
hp.show(). Normally a warning won't do that. The second is why imshow is
not showing the correct image (instead it's showing what Anna called
"wingdings"). Both of these errors seem to be specific to Mac OS X 10.10.
They may also be specific to the python distribution. It looks like Brett
is using Anaconda. Anna, what are you using?


Reply to this email directly or view it on GitHub
#27 (comment)
.

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

The Wingdings is what shows up when I open the yaml file up in a text
editor.

On 8 May 2015 at 13:52, Anna Wang [email protected] wrote:

I'm using Canopy

On 8 May 2015 at 13:45, vnmanoharan [email protected] wrote:

I think Brett is saying that Anna's code worked, but we still don't know
why the original example failed. So I'm reopening this because if our
examples aren't working, that's a bug.

There are a couple of things going on here that I don't understand. The
first is why warnings like FutureWarning and UnicodeWarning are halting
hp.show(). Normally a warning won't do that. The second is why imshow is
not showing the correct image (instead it's showing what Anna called
"wingdings"). Both of these errors seem to be specific to Mac OS X 10.10.
They may also be specific to the python distribution. It looks like Brett
is using Anaconda. Anna, what are you using?


Reply to this email directly or view it on GitHub
#27 (comment)
.

from holopy.

fmehdi15 avatar fmehdi15 commented on September 15, 2024

I am not able to run this example. This is what I get:

Traceback (most recent call last):
File "<pyshell#36>", line 1, in
rec_vol = propagate(holo, linspace(4e-6, 10e-6, 7))
File "C:\Python27\lib\site-packages\holopy\propagation\convolution_propagation.py", line 81, in propagate
ft = apply_trans_func(ft, G)
File "C:\Python27\lib\site-packages\holopy\propagation\convolution_propagation.py", line 119, in apply_trans_func
ft[(m/2-mm):(m/2+mm),(n/2-nn):(n/2+nn)] _= G[:(mm_2),:(nn*2)]
IndexError: invalid slice

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

Hi fmehdi15: are you using Windows? Also, did you get holo from the .yaml file?

holo = get_example_data('image0001.yaml')

If so, can you see the hologram when you type

hp.show(holo)

Anna

from holopy.

fmehdi15 avatar fmehdi15 commented on September 15, 2024

I am using windows 7.

I do get holo from the provided .yaml file. When I type hp.show(holo), I get the following message:

Traceback (most recent call last):
File "<pyshell#28>", line 1, in
hp.show(holo)
File "C:\Python27\lib\site-packages\holopy\vis\show.py", line 59, in show
show2d(o)
File "C:\Python27\lib\site-packages\holopy\vis\vis2d.py", line 188, in show2d
plotter(im, i, t, axis_names = axis_names)
File "C:\Python27\lib\site-packages\holopy\vis\vis2d.py", line 49, in init
self.draw()
File "C:\Python27\lib\site-packages\holopy\vis\vis2d.py", line 72, in draw
interpolation="nearest", aspect=ratio)
File "C:\Python27\lib\site-packages\matplotlib\axes_axes.py", line 4639, in imshow
self.set_aspect(aspect)
File "C:\Python27\lib\site-packages\matplotlib\axes_base.py", line 1059, in set_aspect
if aspect == 'normal':
UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

At this stage, if I type plt.show(), with plt being the shorcut for matplotlib.pyplot, I get an empty figure.

If I add, warnings.filterwarnings("ignore") in the _base.py file, no error message pops up after I type hp.show(holo) but no hologram appears either. However, I am able to view it if I type plt.show() at this point.

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

Hi fmehdi15: what happens if you change the following code (lines 63-67) in holopy/vis/vis2d.py, then open up ipython and try the example again?:

        if  hasattr(im, 'spacing') and im.spacing is not None:
            ratio = str(im.spacing[0]/im.spacing[1])
        else:
            ratio = '1.0'

This change eliminates the Unicode error on my Mac. I am still looking into the invalid slice error for doing a reconstruction.

Anna

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

Ok I think I have a solution. I will implement a few changes to the code and make sure it works in Ubuntu tomorrow morning before putting it up here. The way NumPy treats == and floats vs integers is different (stricter) in the newer Windows and Mac NumPy distributions, which has caused a couple of problems.

Anna

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

Hi fmehdi15: I've implemented some changes. Can you try the latest version of the code and let me know how it goes?

Anna

from holopy.

fmehdi15 avatar fmehdi15 commented on September 15, 2024

Thanks Anna. I could not test it as I am travelling till but will get back to you after the first week of September. Please feel free to delete this message after you have viewed it as it is not adding to the topic but I just wanted to let you know.

Best

Faraz

from holopy.

fmehdi15 avatar fmehdi15 commented on September 15, 2024

Hi Anna-Wang: Your new code took care of the invalid slice error. Thanks.

from holopy.

anna-wang avatar anna-wang commented on September 15, 2024

I'm glad, thanks for letting me know!

Anna

On 9 September 2015 at 14:27, fmehdi15 [email protected] wrote:

Hi Anna-Wang: Your new code took care of the invalid slice error. Thanks.


Reply to this email directly or view it on GitHub
#27 (comment)
.

from holopy.

barkls avatar barkls commented on September 15, 2024

We think everything here is resolved, especially in the upcoming version3 release. We're closing the issue but it should be reopened if these issues persist.

from holopy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.