def process(self): for job in self.jobs: job.percent_complete = min( job.percent_complete + random.randint(0, 3), 100) if any(job.percent_complete < 100 for job in self.jobs): GUI.invoke_after(100, self.process)
def step11(self): theoretical = np.genfromtxt(f"{TestDataPath}/Figure810BH.csv", delimiter=',') x = theoretical[:,0] y = theoretical[:,1] Source = PlaneWave(Wavelength = 470e-9, Polarization = None, Amplitude = 1) Scat = Cylinder(Diameter = 3000e-9, Source = Source, Index = 1.00+0.07j, nMedium = 1.0) S1S2 = Scat.S1S2(Phi = x+90) Data = ( np.abs(S1S2['S1'])**2 + np.abs(S1S2['S2'])**2 ) * ( 0.5 / (np.pi * Source.k) )**(1/4) error = np.abs( ( Data - y ) / y ) GUI.invoke_after(PLOTTIME, Close) plt.figure() plt.plot( S1S2['Phi']-90, Data,'C1-', linewidth=3, label='PyMieSim' ) plt.plot( x, y,'k--', linewidth=1, label='B&H [8.10]') plt.xlabel('Scattering angle [degree]'); plt.ylabel('Phase function') plt.yscale('log'); plt.grid(); plt.legend(); plt.tight_layout() plt.show() if not np.all(error < 1): raise
def step05(self): theoretical = np.genfromtxt(f"{TestDataPath}/Figure87BH.csv", delimiter=',') Diameter = np.geomspace(10e-9, 6e-6, 800) Volume = np.pi * (Diameter/2)**2 scatSet = CylinderSet(Diameter = Diameter, Index = 1.55, nMedium = 1.) sourceSet = SourceSet(Wavelength = 632.8e-9, Polarization = [0, 90], Amplitude = 1) ExpSet = Setup(ScattererSet = scatSet, SourceSet = sourceSet, DetectorSet = None) Data = ExpSet.Get(Measure.Csca).Data.squeeze()/Volume*1e-4/100 GUI.invoke_after(PLOTTIME, Close) plt.figure() plt.plot(Diameter, Data[0],'C0-', linewidth=3, label='PyMieSim' ) plt.plot(Diameter, Data[1],'C1-', linewidth=3, label='PyMieSim' ) plt.plot( Diameter, theoretical[0],'k--', linewidth=1, label='BH 8.8') plt.plot( Diameter, theoretical[1],'k--', linewidth=1, label='BH 8.8') plt.xlabel(r'Diameter [\mu m]'); plt.ylabel('Scattering cross section [Cylinder]') plt.grid(); plt.legend(); plt.tight_layout() plt.show() if not np.all(np.isclose(Data,theoretical, 1e-9)): raise
def close(): """Close the scene.""" f = mlab.gcf() e = mlab.get_engine() e.window.workbench.prompt_on_exit = False e.window.close() mlab.options.backend = 'auto' # Hack: on Linux the splash screen does not go away so we force it. GUI.invoke_after(500, e.window.workbench.application.gui.stop_event_loop)
def close(self): """ Close the dialog. """ self._closing = True # We don't call our superclass' 'close' method immediately as there # may be one final call to '_pulse_and_reschedule' already on the # event queue. This makes sure that we call 'close' *after* that final # update. GUI.invoke_after(self.delay, super(PulseProgressDialog, self).close)
def main(): """ Entry point for standalone testing/debugging. """ from pyface.api import GUI gui = GUI() progress_dialog = PulseProgressDialog(title="Test", message="Doing something possibly interesting...") progress_dialog.open() gui.invoke_after(3000, progress_dialog.close) gui.start_event_loop() return
def main(): """ Entry point for standalone testing/debugging. """ from pyface.api import GUI gui = GUI() progress_dialog = PulseProgressDialog( title='Test', message='Doing something possibly interesting...') progress_dialog.open() gui.invoke_after(3000, progress_dialog.close) gui.start_event_loop() return
def _anytrait_changed ( self, name, old, new ): if name[:4] == 'var_': name = name[4:] if (not self._no_block_update) and (self.block is not None): if isinstance( old, ArangeGenerator ): old.on_trait_change( self._array_changed, 'array', remove = True ) if isinstance( new, ArangeGenerator ): new.on_trait_change( self._array_changed, 'array' ) new = new.array self.context[ name ] = new self._needs_update = True #print "Adding update func" def update_func(): if self._needs_update: self._blocks[ name ].execute( self.context ) self._needs_update = False GUI.invoke_after(10, update_func)
def step10(self): theoretical = np.genfromtxt(f"{TestDataPath}/PyMieScattQscaCoreShellMedium.csv", delimiter=',') Diameter = np.geomspace(10e-9, 500e-9, 400) scatSet = CoreShellSet(CoreDiameter = Diameter, ShellDiameter = 600e-9, CoreIndex = 1.4, ShellIndex=1.5, nMedium = 1.2) sourceSet = SourceSet(Wavelength = 600e-9, Polarization = [None], Amplitude = 1) ExpSet = Setup(ScattererSet = scatSet, SourceSet = sourceSet, DetectorSet = None) Data = ExpSet.Get(Measure.Qsca).Data.squeeze() GUI.invoke_after(PLOTTIME, Close) plt.figure() plt.plot(Diameter, Data,'C1-', linewidth=3, label='PyMieSim' ) plt.plot( Diameter, theoretical,'k--', linewidth=1, label='PyMieScatt') plt.xlabel(r'Diameter [\mu m]'); plt.ylabel('Scattering efficiency [CoreShell + nMedium]') plt.grid(); plt.legend(); plt.tight_layout() plt.show() if not np.all(np.isclose(Data,theoretical, 1e-9)): raise
def _anytrait_changed(self, name, old, new): if name[:4] == 'var_': name = name[4:] if (not self._no_block_update) and (self.block is not None): if isinstance(old, ArangeGenerator): old.on_trait_change(self._array_changed, 'array', remove=True) if isinstance(new, ArangeGenerator): new.on_trait_change(self._array_changed, 'array') new = new.array self.context[name] = new self._needs_update = True #print "Adding update func" def update_func(): if self._needs_update: self._blocks[name].execute(self.context) self._needs_update = False GUI.invoke_after(10, update_func)
def close(self): """ Close progress bar window. """ GUI.invoke_after(0.1, super(PulsableProgressDialog, self).close) sleep(0.2)
def _populate_and_process(self, event): self.populate() GUI.invoke_after(1000, self.process)
def step46(self): GUI.invoke_after(PLOTTIME, Close) self.footprint.Plot()
def step10(self): GUI.invoke_after(PLOTTIME, Close) self.sphere.SPF(Num=40).Plot()
def step39(self): GUI.invoke_after(PLOTTIME, Close) GUI.invoke_after(2*PLOTTIME, Close) self.coreShell.FarField(40).Plot()
def step40(self): GUI.invoke_after(PLOTTIME, Close) self.coreShell.SPF(40).Plot()
def test_mlab_show(): """Test mlab.show()""" run_mlab_examples() # Automatically close window in 100 msecs. GUI.invoke_after(100, close) mlab.show()
def f(): do_mlab() # Automatically close window in 2500 msecs. GUI.invoke_after(2500, close)
def test04(self): GUI.invoke_after(PLOTTIME, Close) LPmode.Plot() print('LPmode Plotting passed')
def step08(self): GUI.invoke_after(PLOTTIME, Close) self.sphere.Stokes(Num=40).Plot()
def _start_fired(self): self.populate() GUI.invoke_after(1000, self.process)
def f(): mlab.options.backend = 'envisage' mlab.test_contour3d() GUI.invoke_after(3000, close)
def _new_workbench_window_created(self, event): try: GUI.invoke_after(500.0, self.mcss_ui_plugin.edit_new_mcss_experiment, event.window) # do it in the UI thread, not too fast for workbench_window to have been created and hopefully slow enough (not tested on a slow computer), but not too slow for user #@UndefinedVariable except AttributeError: pass # give up
def step07(self): GUI.invoke_after(PLOTTIME, Close) self.sphere.S1S2(Num=40).Plot()
def step38(self): GUI.invoke_after(PLOTTIME, Close) self.coreShell.Stokes(40).Plot()
def f(): run_mlab_examples() # Automatically close window in 100 msecs. GUI.invoke_after(100, close)
def test03(self): GUI.invoke_after(PLOTTIME, Close) Detector0.Plot() print('Photodiode Plotting passed')
def _schedule_pulse(self): """ Schedule a pulse for 'self.delay' milliseconds from now. """ GUI.invoke_after(self.delay, self._pulse_and_reschedule)
def f(): from mayavi.preferences.api import preference_manager preference_manager.root.show_splash_screen = False mlab.options.backend = 'envisage' mlab.test_contour3d() GUI.invoke_after(3000, close)
def step09(self): GUI.invoke_after(PLOTTIME, Close) GUI.invoke_after(2*PLOTTIME, Close) self.sphere.FarField(Num=40).Plot()
def test05(self): GUI.invoke_after(PLOTTIME, Close) IntegratingSphere.Plot() print('IntegratingSphere Plotting passed')
def step37(self): GUI.invoke_after(PLOTTIME, Close) self.coreShell.S1S2(Num=10).Plot()
def test_mlab_show(): """Test mlab.show()""" do_mlab() # Automatically close window in 2500 msecs. GUI.invoke_after(2500, close) mlab.show()
def test09(self): GUI.invoke_after(PLOTTIME, Close) sScat.S1S2(10).Plot() print('<S1S2> Plot passed')
def test05(self): GUI.invoke_after(PLOTTIME, Close) pymieArrayEff.Plot(y='Qsca', x='diameter') print('PyMieSim Array Efficiencies plotting passed')
def test06(self): GUI.invoke_after(PLOTTIME, Close) pymieArrayCoupling.Plot(y='Coupling', x='diameter') print('PyMieSim Array Coupling plotting passed')