def simulate_all_in_one(config): """simulate all grid points, and compose PDF reports A PDF includes basic info, a plot of dynamical range, and a plot of simulated resolution functions on a grid. """ import pylatex Ei = config.Ei Erange = (-0.3 * Ei, .95 * Ei) for sl in config.slices: doc = _wph.initReportDoc("%s-sim-report" % sl.name) # report document # info _wph.slice_info_section(sl, doc) qaxis = sl.grid.qaxis Eaxis = sl.grid.Eaxis # dyn range plot # larger q range for a broader view ratio = 1. expanded_qaxis = sx.axis( min=qaxis.min - (qaxis.max - qaxis.min) * ratio / 2, max=qaxis.max + (qaxis.max - qaxis.min) * ratio / 2, step=qaxis.step).ticks() width = r'1\textwidth' with doc.create(pylatex.Section('Dynamical range')): with doc.create(pylatex.Figure(position='htbp')) as plot: plt.figure() plotDynRange(sl.hkl0, sl.hkl_projection, qaxis=expanded_qaxis, Erange=Erange, config=config) plot.add_plot(width=pylatex.NoEscape(width)) plot.add_caption('Dynamical range for slice %s' % sl.name) plt.close() # simulate with doc.create( pylatex.Section('Simulated resolution functions on a grid')): outputs, failed = simulate_all_grid_points( slice=sl, config=config, Nrounds_beam=config.sim_Nrounds_beam, overwrite=False) if failed: # this seems unecessary as what is missing is clear in the plot """ doc.append("Failed to calculate resolution functions for the following (Q,E) pairs:") with doc.create(pylatex.Itemize()) as itemize: for f in failed: itemize.add_item(str(f)) """ pass # plot with doc.create(pylatex.Figure(position='htbp')) as plot: plt.figure() plot_resolution_on_grid(sl, config, figsize=(10, 10)) plot.add_plot(width=pylatex.NoEscape(width)) plot.add_caption('Simulated resolution functions for %s' % sl.name) plt.close() # save pdf doc.generate_pdf(clean_tex=False) continue return
class res_2d_grid: "resolution data will be histogrammed into this grid" qaxis = sx.axis(min=-0.25, max=0.25, step=0.01) Eaxis = sx.axis(min=-2., max=2., step=.05)
class grid: qaxis = sx.axis(min=0, max=4. + 1e-5, step=0.5 / 10) Eaxis = sx.axis(min=0., max=40. + 1e-5, step=1.)
class grid: "simulations will be done for points on this grid" qaxis = sx.axis(min=-.5, max=4.5, step=0.6) Eaxis = sx.axis(min=-4., max=42.1, step=8.)