def allocate_measurement(self, grid: Grid, wavelength: float, scan: AbstractScan) -> Measurement: inner, outer, nbins_radial, nbins_azimuthal = self._get_bins( grid.antialiased_sampling, wavelength) shape = scan.shape calibrations = scan.calibrations if nbins_radial > 1: shape += (nbins_radial, ) calibrations += (Calibration(offset=inner, sampling=self._radial_steps, units='mrad'), ) if nbins_azimuthal > 1: shape += (nbins_azimuthal, ) calibrations += (Calibration(offset=0, sampling=self._azimuthal_steps, units='rad'), ) array = np.zeros(shape, dtype=np.float32) measurement = Measurement(array, calibrations=calibrations) if isinstance(self.save_file, str): measurement = measurement.write(self.save_file) return measurement
def calibrations(self) -> tuple: return (Calibration(offset=0, sampling=self.sampling[0], units='Å', name='x'), Calibration(offset=0, sampling=self.sampling[1], units='Å', name='y'))
def calibrations(self) -> tuple: return (Calibration(offset=self.start[0], sampling=self.sampling[0], units='Å', name='x', endpoint=self.grid.endpoint[0]), Calibration(offset=self.start[1], sampling=self.sampling[1], units='Å', name='y', endpoint=self.grid.endpoint[1]))
def allocate_measurement(self, waves, scan: AbstractScan = None) -> Measurement: """ Allocate a Measurement object or an hdf5 file. Parameters ---------- waves : Waves object An example of the scan : Scan object The scan object that will define the scan dimensions the measurement. Returns ------- Measurement object or str The allocated measurement or path to hdf5 file with the measurement data. """ waves.grid.check_is_defined() waves.accelerator.check_is_defined() if scan is None: shape = () calibrations = () else: shape = scan.shape calibrations = scan.calibrations nbins_radial, nbins_azimuthal, inner, _ = self._get_bins( min(waves.cutoff_scattering_angles)) if nbins_radial > 1: shape += (nbins_radial, ) calibrations += (Calibration(offset=inner, sampling=self._radial_steps, units='mrad'), ) if nbins_azimuthal > 1: shape += (nbins_azimuthal, ) calibrations += (Calibration(offset=0, sampling=self._azimuthal_steps, units='rad'), ) array = np.zeros(shape, dtype=np.float32) measurement = Measurement(array, calibrations=calibrations) if isinstance(self.save_file, str): measurement = measurement.write(self.save_file) return measurement
def profiles(self, max_semiangle: float = None, phi: float = 0.): if max_semiangle is None: if self._semiangle_cutoff == np.inf: max_semiangle = 50 else: max_semiangle = self._semiangle_cutoff * 1.6 alpha = np.linspace(0, max_semiangle / 1000., 500) aberrations = self.evaluate_aberrations(alpha, phi) aperture = self.evaluate_aperture(alpha) temporal_envelope = self.evaluate_temporal_envelope(alpha) spatial_envelope = self.evaluate_spatial_envelope(alpha, phi) gaussian_envelope = self.evaluate_gaussian_envelope(alpha) envelope = aperture * temporal_envelope * spatial_envelope * gaussian_envelope calibration = Calibration(offset=0., sampling=(alpha[1] - alpha[0]) * 1000., units='mrad', name='alpha') profiles = {} profiles['ctf'] = Measurement(aberrations.imag * envelope, calibrations=[calibration], name='CTF') profiles['aperture'] = Measurement(aperture, calibrations=[calibration], name='Aperture') profiles['temporal_envelope'] = Measurement(temporal_envelope, calibrations=[calibration], name='Temporal') profiles['spatial_envelope'] = Measurement(spatial_envelope, calibrations=[calibration], name='Spatial') profiles['gaussian_spread'] = Measurement(gaussian_envelope, calibrations=[calibration], name='Gaussian') profiles['envelope'] = Measurement(envelope, calibrations=[calibration], name='Envelope') return profiles
def calibrations(self) -> Tuple[Calibration]: return Calibration(offset=0, sampling=self.sampling[0], units='Å', name='x', endpoint=self.grid.endpoint[0]),