Closed yurirtonin closed 1 month ago
@yurirtonin from what I can see in the traceback the issue seems to be strange vales (likely NaNs) in the probe. If indeed your data includes negative values, then that could certainly be the origin of this problem. I'd suggest to load a mask to ignore those invalid pixels.
I included a mask for invalid pixels, but still need to try setting these -1 values to 0. I will let you know how it goes.
Hi everyone, quick update. I set the invalid values from -1 to 0 + included the mask the the ML engine did not complain anymore. Issue solved. Perhaps adding a quick check for weird values in the input dataset could help avoid future issues. Cheers :)
Hi everyone, just posting here an error that I noticed with Bjorn.
I ran RAAR successfully for 300 iterations and then ML accused an error when plotting. I wonder if the data could be the issue causing a NaN or something like it here, since our "invalid pixels" are given -1 values.
Cheers, Yuri
`--------------------------------------------------------------------------- AssertionError Traceback (most recent call last) Cell In[28], line 2 1 # Run reconstruction ----> 2 P = ptypy.core.Ptycho(p,level=5)
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/core/ptycho.py:396, in Ptycho.init(self, pars, level, **kwargs) 394 self.init_engine() 395 if level >= 5: --> 396 self.run() 397 self.finalize()
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/core/ptycho.py:784, in Ptycho.run(self, label, epars, engine) 782 self.runtime.allstop = None 783 for engine in self.engines.values(): --> 784 self.run(engine=engine)
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/core/ptycho.py:734, in Ptycho.run(self, label, epars, engine) 732 self._jupyter_client = _JupyterClient(self, autoplot_pars=self.p.io.autoplot, layout_pars=self.p.io.autoplot.layout) 733 self._jupyter_client.runtime.update(self.runtime) --> 734 self._jupyter_client.display(imsg) 735 else: 736 ilog_streamer(imsg)
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_client.py:735, in _JupyterClient.display(self, title) 734 def display(self,title): --> 735 self.ipython.display.display(self.plot(title=title), clear=True)
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_client.py:730, in _JupyterClient.plot(self, title) 728 self.initialized=True 729 self.plot_fig.suptitle(title) --> 730 self.plot_all() 731 plt.close(self.plot_fig) 732 return self.plot_fig
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_client.py:637, in MPLplotter.plot_all(self) 634 for key, storage in self.pr.items(): 635 #print key 636 pp = self.pr_plot[key] --> 637 self.plot_storage(storage,pp, str(key), 'pr') 638 for key, storage in self.ob.items(): 639 #print key 640 pp = self.ob_plot[key]
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_client.py:595, in MPLplotter.plot_storage(self, storage, plot_pars, title, typ) 593 # get the layer 594 ptya.set_mask(mask, False) --> 595 ptya.set_data(data[layer]) 596 ptya.ax.set_ylim(crop[0],sh[0]-crop[0]) 597 ptya.ax.set_xlim(crop[1],sh[1]-crop[1])
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_utils.py:721, in PtyAxis.set_data(self, data, update) 719 self._update(renew_image=True) 720 else: --> 721 self._update()
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_utils.py:764, in PtyAxis._update(self, renew_image) 761 else: 762 mn, mx = self.vmin, self.vmax --> 764 pilim = imsave(imdata, cmap=self.cmap, vmin=mn, vmax=mx) 765 if not self.ax.images or renew_image: 766 self.ax.imshow(pilim, **self.kwargs)
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_utils.py:351, in imsave(a, filename, vmin, vmax, cmap) 348 cmap = mpl.colormaps.get_cmap(cmap) 350 if a.dtype.kind == 'c': --> 351 i = complex2rgb(a, vmin=vmin, vmax=vmax) 352 im = Image.fromarray(np.uint8(i), mode='RGB') 354 else:
File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_utils.py:196, in complex2rgb(cin, kwargs) 186 def complex2rgb(cin, kwargs): 187 """ 188 Executes
complex2hsv
and thenhsv2rgb
189 (...) 194 rgb2complex 195 """ --> 196 return hsv2rgb(complex2hsv(cin, **kwargs))File /global/common/software/ntrain3/ptypy_env/lib/python3.11/site-packages/ptypy/utils/plot_utils.py:180, in complex2hsv(cin, vmin, vmax) 178 v = v.clip(0.0, 1.0) 179 else: --> 180 assert vmin < vmax 181 v = (v.clip(vmin, vmax)-vmin)/(vmax-vmin) 183 return np.asarray((h, s, v))
AssertionError: <Figure size 640x480 with 0 Axes>`