From 09f4c70c6a08a246cad8db044ef85fbb5da5089f Mon Sep 17 00:00:00 2001 From: James Ball Date: Thu, 21 Nov 2024 17:04:33 +0100 Subject: [PATCH] Fix y0 bug, a bit of cleanup --- .../S3DXRD/select_for_index_unknown.ipynb | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/ImageD11/nbGui/S3DXRD/select_for_index_unknown.ipynb b/ImageD11/nbGui/S3DXRD/select_for_index_unknown.ipynb index 9e11d6cc..a356754d 100644 --- a/ImageD11/nbGui/S3DXRD/select_for_index_unknown.ipynb +++ b/ImageD11/nbGui/S3DXRD/select_for_index_unknown.ipynb @@ -90,7 +90,7 @@ }, "outputs": [], "source": [ - "ds.parfile = aroot + \"/LMGO_pseudo_cubic.par\"\n", + "# ds.parfile = aroot + \"/LMGO_pseudo_cubic.par\"\n", "cf_4d = ds.get_cf_4d()\n", "ds.update_colfile_pars( cf_4d )" ] @@ -98,12 +98,20 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ - "\" \".join(cf_4d.titles)" + "ds.phases = ds.get_phases_from_disk()\n", + "ds.phases.unitcells" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "major_phase_str = 'Al'" ] }, { @@ -129,9 +137,8 @@ }, "outputs": [], "source": [ - "# fixme - removing the main phase - could skip this part if there is no main phase\n", - "a = 3.90725\n", - "ucell = ImageD11.unitcell.unitcell( [2*a, 2*a, 2*a, 90, 90, 90], \"P\")\n", + "ucell = ds.phases.unitcells[major_phase_str]\n", + "\n", "ucell.makerings( dsbinedges[-1] )\n", "ucell.lattice_parameters" ] @@ -269,7 +276,8 @@ " return pair\n", "\n", "om = np.linspace( cring.omega.min(), cring.omega.max(), 90 )\n", - "fitline, = ax[1].plot( om, np.zeros_like(om), '-')\n", + "fitlinel, = ax[0].plot( om, np.zeros_like(om), '-')\n", + "fitliner, = ax[1].plot( om, np.zeros_like(om), '-')\n", "\n", "### GLOBALS, also y0\n", "p1 = None # index of first peak in cring\n", @@ -305,7 +313,8 @@ " [ -sj, -cj] ] )\n", " xy = x, y = np.linalg.inv(R).dot( [ yi, yj ] )\n", " ycalc = ImageD11.sinograms.geometry.x_y_y0_omega_to_dty(om, x, y, y0)\n", - " fitline.set_ydata( ycalc )\n", + " fitlinel.set_ydata( ycalc )\n", + " fitliner.set_ydata( ycalc )\n", " peak_ycalc = ImageD11.sinograms.geometry.x_y_y0_omega_to_dty(cring.omega, x, y, y0)\n", " \n", "def onpick( evt ):\n", @@ -523,8 +532,8 @@ "sino, obinedge, ybinedge = np.histogram2d( cring.omega, cring.dty, weights = np.log(cring.sum_intensity),\n", " bins = (np.linspace(ds.obinedges.min(), ds.obinedges.max(), nbins_angle), ds.ybinedges) )\n", "obincen = 0.5*(obinedge[:-1] + obinedge[1:])\n", - "recon = ImageD11.sinograms.roi_iradon.iradon( sino.T, obincen, filter_name='shepp-logan', \n", - " workers=ImageD11.cImageD11.cores_available())" + "recon = ImageD11.sinograms.roi_iradon.run_iradon(sino.T, obincen, filter_name='shepp-logan', \n", + " workers=ImageD11.cImageD11.cores_available(), shift=-y0/ds.ystep, pad=0)" ] }, { @@ -557,10 +566,10 @@ " if evt.inaxes == ax[1]:\n", " y = evt.xdata\n", " x = evt.ydata\n", - " ycalc = ImageD11.sinograms.geometry.dtycalc( om, x, y, 0 )\n", + " ycalc = ImageD11.sinograms.geometry.dtycalc( om, x, y, y0 )\n", " global ycalcall, pos\n", " pos = y,x\n", - " ycalcall = ImageD11.sinograms.geometry.dtycalc( cring.omega, x, y, 0 )\n", + " ycalcall = ImageD11.sinograms.geometry.dtycalc( cring.omega, x, y, y0 )\n", " fitline1.set_ydata( ycalc + 1 )\n", " fitline2.set_ydata( ycalc - 1 )\n", " location.set_xdata( [y,] )\n", @@ -664,6 +673,8 @@ "for c in cells:\n", " plt.plot( c.ringds, np.full( len(c.ringds), o) ,\"|\", ms=10, lw =.1, label=(\"%.4f \"*6)%tuple(c.lattice_parameters) )\n", " o *= 2\n", + "o *= 2\n", + "plt.plot( ucell.ringds, np.full( len(ucell.ringds), o) ,\"|\", ms=10, lw =.1, label=(\"%.4f \"*6)%tuple(ucell.lattice_parameters) )\n", "plt.semilogy()\n", "plt.xlim(0.1,0.6)\n", "plt.legend(loc='upper left');"