@mwi-charts.html


001| """Charts for the MWI Posts.
001| 
001| Commands:
001|     c1          do_classical_bounces                ~
001|     c2          do_classical_goes_thru              ~
001|     c3          do_classical_superposition          ~
001|     q1          do_quantum_two_particles            ~
001|     q2          do_quantum_one_particle_splits      ~
001|     test        do_test                             ~test
001| """

002| ####################################################################################################
003| from sys import argv, exc_info
004| from traceback import extract_tb
005| from os import path
006| from matplotlib import pyplot as plt
007| from matplotlib.ticker import NullLocator, FixedLocator, MultipleLocator
008| from matplotlib.ticker import NullFormatter, FixedFormatter, FormatStrFormatter
009| from matplotlib.patches import Patch
010| from logger import logger,info,debug,trace, LogFilenameTimestamp
011| from goodies import KWARG
012| ####################################################################################################
013| BasePath = r'C:\CJS\prj\Python\blog\proj'
014| ImgsPath = path.join(BasePath, 'img')
015| Log = logger('MWIcharts')
016| 
017| CMND = ''
018| ARGS = {
019|     #'fname': 'MWI Chart.png',
020|     #'fpath': BasePath,
021| }
022| 
023| ##------------------------------------------------------------------------------------------------##
024| BallSize = 69
025| 
026| ##================================================================================================##
027| def new_spacetime_chart (title):
028|     '''Create a spacetime chart (x=space, y=time).'''
029|     ticks = [1, 2, 3, 4, 5, 6, 7, 8, 9]
030|     xlabels = [f'$x_{x}$' for x in ticks]
031|     ylabels = [f'$t_{y}$' for y in ticks]
032| 
033|     fig, ax = plt.subplots()
034|     fig.set_figwidth(7.0)
035|     fig.set_figheight(7.0)
036|     fig.suptitle(title, fontsize=14, fontweight='bold')
037|     fig.subplots_adjust(left=0.085, right=0.985, bottom=0.08, top=0.95)
038| 
039|     # X Axis...
040|     ax.set_xlabel('Position', fontsize=12, fontweight='bold')
041|     ax.set_xlim(0.0, 10.0)
042|     ax.xaxis.set_major_locator(FixedLocator(ticks))
043|     ax.xaxis.set_minor_locator(MultipleLocator(0.25))
044|     ax.xaxis.set_major_formatter(FixedFormatter(xlabels))
045| 
046|     for tick in ax.get_xticklabels():
047|         tick.set_fontstyle('italic')
048|         tick.set_fontsize(12)
049| 
050|     # Y Axis...
051|     ax.set_ylabel('Time', fontsize=12, fontweight='bold')
052|     ax.set_ylim(0.0, 10.0)
053|     ax.yaxis.set_major_locator(FixedLocator(ticks))
054|     ax.yaxis.set_minor_locator(MultipleLocator(0.25))
055|     ax.yaxis.set_major_formatter(FixedFormatter(ylabels))
056| 
057|     for tick in ax.get_yticklabels():
058|         tick.set_fontstyle('italic')
059|         tick.set_fontsize(12)
060| 
061|     # Grid...
062|     ax.grid(which='major', axis='both', color='#9f9f9f', lw=1.0,ls='-',zorder=1, alpha=1.0)
063|     ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
064|     ax.tick_params(which='major', axis='both', direction='out', color='#000000')
065|     ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
066| 
067|     # Base line...
068|     ax.axhline(0.0, lw=2.7, color='#000000', alpha=1.00, zorder=11)
069| 
070|     # Wall...
071|     ax.axvspan(5.0,5.125, ymax=1.1, lw=1.7, fc='#ff7f7f', ec='#000000', alpha=0.50, zorder=10)
072| 
073|     return (fig, ax)
074| 
075| ##================================================================================================##
076| def new_phase_chart (title):
077|     '''Create a phase chart (x=particle1, y=particle2).'''
078|     ticks = [1, 2, 3, 4, 5, 6, 7, 8, 9]
079|     xlabels = [f'$x_{x}$' for x in ticks]
080|     ylabels = [f'$x_{y}$' for y in ticks]
081| 
082|     fig, ax = plt.subplots()
083|     fig.set_figwidth(7.0)
084|     fig.set_figheight(7.0)
085|     fig.suptitle(title, fontsize=14, fontweight='bold')
086|     fig.subplots_adjust(left=0.085, right=0.985, bottom=0.08, top=0.95)
087| 
088|     # X Axis...
089|     ax.set_xlabel('Particle 1 Position', fontsize=12, fontweight='bold')
090|     ax.set_xlim(0.0, 10.0)
091|     ax.xaxis.set_major_locator(FixedLocator(ticks))
092|     ax.xaxis.set_minor_locator(MultipleLocator(0.25))
093|     ax.xaxis.set_major_formatter(FixedFormatter(xlabels))
094| 
095|     for tick in ax.get_xticklabels():
096|         tick.set_fontstyle('italic')
097|         tick.set_fontsize(12)
098| 
099|     # Y Axis...
100|     ax.set_ylabel('Particle 2 Position', fontsize=12, fontweight='bold')
101|     ax.set_ylim(0.0, 10.0)
102|     ax.yaxis.set_major_locator(FixedLocator(ticks))
103|     ax.yaxis.set_minor_locator(MultipleLocator(0.25))
104|     ax.yaxis.set_major_formatter(FixedFormatter(ylabels))
105| 
106|     for tick in ax.get_yticklabels():
107|         tick.set_fontstyle('italic')
108|         tick.set_fontsize(12)
109| 
110|     # Grid...
111|     ax.grid(which='major', axis='both', color='#9f9f9f', lw=1.0,ls='-',zorder=1, alpha=1.0)
112|     ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
113|     ax.tick_params(which='major', axis='both', direction='out', color='#000000')
114|     ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
115| 
116|     # Wall...
117|     ax.axvspan(5.0,5.125, ymax=1.1, lw=1.7, fc='#ff7f7f', ec='#000000', alpha=0.50, zorder=10)
118|     ax.axhspan(5.0,5.125, xmax=1.1, lw=1.7, fc='#ff7f7f', ec='#000000', alpha=0.50, zorder=10)
119| 
120|     return (fig, ax)
121| 
122| 
123| ##================================================================================================##
124| def do_classical_bounces (**kwargs):
125|     '''CMND: Create chart for Classical Bounces scenario.'''
126|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
127|     fname = KWARG('fname', 'classical-bounces.png', str, kwargs)
128|     Log.info('classical-bounces:: %s' % str(list(kwargs.keys())))
129|     Log.debug(f'{fpath=}')
130|     Log.debug(f'{fname=}')
131|     Log.info()
132|     xs = [1, 2, 3, 4, 5, 4, 3, 2, 1]
133|     ys = [1, 2, 3, 4, 5, 6, 7, 8, 9]
134| 
135|     # Create a chart...
136|     fig,ax = new_spacetime_chart('Classical Physics - Ball Bounces')
137| 
138|     # Horizontal time lines...
139|     ax.axhline(9.0, xmax=0.1, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
140|     ax.axhline(8.0, xmax=0.2, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
141|     ax.axhline(7.0, xmax=0.3, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
142|     ax.axhline(6.0, xmax=0.4, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
143|     ax.axhline(5.0, xmax=0.5, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
144|     ax.axhline(4.0, xmax=0.4, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
145|     ax.axhline(3.0, xmax=0.3, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
146|     ax.axhline(2.0, xmax=0.2, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
147|     ax.axhline(1.0, xmax=0.1, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
148| 
149|     # Vertical position lines...
150|     ax.axvline(1.0, ymax=0.9, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
151|     ax.axvline(2.0, ymax=0.8, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
152|     ax.axvline(3.0, ymax=0.7, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
153|     ax.axvline(4.0, ymax=0.6, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
154| 
155|     # Draw stuff on the chart...
156|     ax.plot(xs,ys, c='#3f3fff', lw=2.5, alpha=0.8, zorder=21)
157|     ax.scatter(xs,ys, c='#0000ff', s=BallSize, marker='o', alpha=1.00, zorder=31)
158| 
159|     # Save the chart image file...
160|     filename = path.join(fpath,fname) if fpath else fname
161|     fig.savefig(filename)
162|     Log.info(f'wrote: {filename}')
163| 
164|     Log.info()
165|     return 'Done'
166| 
167| ##================================================================================================##
168| def do_classical_goes_thru (**kwargs):
169|     '''CMND: Create chart for Classical Bashes Through scenario.'''
170|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
171|     fname = KWARG('fname', 'classical-goes-thru.png', str, kwargs)
172|     Log.info('classical-goes-thru:: %s' % str(list(kwargs.keys())))
173|     Log.debug(f'{fpath=}')
174|     Log.debug(f'{fname=}')
175|     Log.info()
176|     xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]
177|     ys = [1, 2, 3, 4, 5, 6, 7, 8, 9]
178| 
179|     # Create a chart...
180|     fig,ax = new_spacetime_chart('Classical Physics - Ball Bashes Through')
181| 
182|     # Horizontal time lines...
183|     ax.axhline(9.0, xmax=0.9, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
184|     ax.axhline(8.0, xmax=0.8, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
185|     ax.axhline(7.0, xmax=0.7, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
186|     ax.axhline(6.0, xmax=0.6, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
187|     ax.axhline(5.0, xmax=0.5, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
188|     ax.axhline(4.0, xmax=0.4, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
189|     ax.axhline(3.0, xmax=0.3, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
190|     ax.axhline(2.0, xmax=0.2, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
191|     ax.axhline(1.0, xmax=0.1, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
192| 
193|     # Vertical position lines...
194|     ax.axvline(1.0, ymax=0.1, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
195|     ax.axvline(2.0, ymax=0.2, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
196|     ax.axvline(3.0, ymax=0.3, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
197|     ax.axvline(4.0, ymax=0.4, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
198|     ax.axvline(5.0, ymax=0.5, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
199|     ax.axvline(6.0, ymax=0.6, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
200|     ax.axvline(7.0, ymax=0.7, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
201|     ax.axvline(8.0, ymax=0.8, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
202|     ax.axvline(9.0, ymax=0.9, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
203| 
204|     # Draw stuff on the chart...
205|     ax.plot(xs,ys, c='#ff3f3f', lw=2.5, alpha=0.8, zorder=21)
206|     ax.scatter(xs,ys, c='#ff0000', s=BallSize, marker='o', alpha=1.00, zorder=31)
207| 
208|     # Save the chart image file...
209|     filename = path.join(fpath,fname) if fpath else fname
210|     fig.savefig(filename)
211|     Log.info(f'wrote: {filename}')
212| 
213|     Log.info()
214|     return 'Done'
215| 
216| ##================================================================================================##
217| def do_classical_superposition (**kwargs):
218|     '''CMND: Create chart for Classical superposition scenario.'''
219|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
220|     fname = KWARG('fname', 'classical-superposition.png', str, kwargs)
221|     Log.info('classical-superposition:: %s' % str(list(kwargs.keys())))
222|     Log.debug(f'{fpath=}')
223|     Log.debug(f'{fname=}')
224|     Log.info()
225|     xs1 = [1, 2, 3, 4, 5, 4, 3, 2, 1]
226|     xs2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
227|     ys  = [1, 2, 3, 4, 5, 6, 7, 8, 9]
228| 
229|     # Create a chart...
230|     fig,ax = new_spacetime_chart('Classical Physics - "Superposition"')
231| 
232|     # Horizontal time lines...
233|     ax.axhline(9.0, xmax=0.9, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
234|     ax.axhline(8.0, xmax=0.8, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
235|     ax.axhline(7.0, xmax=0.7, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
236|     ax.axhline(6.0, xmax=0.6, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
237|     ax.axhline(5.0, xmax=0.5, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
238|     ax.axhline(4.0, xmax=0.4, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
239|     ax.axhline(3.0, xmax=0.3, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
240|     ax.axhline(2.0, xmax=0.2, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
241|     ax.axhline(1.0, xmax=0.1, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
242| 
243|     # Vertical position lines...
244|     ax.axvline(1.0, ymax=0.9, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
245|     ax.axvline(2.0, ymax=0.8, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
246|     ax.axvline(3.0, ymax=0.7, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
247|     ax.axvline(4.0, ymax=0.6, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
248|     ax.axvline(5.0, ymax=0.5, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
249|     ax.axvline(6.0, ymax=0.6, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
250|     ax.axvline(7.0, ymax=0.7, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
251|     ax.axvline(8.0, ymax=0.8, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
252|     ax.axvline(9.0, ymax=0.9, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
253| 
254|     # Draw stuff on the chart...
255|     ax.plot(xs1,ys, c='#0000ff', lw=2.5, alpha=0.7, zorder=21)
256|     ax.plot(xs2,ys, c='#ff0000', lw=2.5, alpha=0.7, zorder=22)
257|     ax.scatter(xs1[0:5],ys[0:5], c='#cc00cc', s=BallSize, marker='o', alpha=1.00, zorder=31)
258|     ax.scatter(xs1[5:],ys[5:], c='#0000ff', s=BallSize, marker='o', alpha=1.00, zorder=32)
259|     ax.scatter(xs2[5:],ys[5:], c='#ff0000', s=BallSize, marker='o', alpha=1.00, zorder=31)
260| 
261|     # Save the chart image file...
262|     filename = path.join(fpath,fname) if fpath else fname
263|     fig.savefig(filename)
264|     Log.info(f'wrote: {filename}')
265| 
266|     Log.info()
267|     return 'Done'
268| 
269| ##================================================================================================##
270| def do_quantum_two_particles (**kwargs):
271|     '''CMND: Create chart for Quantum two-particle scenario.'''
272|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
273|     fname = KWARG('fname', 'quantum-two-particles.png', str, kwargs)
274|     Log.info('quantum-two-particles:: %s' % str(list(kwargs.keys())))
275|     Log.debug(f'{fpath=}')
276|     Log.debug(f'{fname=}')
277|     Log.info()
278|     xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]
279|     ys = [1, 2, 3, 4, 5, 6, 7, 8, 9]
280| 
281|     # Create a chart...
282|     fig,ax = new_phase_chart('Quantum Physics - Two Particles')
283| 
284|     # Horizontal time lines...
285|     ax.axhline(9.0, xmax=0.9, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
286|     ax.axhline(8.0, xmax=0.8, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
287|     ax.axhline(7.0, xmax=0.7, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
288|     ax.axhline(6.0, xmax=0.6, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
289|     ax.axhline(5.0, xmax=0.5, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
290|     ax.axhline(4.0, xmax=0.4, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
291|     ax.axhline(3.0, xmax=0.3, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
292|     ax.axhline(2.0, xmax=0.2, ls='--', lw=1.0, color='#3366cc', alpha=0.80, zorder=11)
293|     ax.axhline(1.0, xmax=0.1, ls='--', lw=1.9, color='#3366cc', alpha=0.80, zorder=11)
294| 
295|     # Vertical position lines...
296|     ax.axvline(1.0, ymax=0.1, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
297|     ax.axvline(2.0, ymax=0.2, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
298|     ax.axvline(3.0, ymax=0.3, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
299|     ax.axvline(4.0, ymax=0.4, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
300|     ax.axvline(5.0, ymax=0.5, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
301|     ax.axvline(6.0, ymax=0.6, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
302|     ax.axvline(7.0, ymax=0.7, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
303|     ax.axvline(8.0, ymax=0.8, ls='--', lw=1.0, color='#339966', alpha=0.80, zorder=12)
304|     ax.axvline(9.0, ymax=0.9, ls='--', lw=1.8, color='#339966', alpha=0.80, zorder=12)
305| 
306|     # Draw stuff on the chart...
307|     ax.plot(xs,ys, c='#cc3fcc', lw=2.5, alpha=0.8, zorder=21)
308|     ax.scatter(xs,ys, c='#990099', s=BallSize, marker='o', alpha=1.00, zorder=31)
309| 
310|     # Save the chart image file...
311|     filename = path.join(fpath,fname) if fpath else fname
312|     fig.savefig(filename)
313|     Log.info(f'wrote: {filename}')
314| 
315|     Log.info()
316|     return 'Done'
317| 
318| ##================================================================================================##
319| def do_quantum_one_particle_splits (**kwargs):
320|     '''CMND: Create chart for Quantum one-particle splits scenario.'''
321|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
322|     fname = KWARG('fname', 'quantum-one-particle-splits.png', str, kwargs)
323|     Log.info('quantum-one-particle-splits:: %s' % str(list(kwargs.keys())))
324|     Log.debug(f'{fpath=}')
325|     Log.debug(f'{fname=}')
326|     Log.info()
327|     x1s = [1, 2, 3, 4, 5]
328|     y1s = [1, 1, 1, 1, 1]
329|     x2s = [5, 6, 7, 8, 9]
330|     y2s = [5, 6, 7, 8, 9]
331| 
332|     # Create a chart...
333|     fig,ax = new_phase_chart('Quantum Physics - One Particle Splits')
334| 
335|     # Horizontal time lines...
336|     # Vertical position lines...
337| 
338|     # Draw stuff on the chart...
339|     ax.plot(x1s,y1s, c='#ff3f3f', lw=2.5, alpha=0.8, zorder=21)
340|     ax.plot(x2s,y2s, c='#cc3fcc', lw=2.5, alpha=0.8, zorder=21)
341|     ax.scatter(x1s,y1s, c='#ff0000', s=BallSize, marker='o', alpha=1.00, zorder=31)
342|     ax.scatter(x2s,y2s, c='#990099', s=BallSize, marker='o', alpha=1.00, zorder=31)
343| 
344|     # Save the chart image file...
345|     filename = path.join(fpath,fname) if fpath else fname
346|     fig.savefig(filename)
347|     Log.info(f'wrote: {filename}')
348| 
349|     Log.info()
350|     return 'Done'
351| 
352| ##================================================================================================##
353| def do_quantum_scenario (**kwargs):
354|     '''CMND: Create chart for Quantum scenario.'''
355|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
356|     fname = KWARG('fname', 'quantum-scenario.png', str, kwargs)
357|     Log.info('quantum-scenario:: %s' % str(list(kwargs.keys())))
358|     Log.debug(f'{fpath=}')
359|     Log.debug(f'{fname=}')
360|     Log.info()
361|     xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]
362|     ys = [1, 2, 3, 4, 5, 6, 7, 8, 9]
363| 
364|     # Create a chart...
365|     fig,ax = new_phase_chart('Quantum Physics - ZCZC')
366| 
367|     # Horizontal time lines...
368|     # Vertical position lines...
369|     # Draw stuff on the chart...
370| 
371|     # Save the chart image file...
372|     filename = path.join(fpath,fname) if fpath else fname
373|     fig.savefig(filename)
374|     Log.info(f'wrote: {filename}')
375| 
376|     Log.info()
377|     return 'Done'
378| 
379| ##================================================================================================##
380| def do_test (**kwargs):
381|     '''CMND: Do a test.'''
382|     fpath = KWARG('fpath', BasePath, str, kwargs)
383|     fname = KWARG('fname', 'test.out', str, kwargs)
384|     Log.info('test:: %s' % str(list(kwargs.keys())))
385|     Log.debug(f'{fpath=}')
386|     Log.debug(f'{fname=}')
387|     Log.info()
388|     Log.info()
389|     return 'Done'
390| ####################################################################################################
391| def dispatch (cmd, **kwargs):
392|     '''Dispatch to a module function based on CMD.'''
393|     Log.info(f'CMD: {cmd}')
394|     for kw in kwargs:
395|         Log.debug(f'argument[{kw}]: {kwargs[kw]}')
396|     Log.info()
397|     if cmd == 'c1': return do_classical_bounces(**kwargs)
398|     if cmd == 'c2': return do_classical_goes_thru(**kwargs)
399|     if cmd == 'c3': return do_classical_superposition(**kwargs)
400|     if cmd == 'q1': return do_quantum_two_particles(**kwargs)
401|     if cmd == 'q2': return do_quantum_one_particle_splits(**kwargs)
402|     if cmd == 'test': return do_test(**kwargs)
403|     return 'Nothing to do!'
404| ####################################################################################################
405| if __name__ == '__main__':
406|     print(f'autorun: {argv[0]}')
407|     Log.start(path.join(BasePath,'mwi-charts.log'))
408|     Log.level(debug())
409|     Log.info(argv[0])
410|     Log.info()
411|     cmd = argv[1] if 1 < len(argv) else CMND
412|     kwargs = ARGS
413|     for a in argv[2:]:
414|         nv = a.split('=', 1)
415|         kwargs[nv[0]] = (nv[1] if 1<len(nv) else '')
416|         Log.debug(f'{nv[0]}: "{kwargs[nv[0]]}"')
417|     try:
418|         print(f'CMD: {cmd}')
419|         print()
420|         obj = dispatch(cmd, **kwargs)
421|         print()
422|         print(obj)
423|         Log.info()
424|         Log.info(obj)
425|     except:
426|         etype, evalue, tb = exc_info()
427|         ts = extract_tb(tb)
428|         Log.error()
429|         Log.error(f'{etype.__name__}: {evalue!s}')
430|         Log.error()
431|         for t in ts[-5:]:
432|             Log.error(f'[{t[1]}] {t[2]} ({t[0]})')
433|             Log.error(f' {t[3]}')
434|             Log.error()
435|         raise
436|     finally:
437|         Log.end()
438| ####################################################################################################
439| '''eof'''
440|