diff --git a/ImageD11/nbGui/S3DXRD/4_visualise.ipynb b/ImageD11/nbGui/S3DXRD/4_visualise.ipynb index 82e24d51..6511fa53 100755 --- a/ImageD11/nbGui/S3DXRD/4_visualise.ipynb +++ b/ImageD11/nbGui/S3DXRD/4_visualise.ipynb @@ -290,10 +290,10 @@ }, "outputs": [], "source": [ - "# look at unit cells\n", + "# look at unit cells - mean of a, b, c for cubic for now\n", "\n", "fig, ax = plt.subplots()\n", - "ax.hist(tmap.unitcell[0, :, :, :3].ravel(), bins=1000)\n", + "ax.hist(tmap.unitcell[0, :, :, :3].mean(axis=-1).ravel(), bins=1000)\n", "ax.set_xlabel('unitcell of pixel')\n", "plt.show()" ] diff --git a/ImageD11/nbGui/S3DXRD/tomo_3_refinement_minor_phase.ipynb b/ImageD11/nbGui/S3DXRD/tomo_3_refinement_minor_phase.ipynb index fb074f13..18d94346 100755 --- a/ImageD11/nbGui/S3DXRD/tomo_3_refinement_minor_phase.ipynb +++ b/ImageD11/nbGui/S3DXRD/tomo_3_refinement_minor_phase.ipynb @@ -564,6 +564,11 @@ "\n", " refine = PBPRefine(dset=ds, y0=y0, fpks=fpks, hkl_tol_origins=hkl_tol_origins, hkl_tol_refine=hkl_tol_refine, hkl_tol_refine_merged=hkl_tol_refine_merged, ds_tol=ds_tol, ifrac=ifrac, phase_name=minor_phase_str, forref=forref)\n", " \n", + " refine.own_filename = os.path.splitext(refine.own_filename)[0] + f'_{phase_str}.h5'\n", + " refine.icolf_filename = os.path.splitext(refine.icolf_filename)[0] + f'_{phase_str}.h5'\n", + " refine.pbpmap_filename = os.path.splitext(refine.pbpmap_filename)[0] + f'_{phase_str}.h5'\n", + " refine.refinedmap_filename = os.path.splitext(refine.refinedmap_filename)[0] + f'_{phase_str}.h5'\n", + " \n", " refine.setmap(pmap)\n", " refine.setpeaks(cf_2d)\n", " refine.mask = pmap.best_npks > 0\n", diff --git a/ImageD11/nbGui/calibration/silicon_calib.ipynb b/ImageD11/nbGui/calibration/silicon_calib.ipynb index e8d7b1d2..c57b1337 100755 --- a/ImageD11/nbGui/calibration/silicon_calib.ipynb +++ b/ImageD11/nbGui/calibration/silicon_calib.ipynb @@ -39,7 +39,8 @@ "import ImageD11.columnfile\n", "import ImageD11.indexing\n", "import ImageD11.grain\n", - "import ImageD11.nbGui.fit_geometry" + "import ImageD11.nbGui.fit_geometry\n", + "import silx.io" ] }, { @@ -154,7 +155,7 @@ "source": [ "# guess the detector distance in um\n", "# you can also manually specify\n", - "distance_guess = auto_guess_distance(ds.masterfile, ds.scans[-1]) # detector distance in um\n", + "distance_guess = auto_guess_distance(dset.masterfile, dset.scans[-1]) # detector distance in um\n", "# distance_guess = 140000 # 140 mm" ] }, @@ -220,22 +221,6 @@ "ui.fitGui()" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "ui.valuewidgets['fit_tolerance'].value = 0.5\n", - "ui.fit(2,9)\n", - "ui.valuewidgets['fit_tolerance'].value = 0.05\n", - "ui.fit(3,21)\n", - "ui.fit(0,180)\n", - "ui.updateGui()" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/ImageD11/sinograms/point_by_point.py b/ImageD11/sinograms/point_by_point.py index 28bdd374..a97e55f6 100644 --- a/ImageD11/sinograms/point_by_point.py +++ b/ImageD11/sinograms/point_by_point.py @@ -628,6 +628,7 @@ def __init__(self, ifrac=None, forref=None, y0=0.0, + min_grain_npks=6 ): self.dset = dset self.phase_name = phase_name @@ -647,6 +648,7 @@ def __init__(self, # refinement parameters self.hkl_tol_refine = hkl_tol_refine self.hkl_tol_refine_merged = hkl_tol_refine_merged + self.min_grain_npks = min_grain_npks # geometry stuff self.ystep = self.dset.ystep self.y0 = y0 @@ -961,7 +963,7 @@ def to_h5(self, filename=None, h5group='PBPRefine'): # other pars we need for refinement pars = ['phase_name', 'hkl_tol_origins', 'hkl_tol_refine', 'hkl_tol_refine_merged', 'fpks', 'ds_tol', - 'etacut', 'ifrac', 'forref', 'y0'] + 'etacut', 'ifrac', 'forref', 'y0', 'min_grain_npks'] for par in pars: try: @@ -974,6 +976,7 @@ def to_h5(self, filename=None, h5group='PBPRefine'): def from_h5(cls, filename, h5group='PBPRefine'): # load the stuff in # then make an object + manager_filename = filename with h5py.File(filename, "r") as hin: parent_group = hin[h5group] @@ -997,7 +1000,7 @@ def from_h5(cls, filename, h5group='PBPRefine'): continue pars = ['phase_name', 'hkl_tol_origins', 'hkl_tol_refine', 'hkl_tol_refine_merged', 'fpks', 'ds_tol', - 'etacut', 'ifrac', 'forref', 'y0'] + 'etacut', 'ifrac', 'forref', 'y0', 'min_grain_npks'] pars_dict = {} for par in pars: try: @@ -1007,6 +1010,7 @@ def from_h5(cls, filename, h5group='PBPRefine'): # load the dataset dset = ImageD11.sinograms.dataset.load(dsfile) refine_obj = cls(dset=dset, **pars_dict) + refine_obj.own_filename = manager_filename for filename_attr, filename in filenames.items(): setattr(refine_obj, filename_attr, filename) for array_attr, array in arrays.items(): @@ -1030,7 +1034,6 @@ def from_h5(cls, filename, h5group='PBPRefine'): refine_obj.loadmap(refine_obj.refinedmap_filename, refined=True) except (AttributeError, OSError): pass - return refine_obj def get_origins(self, guess_speed=True, guess_npks=10000, save_peaks_after=True): @@ -1168,7 +1171,8 @@ def run_refine(self, points_step_space=None, npoints=None, output_filename=None, pars['chi'], pars['wavelength'], tol=self.hkl_tol_refine, - merge_tol=self.hkl_tol_refine_merged + merge_tol=self.hkl_tol_refine_merged, + min_grain_npks=int(self.min_grain_npks) ) # now we match how the indexer returns dodgy values # mask nan 3x3 entires to identity matrix