diff --git a/CDTools/datasets/ptycho_2d_dataset.py b/CDTools/datasets/ptycho_2d_dataset.py index dc078c3..794d192 100644 --- a/CDTools/datasets/ptycho_2d_dataset.py +++ b/CDTools/datasets/ptycho_2d_dataset.py @@ -188,7 +188,7 @@ class Ptycho2DDataset(CDataset): cdtdata.add_ptycho_translations(cxi_file, self.translations) - def inspect(self, logarithmic=True): + def inspect(self, logarithmic=True, units='um'): """Launches an interactive plot for perusing the data This launches an interactive plotting tool in matplotlib that @@ -257,12 +257,13 @@ class Ptycho2DDataset(CDataset): nanomap_values = (self.mask.to(t.float32) * self.patterns).sum(dim=(1,2)).detach().cpu().numpy() s = calculate_sizes(0) - nanomap = axes[0].scatter(1e6 * translations[:,0],1e6 * translations[:,1],s=s,c=nanomap_values, picker=True) + units_factor = plotting.get_units_factor(units) + nanomap = axes[0].scatter(units_factor * translations[:,0],units_factor * translations[:,1],s=s,c=nanomap_values, picker=True) axes[0].invert_xaxis() axes[0].set_facecolor('k') - axes[0].set_xlabel('Translation x ($\mu$m)', labelpad=1) - axes[0].set_ylabel('Translation y ($\mu$m)', labelpad=1) + axes[0].set_xlabel('Translation x ('+units+')', labelpad=1) + axes[0].set_ylabel('Translation y ('+units+')', labelpad=1) cb1 = plt.colorbar(nanomap, ax=axes[0], orientation='horizontal', format='%.2e', ticks=ticker.LinearLocator(numticks=5), diff --git a/converters/TITAN_stem.py b/converters/TITAN_stem.py new file mode 100644 index 0000000..d5ac537 --- /dev/null +++ b/converters/TITAN_stem.py @@ -0,0 +1,84 @@ +""" +Purpose: Convert file collection from Jim Lebeau's TITAN microscope to .CXI +Author: Abe Levitan +Date: January 2019 +""" + +import numpy as np +import pickle +import h5py +import os +import CDTools +from CDTools.tools import data as cdtdata +from CDTools.datasets import Ptycho2DDataset +from matplotlib import pyplot as plt +from scipy.spatial.transform import Rotation +from datetime import datetime + + +def load_raw_image_stack(filename): + # The resulting data is an array of (exposure, image-i, image-j), + # with image0i corresponding to y and image-j corresponding to x + # Note that the real-space scanning is done from the bottom right + # corner, first heading left (in x) then scanning up. + rawdata = np.fromfile(filename,dtype='