Beispiel #1
0
    def parse_params(self):
        p = u.Param()
        p.scan = u.Param()
        p.scan.data = u.Param()
        p.scan.data.center = self.parameters['data_center']
        p.scan.data.orientation = self.parameters['data_orientation']
        p.scan.data.auto_center = self.parameters['data_auto_center']
        p.scan.illumination = u.Param()
        p.scan.illumination.photons = self.parameters['illumination_photons']
        p.scan.illumination.diversity = u.Param()
        p.scan.illumination.diversity.noise = self.parameters[
            'illumination_diversity_noise']
        p.scan.illumination.diversity.power = self.parameters[
            'illumination_diversity_power']
        p.scan.illumination.diversity.shift = self.parameters[
            'illumination_diversity_shift']
        p.scan.sample = u.Param()
        p.scan.sample.model = self.parameters['sample_model']
        p.scan.sample.fill = self.parameters['sample_fill']
        p.scan.sample.recon = u.Param()
        p.scan.sample.diversity = u.Param()
        p.scan.sample.diversity.noise = self.parameters[
            'sample_diversity_noise']
        p.scan.sample.diversity.power = self.parameters[
            'sample_diversity_power']
        p.scan.sample.diversity.shift = self.parameters[
            'sample_diversity_shift']
        p.scan.coherence = u.Param()
        p.scan.coherence.num_probe_modes = self.parameters[
            'coherence_num_probe_modes']
        p.scan.coherence.num_object_modes = self.parameters[
            'coherence_num_object_modes']
        p.scan.coherence.spectrum = self.parameters['coherence_spectrum']
        p.scan.coherence.object_dispersion = self.parameters[
            'coherence_object_dispersion']
        p.scan.coherence.probe_dispersion = self.parameters[
            'coherence_probe_dispersion']
        p.scan.geometry = u.Param()
        p.scan.geometry.shape = self.parameters['geometry_shape']
        p.engine = u.Param()
        p.engine.common = u.Param()
        p.engine.common.probe_support = self.parameters['common_probe_support']
        p.engine.common.clip_object = self.parameters[
            'common_clip_object']  #     turn off all of the output things
        p.io = u.Param()
        p.io.home = "./"  ## (05) Base directory for all I/O
        p.io.rfile = False  ## (06) Reconstruction file name (or format string)
        p.io.autosave = u.Param()
        p.io.autosave.active = False  ## (08) Activation switch
        p.io.autosave.interval = -1  ## (09) Auto-save interval
        # p.io.autosave.rfile = "dumps/%(run)s/%(run)s_%(engine)s_%(iterations)04d.ptyr" ## (10) Auto-save file name (or format string)
        ## (11) Server / Client parameters
        p.io.interaction = u.Param()
        p.io.interaction.active = True
        p.io.autoplot = u.Param()
        p.io.autoplot.imfile = "./"  ## (17) Plot images file name (or format string)
        p.io.autoplot.interval = 5  ## (18) Number of iterations between plot updates
        p.io.autoplot.threaded = True  ## (19) Live plotting switch
        p.io.autoplot.layout = u.Param(
        )  ## (20) Options for default plotter or template name
        p.io.autoplot.dump = False  ## (21) Switch to dump plots as image files
        p.io.autoplot.make_movie = False
        if self.parameters['DM_num_iter'] is not None:
            p.engine.DM = u.Param()
            p.engine.DM.name = "DM"
            p.engine.DM.alpha = self.parameters['DM_alpha']
            p.engine.DM.probe_update_start = self.parameters[
                'DM_probe_update_start']
            p.engine.DM.update_object_first = self.parameters[
                'DM_update_object_first']
            p.engine.DM.overlap_converge_factor = self.parameters[
                'DM_overlap_converge_factor']
            p.engine.DM.overlap_max_iterations = self.parameters[
                'DM_overlap_max_iterations']
            p.engine.DM.probe_inertia = self.parameters['DM_probe_inertia']
            p.engine.DM.object_inertia = self.parameters['DM_object_inertia']
            p.engine.DM.fourier_relax_factor = self.parameters[
                'DM_fourier_relax_factor']
            p.engine.DM.obj_smooth_std = self.parameters['DM_obj_smooth_std']
            p.engines = u.Param()
            p.engines.engine_00 = u.Param()
            p.engines.engine_00.name = 'DM'
            p.engines.engine_00.numiter = self.parameters['DM_num_iter']
        if self.parameters['ML_num_iter'] is not None:
            p.engine.ML = u.Param()
            p.engine.ML.name = "ML"
            p.engine.ML.type = self.parameters['ML_type']
            p.engine.ML.floating_intensities = self.parameters[
                'ML_floating_intensities']
            p.engine.ML.intensity_renormalization = self.parameters[
                'ML_intensity_renormalization']
            p.engine.ML.reg_del2 = self.parameters['ML_reg_del2']
            p.engine.ML.reg_del2_amplitude = self.parameters[
                'ML_reg_del2_amplitude']
            p.engine.ML.smooth_gradient = self.parameters['ML_smooth_gradient']
            p.engine.ML.scale_precond = self.parameters['ML_scale_precond']
            p.engine.ML.scale_probe_object = self.parameters[
                'ML_scale_probe_object']
            p.engine.ML.probe_update_start = self.parameters[
                'ML_probe_update_start']  #             p.engines = u.Param()
            p.engines.engine_01 = u.Param()
            p.engines.engine_01.name = 'ML'
            p.engines.engine_01.numiter = self.parameters['ML_num_iter']
        p.scans = u.Param()
        p.scans.savu = u.Param()
        p.scans.savu.if_conflict_use_meta = True
        p.scans.savu.data = u.Param()
        p.scans.savu.data.source = 'savu'
        p.scans.savu.data.dfile = None
        p.scans.savu.data.shape = self.parameters['geometry_shape']
        p.scans.savu.data.save = None
        p.ipython_kernel = False
        r = u.Param()
        r.positions = self.get_positions(
        ).T  ### this stuff can come out of the nexus file
        p.scans.savu.data.psize = 55e-6
        p.scans.savu.data.distance = 1.59
        p.scans.savu.data.orientation = 2
        p.scans.savu.data.energy = 9.1
        p.scan.illumination = u.Param()
        p.scan.illumination.model = None
        p.scan.illumination.photons = 1e8
        p.scan.illumination.aperture = u.Param()
        p.scan.illumination.aperture.form = "circ"
        p.scan.illumination.aperture.size = 400e-6
        p.scan.illumination.propagation = u.Param()
        p.scan.illumination.propagation.focussed = 440.5e-3
        p.scan.illumination.propagation.parallel = 2.3e-3
        r.mask = np.ones((p.scans.savu.data.shape, p.scans.savu.data.shape))
        #         probe_size = tuple(u.expect2(p.scan.geometry.shape)) + (p.scan.coherence.num_probe_modes, )

        #         self.set_size_probe(probe_size)
        return p, r
Beispiel #2
0
    def _initialize(self, pars=None, **kwargs):
        # Starting parameters
        p = u.Param(DEFAULT)
        if pars is not None:
            p.update(pars)
        for k, v in kwargs.iteritems():
            if p.has_key(k): p[k] = v

        self.p = p
        self.interact = False

        # set distance
        if self.p.z is None or self.p.z == 0:
            raise ValueError('Distance (geometry.z) must not be None or 0')

        # set frame shape
        if self.p.N is None or (np.array(self.p.N) == 0).any():
            raise ValueError('Frame size (geometry.N) must not be None or 0')
        else:
            self.p.N = u.expect2(p.N)

        # Set energy and wavelength
        if p.energy is None:
            if p.lam is None:
                raise ValueError(
                    'Wavelength (geometry.lam) and energy (geometry.energy)\n must not both be None'
                )
            else:
                self.lam = p.lam  # also sets energy
        else:
            if p.lam is not None:
                logger.debug(
                    'Energy and wavelength both specified. Energy takes precedence over wavelength'
                )

            self.energy = p.energy

        # set initial geometrical misfit to 0
        self.p.misfit = u.expect2(0.)

        # Pixel size
        self.p.psize_det_is_fix = p.psize_det is not None
        self.p.psize_sam_is_fix = p.psize_sam is not None

        if not self.p.psize_det_is_fix and not self.p.psize_sam_is_fix:
            raise ValueError(
                'Pixel size in sample plane (geometry.psize_sam) and detector plane \n(geometry.psize_det) must not both be None'
            )

        # fill pixel sizes
        self.p.psize_sam = u.expect2(
            p.psize_sam) if self.p.psize_sam_is_fix else u.expect2(1.0)
        self.p.psize_det = u.expect2(
            p.psize_det) if self.p.psize_det_is_fix else u.expect2(1.0)

        # update other values
        self.update(False)

        # attach propagator
        self._propagator = self._get_propagator()
        self.interact = True
import sys
import numpy as np
import ptypy
from ptypy.core import Ptycho
from ptypy import utils as u
from distutils.version import LooseVersion

## simplest possible input #############################################
detector = 'pilatus'  # or 'merlin' or 'pilatus'
folder = '/data/staff/nanomax/commissioning_2020-1/20200130/raw/sample'
scannr = int(sys.argv[1])
distance = 4.05
########################################################################

# General parameters
p = u.Param()
p.verbose_level = 3
p.run = 'scan%d' % scannr

# Scan parameters
p.scans = u.Param()
p.scans.scan00 = u.Param()
p.scans.scan00.name = 'Full'
p.scans.scan00.data = u.Param()
p.scans.scan00.coherence = u.Param()
p.scans.scan00.coherence.num_probe_modes = 5
p.scans.scan00.data.name = 'NanomaxContrast'
p.scans.scan00.data.path = folder
p.scans.scan00.data.detector = detector
p.scans.scan00.data.maskfile = {
    'merlin': '/data/visitors/nanomax/common/masks/merlin/latest.h5',
Beispiel #4
0
* fix the 0002 calulation pf strain. should be ~5.93E-10m

# Want to know the change of Q in reciprocal space, that is, the orthogonal space reciprocal to real space.
# use ptypy coordinate shifting systems to shift the data from skewed to orthogonal reciprocal space

"""
import ptypy
from ptypy.core import Ptycho
from ptypy import utils as u
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from ptypy.experiment.nanomax3d import NanomaxBraggMarch2019  # after update need to update spec ptyScan class

p = u.Param()
p.run = 'XRD_LCBP31_AB'
##############323 is OK
sample = 'LCBP31_AB'
#scans = [244,245,283]
# Whole set of scans. no multiples only the better one of the doublets
scans = np.arange(244,324+1).tolist() + np.arange(326,329+1).tolist() + \
        np.arange(331,333+1).tolist() + np.arange(335,339+1).tolist() + \
        np.arange(340,343+1).tolist()

p.verbose_level = 5

# use special plot layout for 3d data  (but the io.home part tells ptypy where to save recons and dumps)
p.io = u.Param()
p.io.home = './'
p.io.autoplot = u.Param()
Beispiel #5
0
    # for in package use #####
    from .. import utils as u
    from ..utils.verbose import logger
    from classes import Base, GEO_PREFIX

import numpy as np

__all__ = ['Geo']

DEFAULT = u.Param(
    energy=7.2,  # Incident photon energy (in keV)
    lam=None,  # Wavelength (in meters)
    z=2.19,  # Distance from object to screen 
    psize_det=172e-6,  # Pixel size (in meters) at detector plane
    psize_sam=None,  # Pixel sixe (in meters) at sample plane  
    N=220,  # Number of detector pixels
    #rebin = 1,                   # Rebinning (!! not implemented)
    prop_type='farfield',  # propagation type 
    #antialiasing = 2             # use antialiasing when generating diffraction
    misfit=0,
    origin_det='fftshift',
    origin_sam='fftshift',
)


class Geo(Base):
    """
    Interactive Geometry class! Bam!
    switch resolution, shape etc.
    and provide the propagator too.
    """
import ptypy
from ptypy.core import Ptycho
from ptypy import utils as u
from distutils.version import LooseVersion

## simplest possible input #############################################
detector   = 'eiger' # or 'merlin' or 'pilatus'
folder     = '../../raw/sample'
distance_m = 3.512	# distance between the sample and the detector in meters
defocus_um = 600	# distance between the focus and the sample plane in micro meters -> used for inital probe
scannr     = int(sys.argv[1])
########################################################################


# General parameters
p = u.Param()
p.verbose_level = 3
p.run = 'scan%d' % scannr
p.io = u.Param()
p.io.rfile = 'recons/%(run)s_%(engine)s.ptyr'
p.io.autoplot = u.Param()
p.io.autoplot.active = False

# Scan parameters
p.scans = u.Param()
p.scans.scan00 = u.Param()
p.scans.scan00.name = 'Full'
p.scans.scan00.coherence = u.Param()
p.scans.scan00.coherence.num_probe_modes = 1		# Number of probe modes

p.scans.scan00.data = u.Param()
from matplotlib import pyplot as plt
from ptypy import utils as u
from ptypy import *
import numpy as np
from pyE17 import utils as U
import os
import subprocess
import sys
import time
"""
import ptypy
from ptypy.core import Ptycho
from ptypy import utils as u
import ptypy.simulations as sim
import numpy as np
p = u.Param()


def RGB_to_HSV(rgb):
    eps = 1e-6
    rgb = np.asarray(rgb).astype(float)
    maxc = rgb.max(axis=-1)
    minc = rgb.min(axis=-1)
    v = maxc
    s = (maxc - minc) / maxc
    s[maxc == 0.0] = 0.0
    rc = (maxc - rgb[:, :, 0]) / (maxc - minc + eps)
    gc = (maxc - rgb[:, :, 1]) / (maxc - minc + eps)
    bc = (maxc - rgb[:, :, 2]) / (maxc - minc + eps)

    h = 4.0 + gc - rc
Beispiel #8
0
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 13 2013

@author: benders
"""
################ LOAD MODULES ##########################################
from pyE17 import utils as U
import ptypy
from ptypy import utils as u
import sys
import numpy as np
import os
########################################################################
p = u.Param()
##### GENERAL ####################################################
#plt.interactive(True)
#verbose.set_level(3)
p.base_path = '/data/CDI/simulations/test'
##### PARAMETER INPUT ##################################################
# Please also define here what additional parameter means what
# As a default all parameters will form the simulation ID
# First parameter is ALWAYS understood as stack index and will not be part of an id.
pyfile = os.path.basename(sys.argv[0])
pars = []
if len(sys.argv) > 1:
    pars += sys.argv[1:]
    index_string = pars.pop(0)
"""
Use pars[ind] to pass changes through the script
Example:
Beispiel #9
0
Want to know the change of Q in reciprocal space, that is, the orthogoanl space reciprocal to real space.

# XRD analysis: use ptypy coordinate shifting systems to shift the data 

"""
import ptypy
from ptypy.core import Ptycho
from ptypy.core.classes import Container, Storage, View
from ptypy import utils as u
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from ptypy.experiment.nanomax3d import NanomaxBraggJune2017  # after update need to update spec ptyScan class
from matplotlib import ticker

p = u.Param()
p.run = 'XRD_29A_inP_realprobe'  # 'XRD_InP'

#sample = 'JWX33_NW2'; scans = range(192, 200+1)+range(205, 222+1) #range(192, 195)#
#sample = 'JWX29A_NW1'; scans = [483,484,485] # ~~central rotations
sample = 'JWX29A_NW1'
scans = [
    458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 518,
    473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 519,
    488, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
    510, 511, 512, 513, 514, 515
]
# new scan list with few scans removed to increase roi
scans = [
    458, 463, 464, 466, 467, 468, 469, 470, 471, 518, 473, 474, 475, 476, 477,
    478, 479, 480, 481, 482, 483, 484, 485, 486, 519, 488, 496, 497, 498, 499,
Beispiel #10
0
import numpy as np
import os
import time

from ptypy import utils as u
import ptypy
from detector import Detector, conv
from ptysim_utils import *

DEFAULT = u.Param(
    pos_noise=
    1e-10,  # (float) unformly distributed noise in xy experimental positions
    pos_scale=
    0,  # (float, list) amplifier for noise. Will be extended to match number of positions. Maybe used to only put nois on individual points  
    pos_drift=
    0,  # (float, list) drift or offset paramter. Noise independent drift. Will be extended like pos_scale.
    detector='PILATUS_300K',
    frame_size=
    None,  # (None, or float, 2-tuple) final frame size when saving if None, no cropping/padding happens
    psf=
    None,  # (None or float, 2-tuple, array) Parameters for gaussian convolution or convolution kernel after propagation
    # use it for simulating partial coherence
)

__all__ = ['simulate_basic_with_pods']


def simulate_basic_with_pods(ptypy_pars_tree=None, sim_pars=None, save=False):
    """
    Basic Simulation
    """
    p = DEFAULT.copy()
Beispiel #11
0
import sys
import os

# for solo use ##########
if __name__ == "__main__":
    from ptypy import utils as u
    from ptypy.utils.verbose import logger

else:
    # for in package use #####
    from .. import utils as u
    from ..utils.verbose import logger

__all__ = ['Paths']

DEFAULT = u.Param()
DEFAULT.base_dir = "./"  # (03) Relative base path for all other paths
DEFAULT.run = None  # (04) Name of reconstruction run
DEFAULT.plot_dir = "plots/%(run)s/"  # (06) directory to dump plot images
DEFAULT.plot_file = "%(run)s_%(engine)s_%(iteration)04d.png"  # (07) filename for dumping plots
DEFAULT.plot_interval = 2  # (08) iteration interval for dumping plots
DEFAULT.save_dir = "recons/%(run)s/"  # (10) directory to save final reconstruction
DEFAULT.save_file = "test.pty"  #"%(run)s_%(algorithm)s_%(it)04d.h5"# (11) filename for saving
DEFAULT.dump_dir = "dumps/%(run)s/"  # (12) directory to save intermediate results
DEFAULT.dump_file = "%(run)s_%(engine)s_%(iteration)04d.pty"  # (13)
DEFAULT.data_dir = "analysis/%(run)s/"
DEFAULT.data_file = "%(label)s.h5"
# runtime parameters
DEFAULT.engine = "Dummy"
DEFAULT.iteration = 0
DEFAULT.args = ""
Beispiel #12
0
    def prepare(self, scan=None, filename=None, dtype=np.uint32, **kwargs):

        self.p.update(
            kwargs)  #rebin = rebin if rebin is not None else self.p.rebin

        scan = scan if scan is not None else self.p.scan

        self.read(scan, **kwargs)
        DS = u.Param()

        dark = self.dark
        data = self.data
        if dark is not None:
            if dark.ndim == 3:
                dark = dark.mean(0)
            dark = np.resize(dark, data.shape)

        flat = self.flat
        if flat is not None:
            if flat.ndim == 3:
                flat = flat.mean(0)
            flat = np.resize(flat, self.data.shape)
        #plt.ion();
        #plt.figure();plt.imshow(dark[0]);plt.colorbar()
        #plt.figure();plt.imshow((flat-dark)[0]);plt.colorbar()
        #plt.figure();plt.imshow(data[0]);plt.colorbar()
        if flat is not None and dark is not None:
            data = (data - dark) / (flat - dark)
        elif dark is not None:
            data = data - dark
        else:
            data = data
        # remove negative values
        data[data < 0] = 0
        #
        #plt.figure();plt.imshow(DS.data[0],vmin=0);plt.colorbar()
        #
        if self.mask is None:
            mask = np.ones_like(data, dtype=np.bool)
        #
        #DS.flat = self.flat
        #DS.dark = self.dark
        DS.scan_info = u.Param()
        s = DS.scan_info
        p = self.p
        #s.scan_number = p.scan_number
        s.scan_label = 'S' + self.label  #'S%05d' % p.scan_number
        s.data_filename = self.scan  #scandict['data_filename']
        s.wavelength = u.keV2m(p.energy)
        s.energy = p.energy
        rebin = self.p.rebin
        s.detector_pixel_size = p.detector_pixel_size * rebin if p.detector_pixel_size is not None else None
        p.dpsize = p.dpsize / rebin
        s.detector_distance = p.detector_distance
        s.initial_ctr = self.ctr / rebin
        if rebin != 1:
            sh = data.shape
            data = u.rebin(data, sh[0], sh[1] / rebin, sh[2] / rebin)
            mask = u.rebin(mask.astype(int), sh[0], sh[1] / rebin,
                           sh[2] / rebin).astype(bool)

        data = flip(data, self.p.flip)
        mask = flip(mask, self.p.flip)

        DS.data = data.astype(dtype)
        DS.mask = mask
        DS.data[np.invert(DS.mask)] = 0
        #s.date_collected = scandict['date']
        s.date_processed = time.asctime()
        s.exposure_time = self.exp

        #if meta is not None: s.raw_filenames = meta['filename']
        s.preparation_basepath = self.base_path
        s.preparation_other = {}
        s.shape = DS.data.shape

        s.positions_theory = None

        s.scan_command = self.command

        motors = p.motors
        if self.motors is not None:
            Nmotors = len(motors)
            logger.debug('Motors are : %s' % str(p.motors))
            mmult = u.expect2(p.motors_multiplier)

            pos_list = [
                mmult[i] * np.array(self.motors[motors[i]])
                for i in range(Nmotors)
            ]
            s.positions = np.array(pos_list).T
        else:
            s.positions = None

        self.p.scan_label = s.scan_label
        if filename is None:
            p.write_path = WRITE_PATH_PATTERN.format(**p)
            filename = SAVE_FILENAME_PATTERN.format(**p)

        s.data_filename = u.clean_path(filename)
        io.h5write(filename, DS)
        return DS
Beispiel #13
0
    def __init__(
        self,
        pars=None
    ):  #base_path, experimentID=None, mask=None, flat=None, dark=None):
        """\
        I13 DLS data reading class. The only mendatory argument for this constructor are 'base_path' and 'user'. 
        
        Mask, flat or dark should be either None, scan numbers (interger) or file paths
        """
        # Semi-smart base path detection: we are looking for a "raw" directory
        p = u.Param(DEFAULT)
        if pars is not None:
            p.update(pars)

        try:
            verbose_level = p.verbose_level
            verbose.set_level(verbose_level)
        except:
            pass
        self.p = p
        base_path = p.base_path if p.base_path.endswith(
            '/') else p.base_path + '/'
        experimentID = p.experimentID

        if base_path is None:
            d = os.getcwd()
            while True:
                if 'raw' in os.listdir(d):
                    base_path = d
                    break
                d, rest = os.path.split(d)
                if not rest:
                    break
            if base_path is None:
                raise RuntimeError('Could not figure out base_path')
            logger.debug('base_path: "%s" (automatically set).' % base_path)
        else:
            logger.debug('base_path: "%s".' % base_path)
        self.base_path = base_path

        self.nxs = u.Param()
        self.nxs.frame = FRAME_IN_NEXUS_FILE.format(**p)
        self.nxs.exp = EXPOSURE_IN_NEXUS_FILE.format(**p)
        self.nxs.motors = MOTORS_IN_NEXUS_FILE.format(**p)
        self.nxs.command = COMMAND_IN_NEXUS_FILE.format(**p)
        self.nxs.experiment = EXPERIMENT_IN_NEXUS_FILE.format(**p)
        self.nxs.label = LABEL_IN_NEXUS_FILE.format(**p)
        # Load mask, flat and dark

        try:
            self.mask = load(self.get_nexus_file(p.mask), self.nxs.frame)
        except:
            self.mask = p.mask
            #assert self.mask.shape[-2:] == sh

        try:
            self.dark = load(self.get_nexus_file(p.dark), self.nxs.frame)
        except:
            self.dark = p.dark
            #assert self.dark.shape[-2:] == sh

        try:
            self.flat = load(self.get_nexus_file(p.flat), self.nxs.frame)
        except:
            self.flat = p.flat
Beispiel #14
0
EXPERIMENT_IN_NEXUS_FILE = 'entry1/experiment_identifier'
#FILENAME_PATTERN = '{read_path}/{index}.{file_extension}'
#INDEX_REPLACEMENT_STRING = '????'

# Standard parameter stucture for prepare_data
DEFAULT = u.Param(
    verbose_level=2,  # Verbosity level 
    base_path=
    None,  #'The root directory where all experiment information can be found'
    detector_name=None,  # That is the name of the detector in the nexus file
    experimentID=None,  #'Experiment identifier' 
    scan=None,  #'Scan number' or file
    dpsize=None,  #'Cropped array size for one frame'
    ctr=None,  #'Center of the diffraction pattern.'
    energy=None,  #'Nominal Radiation energy in keV'
    detector_pixel_size=None,  #'Detector pixel size in meters'
    detector_distance=None,  #'Detector distance to sample in meters'
    motors=['t1_sy',
            't1_sx'],  #'Motor names to determine the sample translation'
    motors_multiplier=1e-6,  #'Motor conversion factor to meters'
    mask=None,  #'Mask or name or number of the file containing the mask'
    dark=None,  #'Dark frame or name or number of the file containing the dark'
    flat=None,  #'Flat frame or name of number the file containing the flat'
    flip=None,  #None, 'lr','ud'
    rebin=1,
    rotate=False,
)


def flip(A, what):
    if what is None:
        return A
Beispiel #15
0
from matplotlib import pyplot as plt
from ptypy import utils as u
from ptypy import *
import numpy as np
from pyE17 import utils as U
import os
import subprocess
import sys
import time
"""
import ptypy
from ptypy.core import Ptycho
from ptypy import utils as u
import ptypy.simulations as sim
import numpy as np
p = u.Param()

### PTYCHO PARAMETERS
p.verbose_level = 3  # (00) Verbosity level

p.data_type = "single"  # (01) Reconstruction floatine number precision

p.paths = u.Param()
p.paths.base_dir = "./"  # (03) Relative base path for all other paths
p.paths.run = None  # (04) Name of reconstruction run
p.paths.data_dir = "analysis/%(run)s/"  # (05) directory where diffraction data is stored
p.paths.data_file = "%(label)s.ptyd"
p.paths.plot_dir = "plots/%(run)s/"  # (06) directory to dump plot images
p.paths.plot_file = "%(run)s_%(engine)s_%(iterations)04d.png"  # (07) filename for dumping plots
p.paths.plot_interval = 2  # (08) iteration interval for dumping plots
p.paths.save_dir = "recons/%(run)s/"  # (09) directory to save final reconstruction
"""
import ptypy
from ptypy.core import Ptycho
from ptypy import utils as u
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
#from ptypy.experiment.nanomax3d import NanomaxBraggJune2017 # after update need to update spec ptyScan class
from ptypy.experiment.I13_Bragg3d import I13Bragg3d # after update need to update spec ptyScan class

# TODO
# if InP
#       choose InP roi and change name

p = u.Param()
p.run = 'I13Bragg3d'   # 'XRD_InP'

sample = 'name'; scans = [155248, 155249] #range(192, 200+1)+range(205, 222+1)
#sample = 'JWX29A_NW1' #; scans =[458,459]
#scans = [458,459,460,461,462,463,464,465,466,467,468,469,470,471,518,473,474,475,476,477,478,479,480,481,482,483,484,485,486,519,488, 496,497,498, 499, 500, 501, 502, 503, 504, 505, 506,507, 508, 509, 510, 511, 512, 513, 514, 515]

p.data_type = "single"   #or "double"
# for verbose output
p.verbose_level = 5

# use special plot layout for 3d data  (but the io.home part tells ptypy where to save recons and dumps)
p.io = u.Param()
p.io.home = './'
p.io.autosave = u.Param()
p.io.autosave.interval = 1 # does not work