reborn package¶
Subpackages¶
- reborn.analysis package
- Submodules
- reborn.analysis.beam_center module
- reborn.analysis.masking module
- reborn.analysis.optimize module
- reborn.analysis.parallel module
- reborn.analysis.peaks module
- reborn.analysis.runstats module
PixelHistogram
PixelHistogram.count
PixelHistogram.bin_min
PixelHistogram.bin_max
PixelHistogram.n_bins
PixelHistogram.to_dict
PixelHistogram.from_dict
PixelHistogram.concatentate
PixelHistogram.get_bin_centers
PixelHistogram.get_histogram_normalized
PixelHistogram.get_histogram
PixelHistogram.add_frame
PixelHistogram.get_peaks_fast
PixelHistogram.get_average_peak_locations
PixelHistogram.gain_and_offset
PixelHistogram.get_refined_gain_and_offset
PixelHistogram.correct_gain_and_offset
PixelHistogram.convert_to_q_histogram
PixelHistogram.get_median_profile
PixelHistogram.process_framegetter
ParallelPADStats
save_padstats
load_padstats
padstats_framegetter
view_padstats
get_gain_and_offset
- reborn.analysis.saxs module
debug_message
QHistogram
RadialProfiler
RadialProfiler.n_bins
RadialProfiler.q_range
RadialProfiler.q_edge_range
RadialProfiler.bin_centers
RadialProfiler.bin_edges
RadialProfiler.bin_size
RadialProfiler.set_mask
RadialProfiler.set_beam
RadialProfiler.set_pad_geometry
RadialProfiler.q_bin_centers
RadialProfiler.make_plan
RadialProfiler.concat_data
RadialProfiler.get_profile_statistic
RadialProfiler.get_counts_profile
RadialProfiler.get_sum_profile
RadialProfiler.get_mean_profile
RadialProfiler.get_median_profile
RadialProfiler.get_sdev_profile
RadialProfiler.subtract_profile
RadialProfiler.divide_profile
RadialProfiler.subtract_median_profile
RadialProfiler.quickstats
ParallelRadialProfiler
save_profiles
load_profiles
view_profile_runstats
normalize_profile_stats
- reborn.analysis.svd module
- Module contents
- reborn.external package
- Submodules
- reborn.external.cheetah module
- reborn.external.crystfel module
load_crystfel_geometry
geometry_dict_to_pad_geometry_list
fix_cspad_cheetah_indexing
extract_geom_from_stream
geometry_file_to_pad_geometry_list
split_data_block
split_image
unsplit_image
write_geom_file_single_pad
write_geom_file_from_template
convert_to_crystfel_format
write_geom_file_from_pad_geometry_list
readStreamfile_get_total_number_of_frames
readStreamfile_get_nth_frame
StreamfileFrameGetter
- reborn.external.denss module
- reborn.external.euxfel module
- reborn.external.hdf5 module
- reborn.external.lcls module
- reborn.external.pyqt module
- reborn.external.pyqtgraph module
- Module contents
- reborn.fileio package
- Submodules
- reborn.fileio.getters module
do_nothing
threadlocked
FrameGetter
FrameGetter.run_id
FrameGetter.current_frame
FrameGetter.current_random_frame
FrameGetter.current_dataframe
FrameGetter.geom_dict
FrameGetter.history_length
FrameGetter.history
FrameGetter.history_index
FrameGetter.init_params
FrameGetter.skip_empty_frames
FrameGetter.postprocessors
FrameGetter.factory
FrameGetter.n_frames
FrameGetter.dbgmsg
FrameGetter.get_data
FrameGetter.pandas_dataframe
FrameGetter.set_pandas_dataframe
FrameGetter.sort_by
FrameGetter.set_sorted_indices
FrameGetter.is_sorted
FrameGetter.get_frame
FrameGetter.get_history_previous
FrameGetter.get_history_next
FrameGetter.get_next_frame
FrameGetter.get_previous_frame
FrameGetter.get_random_frame
FrameGetter.get_first_frame
FrameGetter.view
FrameGetter.get_padview
ListFrameGetter
TestFrameGetter
- reborn.fileio.misc module
- Module contents
- reborn.gui package
- reborn.misc package
- reborn.simulate package
- Submodules
- reborn.simulate.clcore module
get_all_gpu_devices
create_some_gpu_context
ClCore
ClCore.get_device_name
ClCore.print_device_info
ClCore.set_groupsize
ClCore.double_precision_is_available
ClCore.vec4
ClCore.vec16
ClCore.to_device
ClCore.get_group_size
ClCore.rotate_translate_vectors
ClCore.test_rotate_vec
ClCore.test_simple_sum
ClCore.mod_squared_complex_to_real
ClCore.sphere_form_factor
ClCore.phase_factor_qrf
ClCore.phase_factor_pad
ClCore.phase_factor_mesh
ClCore.buffer_mesh_lookup
ClCore.mesh_interpolation
ClCore.lattice_transform_intensities_pad
ClCore.gaussian_lattice_transform_intensities_pad
ClCore.gaussian_lattice_transform_intensities
ClCore.test_atomic_add_real
ClCore.test_atomic_add_int
ClCore.divide_nonzero_inplace
phase_factor_qrf
print_device_info
help
- reborn.simulate.engines module
- reborn.simulate.examples module
- reborn.simulate.form_factors module
- reborn.simulate.gas module
- reborn.simulate.solutions module
- Module contents
- reborn.target package
- Submodules
- reborn.target.atoms module
atomic_symbols_to_numbers
atomic_numbers_to_symbols
henke_scattering_factors
henke_dispersion_corrections
get_scattering_factors
get_scattering_factors_fixed_z
xraylib_scattering_factors
xraylib_refractive_index
xraylib_scattering_density
hubbel_form_factors
hubbel_henke_scattering_factors
cmann_henke_scattering_factors
cromer_mann_scattering_factors
get_cmann_form_factors
get_cromermann_parameters
get_cromer_mann_densities
- reborn.target.crystal module
get_pdb_file
UnitCell
UnitCell.a
UnitCell.b
UnitCell.c
UnitCell.alpha
UnitCell.beta
UnitCell.gamma
UnitCell.o_mat
UnitCell.o_mat_inv
UnitCell.a_mat
UnitCell.a_mat_inv
UnitCell.volume
UnitCell.r2x
UnitCell.x2r
UnitCell.q2h
UnitCell.h2q
UnitCell.a_vec
UnitCell.b_vec
UnitCell.c_vec
UnitCell.as_vec
UnitCell.bs_vec
UnitCell.cs_vec
SpaceGroup
CrystalStructure
CrystalStructure.mosaicity_fwhm
CrystalStructure.crystal_size
CrystalStructure.crystal_size_fwhm
CrystalStructure.mosaic_domain_size
CrystalStructure.mosaic_domain_size_fwhm
CrystalStructure.cryst1
CrystalStructure.pdb_dict
CrystalStructure.unitcell
CrystalStructure.spacegroup
CrystalStructure.fractional_coordinates
CrystalStructure.molecule
CrystalStructure.x_vecs
CrystalStructure.x
CrystalStructure.get_symmetry_expanded_coordinates
CrystalStructure.set_tight_packing
FiniteLattice
CrystalDensityMap
CrystalDensityMap.sym_luts
CrystalDensityMap.cryst
CrystalDensityMap.oversampling
CrystalDensityMap.dx
CrystalDensityMap.cshape
CrystalDensityMap.shape
CrystalDensityMap.size
CrystalDensityMap.strides
CrystalDensityMap.n_vecs
CrystalDensityMap.x_vecs
CrystalDensityMap.x_limits
CrystalDensityMap.x_min
CrystalDensityMap.x_max
CrystalDensityMap.h_vecs
CrystalDensityMap.h_limits
CrystalDensityMap.h_min
CrystalDensityMap.h_max
CrystalDensityMap.q_vecs
CrystalDensityMap.q_min
CrystalDensityMap.q_max
CrystalDensityMap.get_sym_luts
CrystalDensityMap.au_to_k
CrystalDensityMap.k_to_au
CrystalDensityMap.symmetry_transform
CrystalDensityMap.place_atoms_in_map
CrystalDensityMap.voxel_volume
build_atomic_scattering_density_map
place_atoms_in_map
pdb_to_dict
FiniteCrystal
get_hm_symbols
hermann_mauguin_symbol_from_hall_number
itoc_number_from_hall_number
hall_number_from_hermann_mauguin_symbol
itoc_number_from_hermann_mauguin_symbol
hall_number_from_itoc_number
hermann_mauguin_symbol_from_itoc_number
spacegroup_ops_from_hall_number
get_symmetry_operators_from_hall_number
get_symmetry_operators_from_space_group
- reborn.target.density module
- reborn.target.molecule module
Molecule
Molecule.atomic_numbers
Molecule.n_atoms
Molecule.occupancies
Molecule.coordinates
Molecule.get_scattering_factors
Molecule.max_atomic_pair_distance
Molecule.get_size
Molecule.get_molecular_weight
Molecule.get_centered_coordinates
Molecule.get_atomic_weights
Molecule.view
Molecule.remove_hydrogen_atoms
get_molecule
- reborn.target.placer module
- Module contents
- reborn.viewers package
- Subpackages
- reborn.viewers.mplviews package
- reborn.viewers.qtviews package
- Subpackages
- reborn.viewers.qtviews.padview_widgets package
- Submodules
- reborn.viewers.qtviews.padview_widgets.display_editor module
Widget
Widget.fix_current_levels
Widget.upper_fixed_checkbox_action
Widget.upper_fixed_spinbox_action
Widget.upper_percentile_checkbox_action
Widget.upper_percentile_spinbox_action
Widget.lower_fixed_checkbox_action
Widget.lower_fixed_spinbox_action
Widget.lower_percentile_checkbox_action
Widget.lower_percentile_spinbox_action
Widget.mirror_checkbox_action
Widget.ignore_masked_checkbox_action
- reborn.viewers.qtviews.padview_widgets.display_options module
- reborn.viewers.qtviews.padview_widgets.edit_beam module
- reborn.viewers.qtviews.padview_widgets.edit_geometry module
- reborn.viewers.qtviews.padview_widgets.frame_navigator module
- reborn.viewers.qtviews.padview_widgets.mask_editor module
- reborn.viewers.qtviews.padview_widgets.misc module
- reborn.viewers.qtviews.padview_widgets.ring_editor module
- reborn.viewers.qtviews.padview_widgets.run_stats module
- reborn.viewers.qtviews.padview_widgets.swaxs_simulator module
- Module contents
- reborn.viewers.qtviews.padview_widgets package
- Submodules
- reborn.viewers.qtviews.padviews module
PADViewMainWindow
PADView
PADView.show_histogram
PADView.downsample_function
PADView.hold_pad_geometry
PADView.hold_beam
PADView.hold_mask
PADView.hold_levels
PADView.skip_empty_frames
PADView.sig_geometry_changed
PADView.sig_beam_changed
PADView.sig_dataframe_changed
PADView.debug
PADView.get_pad_geometry
PADView.set_pad_geometry
PADView.get_dataframe
PADView.set_dataframe
PADView.get_beam
PADView.set_beam
PADView.get_mask
PADView.set_mask
PADView.get_pad_display_data
PADView.set_pad_display_data
PADView.set_title
PADView.set_shortcut
PADView.set_colormap
PADView.get_levels
PADView.set_levels
PADView.add_rectangle_roi
PADView.add_circle_roi
PADView.show_rois
PADView.hide_rois
PADView.toggle_rois
PADView.show_coordinate_axes
PADView.hide_coordinate_axes
PADView.toggle_coordinate_axes
PADView.show_fast_scan_directions
PADView.hide_fast_scan_directions
PADView.toggle_fast_scan_directions
PADView.show_pad_labels
PADView.hide_pad_labels
PADView.toggle_pad_labels
PADView.show_pad_indices
PADView.hide_pad_indices
PADView.toggle_pad_indices
PADView.choose_mask_color
PADView.get_mask_color
PADView.set_mask_color
PADView.update_masks
PADView.hide_masks
PADView.show_masks
PADView.toggle_masks
PADView.save_masks
PADView.load_masks
PADView.clear_masks
PADView.clear_processed_data
PADView.update_pads
PADView.update_pad_geometry
PADView.update_beam
PADView.update_dataframe
PADView.update_display
PADView.save_pad_geometry
PADView.load_pad_geometry
PADView.save_beam
PADView.load_beam
PADView.vector_to_view_coords
PADView.get_pad_coords_from_view_coords
PADView.get_pad_coords_from_mouse_pos
PADView.get_view_coords_from_mouse_pos
PADView.get_view_bounding_rect
PADView.mouse_moved
PADView.add_ring
PADView.update_rings
PADView.remove_rings
PADView.show_grid
PADView.hide_grid
PADView.toggle_grid
PADView.show_pad_border
PADView.hide_pad_border
PADView.show_pad_borders
PADView.hide_pad_borders
PADView.show_history_next
PADView.show_history_previous
PADView.show_next_frame
PADView.show_previous_frame
PADView.show_random_frame
PADView.show_frame
PADView.show_first_frame
PADView.reload_current_frame
PADView.add_plot_item
PADView.add_scatter_plot
PADView.remove_scatter_plots
PADView.load_pickled_dataframe
PADView.save_pickled_dataframe
PADView.load_npy_file
PADView.save_npy_file
PADView.open_data_file_dialog
PADView.save_data_file_dialog
PADView.vector_coords_to_2d_display_coords
PADView.panel_scatter_plot
PADView.display_editor_widget
PADView.mask_editor_widget
PADView.frame_navigator_widget
PADView.ring_editor_widget
PADView.runstats_widget
PADView.display_options_widget
PADView.edit_geometry_widget
PADView.swaxs_simulator_widget
PADView.beam_editor_widget
PADView.import_plugin_module
PADView.run_plugin
PADView.start
PADView.stop
PADView.show
PADView.save_screenshot_dialog
PADView.save_screenshot
PADView.save_file_dialog
PADView.tic
PADView.toc
PADView.histogram_widget
view_pad_data
DummyFrameGetter
show_and_raise
- reborn.viewers.qtviews.qtviews module
- Module contents
- Subpackages
- Submodules
- reborn.viewers.pandaviews module
WidgetedCell
DataFrameModel
DataFrameModel.RawDataRole
DataFrameModel.RawIndexRole
DataFrameModel.set_dataframe
DataFrameModel.df
DataFrameModel.beginDynamicFilter
DataFrameModel.endDynamicFilter
DataFrameModel.cancelDynamicFilter
DataFrameModel.headerData
DataFrameModel.data
DataFrameModel.flags
DataFrameModel.rowCount
DataFrameModel.columnCount
DataFrameModel.sort
DataFrameModel.filter
DataFrameModel.filterIsIn
DataFrameModel.filterFunction
DataFrameModel.reset
DataFrameSortFilterProxyModel
DataFrameSortFilterProxyModel.setSourceModel
DataFrameSortFilterProxyModel.sort
DataFrameSortFilterProxyModel.setFilterString
DataFrameSortFilterProxyModel.setFilterList
DataFrameSortFilterProxyModel.setFilterFunction
DataFrameSortFilterProxyModel.df
DataFrameSortFilterProxyModel.filterAcceptsRow
DataFrameSortFilterProxyModel.filterAcceptsColumn
DataFrameSortFilterProxyModel.setFilterRegExp
DataFrameSortFilterProxyModel.setFilterWildcard
DataFrameSortFilterProxyModel.setFilterFixedString
DynamicFilterLineEdit
DynamicFilterMenuAction
FilterListMenuWidget
DataFrameItemDelegate
DataFrameWidget
DataFrameWidget.dataFrameChanged
DataFrameWidget.cellClicked
DataFrameWidget.make_cell_context_menu
DataFrameWidget.contextMenuEvent
DataFrameWidget.plot_single_column
DataFrameWidget.setDataFrame
DataFrameWidget.filter
DataFrameWidget.filterIsIn
DataFrameWidget.df
DataFrameWidget.keyPressEvent
DataFrameWidget.copy
DataFrameWidget.custom_filter
DataFrameApp
view_pandas_dataframe
- Module contents
- Subpackages
Submodules¶
reborn.config module¶
Standard configs for reborn. Has global effect.
reborn.const module¶
reborn.dataframe module¶
Classes for handling dataframes.
- class reborn.dataframe.DataFrame(raw_data=None, processed_data=None, mask=None, beam=None, pad_geometry=None, frame_id=0)[source]¶
Bases:
object
A dataframe is a new concept in reborn. It corresponds to a recording event, which is most often an XFEL pulse or a synchrotron exposure. The interface of this class will be changing in the coming weeks. At minimum, it should hold the following data:
A
Beam
instance.The “raw” PAD data arrays.
The “processed” PAD data arrays. (Copy the “raw” data if there are no processing steps.)
An event ID. This may be an integer, or any other data type (such as a tuple in the case of LCLS).
- parameters = {}¶
- validate()[source]¶
Check that this dataframe is valid. A valid dataframe must at minimum have a frame ID, a valid Beam instance, a valid PADGeometryList instance, and raw data.
- property is_dark¶
- property n_pads¶
Number of PADs.
- property raw_data¶
Raw data (closest to the source).
- property processed_data¶
Some modification of the raw data.
- property q_mags¶
Concatenates the output of the corresponding function for each PADGeometry.
- property q_vecs¶
Concatenates the output of the corresponding function for each PADGeometry.
- property solid_angles¶
Concatenates the output of the corresponding function for each PADGeometry.
- property polarization_factors¶
Concatenates the output of the corresponding function for each PADGeometry.
- get_frame_index()[source]¶
This is an integer index the is unique to this frame. It is understood to be a context-dependent parameter that might, for example, be the index in a list of frames.
- get_dataset_id()[source]¶
Unique identifier for the parent dataset.
For LCLS-I this would follow the “data source” convention: for example, “exp=cxil2316:run=56”
- get_frame_id()[source]¶
Unique identifier for this dataframe. Most often this is an integer, but in some cases, such as the LCLS, it may be something else such as a tuple. LCLS uses a tuple of integers: seconds, nanoseconds, and fiducial.
- get_pad_geometry()[source]¶
Get the
PADGeometryList
of all PADs in the event. A future version of this will likely accommodate multiple collections of PADs (e.g. when we have a SAXS detector and WAXS detector that are most reasonably analyzed separately.).
- set_raw_data(data)[source]¶
Set the raw data. You may pass a list or an
ndarray
. Has the side effect of setting the ‘writeable’ flag of the array to False.
reborn.detector module¶
Classes for analyzing/simulating diffraction data contained in pixel array detectors (PADs).
- reborn.detector.cached(method)[source]¶
Experimental decorator for caching results from a method. Assumes no arguments are needed.
- reborn.detector.clear_cache(self)[source]¶
Function to clear cache created by the cached decorator above.
- class reborn.detector.PADGeometry(distance=None, pixel_size=None, shape=None, **kwargs)[source]¶
Bases:
object
A container for pixel-array detector (PAD) geometry specification. By definition, a PAD consists of a single 2D grid of pixels; see the extended description in the documentation.
Note
A common point of confusion is that XFEL detectors typically consist of multiple PADs, in which case your code must handle multiple
PADGeometry
instances. If that is the case for your data, then you should look to thePADGeometryList
documentation as it extends Python’s built-in list class with useful methods for PADGeometry instances. Before you look toPADGeometryList
, you should finish reading this documentation.The complete specification of an individual PAD geometry is understood to be the following 5 parameters, which must be defined for a proper instance of
PADGeometry
:n_fs: The number of pixels along the fast-scan direction.
n_ss: The number of pixels along the slow-scan direction.
t_vec: The vector that points from the origin (interaction point) to the center of the first pixel in memory.
fs_vec: The vector that points from the first pixel in memory, to the next pixel in the fast-scan direction.
ss_vec: The vector that points from the first pixel in memory, to the next pixel in the slow-scan direction.
In the above:
The lengths of the fs_vec and ss_vec vectors encode the size of the (possibly rectangular) pixel. They moreover form the basis of the 2D grid that maps the pixel positions in the 3D space of the measurement.
The term “fast-scan” corresponds to the right-most index of a 2D numpy
ndarray
containing PAD data.The term “slow-scan” corresponds to the left-most index of a 2D
ndarray
containing PAD data.In the default memory buffer layout of an
ndarray
, the fast-scan direction corresponds to pixels that are contiguous in memory, and which therefore have the smallest stride. If the phrase “contiguous in memory” and the term “stride” does not mean anything to you, then you need to read the numpy documentation forndarray
.
In addition to providing a standard way to specify PAD geometry, the PADGeometry class also provides methods that make it easy to generate:
Vectors from sample to pixel.
Scattering vectors (i.e. “q” vectors… provided beam information).
Scattering vector magnitudes.
Scattering angles (twice the Bragg angle).
Polarization factors.
Pixel solid angles.
Maximum resolution.
etc.
Some of the above parameters require more than a PADGeometry instance – they also require information about the x-ray beam. The
Beam
class in reborn provides a standard way to specify the properties of an x-ray beam.Although PADGeometry is primarily meant to deal with geometry, you may also include the information needed to slice the PAD data from a parent data array (as of January 2022). For example, data from the CSPAD detector is presented as a 3D
ndarray
when accessed using the LCLS psana python package. In order to specify slicing, you must add the following parameters:parent_data_shape: The shape of the parent data array (example: (32, 185, 392) ).
parent_data_slice: The slice of the parent data array (example: np.s_[4, :, 196:]).
On initialization, optional arguments may be provided (you must provide all of them):
- Parameters:
- do_cache = False¶
- property hash¶
Return a hash of the geometry parameters. Useful if you want to avoid re-computing things like q_mags.
- validate()[source]¶
Determine if this instance has all the needed parameters defined.
- Returns:
True if validation passes.
- Return type:
- Raises:
ValueError – If any of n_fs, n_ss, fs_vec, ss_vec, t_vec are not defined properly.
- property name¶
(str) The unique name of this panel.
- property n_fs¶
(int) Number of fast-scan pixels.
- property n_ss¶
Number of slow-scan pixels.
- property n_pixels¶
Total number of pixels (\(n_{fs} \cdot n_{ss}\))
- property t_vec¶
(
ndarray
) Translation vector pointing from origin to center of corner pixel, which is first in memory.
- property parent_data_slice¶
Optionally, this defines the slice of an
ndarray
that this geometry corresponds to. This is helpful if you wish to work with the 3D arrays in psana, for example.
- property parent_data_shape¶
Optionally, this defines the shape of the
ndarray
from which this PAD is sliced.
- is_different(geom, precision=1e-05)[source]¶
Compare this PAD to another and check if it is the same within specified precision.
- change_parent_shape(shape)[source]¶
Change the parent data shape (e.g from [400, 150] to [4, 100, 150]).
- to_dict()[source]¶
Convert geometry to a dictionary.
- Returns: (dict): Dictionary containing the keys name, n_fs, n_ss, fs_vec, ss_vec, t_vec,
parent_data_shape, and parent_data_slice.
- from_dict(dictionary)[source]¶
Loads geometry from dictionary. This goes along with the to_dict method.
- simple_setup(pixel_size=None, distance=None, shape=None, **kwargs)[source]¶
Make this a square PAD with beam at center.
- indices_to_vectors(idx_ss, idx_fs)[source]¶
Convert pixel indices to translation vectors pointing from origin to position on panel. The positions need not lie on the actual panel; this assumes an infinite plane.
- vectors_to_indices(vecs, insist_in_pad=True, round_to_nearest=False, **kwargs)[source]¶
Suppose you have a vector pointing away from the origin and you want to know which pixel the vector will intercept. This function will do that calculation for you. It will return the indices corresponding to the point where the vector intercepts the PAD. Note that the indices are floating points, so you might need to convert to integers if you use them for indexing.
- Parameters:
- Returns:
Slow-scan indices, Fast-scan indices.
- Return type:
(tuple)
- pixel_corner_position_vecs()[source]¶
Compute vectors pointing from origin to pixel corners. To get the corners we simply shift the pixel indices by +/- 0.5. The output array is of shape (N, 4, 3), interpreted as follows:
vecs[:, 0, :] corresponds to the corners with indices (j-0.5, i-0.5) vecs[:, 1, :] corresponds to the corners with indices (j-0.5, i+0.5) vecs[:, 2, :] corresponds to the corners with indices (j+0.5, i+0.5) vecs[:, 3, :] corresponds to the corners with indices (j+0.5, i-0.5)
Returns:
ndarray
of shape (N, 4, 3)
- position_vecs()[source]¶
Compute vectors pointing from origin to pixel centers.
Returns:
ndarray
of shape (N, 3)
- center_pos_vec()[source]¶
The vector that points from the origin to the center of the PAD
Returns:
ndarray
- average_detector_distance(beam=None, beam_vec=None)[source]¶
Get the average detector distance, which is equal to the dot product between the beam direction vector and the vector pointing to the center of the PAD.
- set_average_detector_distance(distance, beam=None, beam_vec=None)[source]¶
Set the average detector distance. The translation moves along the beam direction by default.
- norm_vec(beam=None)[source]¶
The vector that is normal to the PAD plane.
- Parameters:
beam (
Beam
) – The beam information, if you want to ensure that the signs are chosen so that the normal vector points toward the interaction point.
Returns:
ndarray
- ds_vecs(beam=None, **kwargs)[source]¶
Scattering vectors \(\hat{s} - \hat{s}_0\) where \(\hat{s}_0\) is the incident beam direction and \(\hat{s}\) is the outgoing vector pointing from sample to pixel. This does not have the \(2\pi/\lambda\) factor that is included in
q_mags
.- Parameters:
beam (
Beam
) – specify incident beam properties. If provided, you may omit the specification of beam_vec ect.
Returns:
ndarray
- q_vecs(beam=None, **kwargs)[source]¶
Calculate scattering vectors \(\frac{2\pi}{\lambda}(\hat{s} - \hat{s}_0)\)
(1)¶\[\vec{q}_{ij}=\frac{2\pi}{\lambda}\left(\hat{v}_{ij} - \hat{b}\right)\]- Parameters:
beam (source.Beam instance) – specify incident beam properties. If provided, you may omit the specification of beam_vec ect.
Returns:
ndarray
- ds_mags(beam=None, **kwargs)[source]¶
These are the magnitudes that correspond to
- Parameters:
beam (
Beam
)
Returns:
ndarray
- q_mags(beam=None, **kwargs)[source]¶
Calculate scattering vector magnitudes:
- Parameters:
beam (source.Beam instance) – specify incident beam properties. If provided, you may omit the specification of beam_vec ect.
Returns:
ndarray
- solid_angles()[source]¶
Calculate solid angles of pixels. See solid_angles2 method.
Returns:
ndarray
- solid_angles1()[source]¶
Calculate solid angles of pixels vectorally, assuming the pixels have small angular extent.
Returns:
ndarray
- solid_angles2()[source]¶
Pixel solid angles calculated using the method of Van Oosterom, A. & Strackee, J. Biomed. Eng., IEEE T ransactions on BME-30, 125-126 (1983). Divide each pixel up into two triangles with vertices R1,R2,R3 and R2,R3,R4. Then use analytical form to find the solid angle of each triangle. Sum them to get the solid angle of pixel.
Thanks to Derek Mendez, who thanks Jonas Sellberg.
Returns:
ndarray
- polarization_factors(beam=None, e1=None, b=None, a=None)[source]¶
The scattering polarization factors.
- Parameters:
Returns:
ndarray
- scattering_angles(beam=None, **kwargs)[source]¶
Scattering angles (i.e. twice the Bragg angles).
- Parameters:
beam (source.Beam instance) – specify incident beam properties. If provided, you may omit the specification of beam_vec ect.
Returns:
ndarray
- azimuthal_angles(beam)[source]¶
The azimuthal angles of pixels in spherical coordinates. In the physics convention, the incident beam points along the zenith \(\hat{z}\), the outgoing wavevector points to the pixel at position \(\vec{r}\), the “polar angle” \(\theta\) is the scattering angle, and the “azimuthal angle” is \(\phi = \arctan(y/x)\).
Since reborn does not enforce any particular coordinate convention or beam direction, we define the azimuthal angles according to the definition of the incident
Beam
:(2)¶\[\phi = \arctan(\hat{e}_2 \cdot \hat{r} / \hat{e}_1 \cdot \hat{r})\]where \(\hat{e}_1\) is the principle polarization component of the incident x-ray beam, and \(\hat{e}_2\) is the complementary polarization component.
- Parameters:
beam (source.Beam instance) – specify incident beam properties.
Returns:
ndarray
- streak_mask(vec=None, angle=None)[source]¶
Create a streak mask. Given the “streak vector” \(\vec{s}\) that defines the plane of the streak, calculate the angles between outgoing pixel vector \(\vec{p}\) and that plane: \(\phi = \pi/2 - |\arccos(\vec{s}\cdot \vec{p})|\). Then mask all pixels for which \(\phi\) is less than the specified angle.
Note
If you want to mask a liquid jet, then the streak vector should be \(\vec{s} \times \vec{b}\) where the vector \(\vec{b}\) points along the beam direction and \(\vec{s}\) points along the liquid jet.
- Parameters:
Returns:
ndarray
- edge_mask(n=1)[source]¶
Mask pixels along the perimeter of the PAD.
- Parameters:
n (int) – How many pixels to mask.
Returns:
ndarray
- beamstop_mask(beam=None, q_min=None, q_max=None, min_angle=None, max_angle=None, min_radius=None, max_radius=None)[source]¶
- Parameters:
beam (
Beam
) – Instance of the Beam class (for wavelength)q_min (float) – Minimum q magnitude (mask smaller q values)
q_max (float) – Maximum q magnitude (mask larger q values)
min_angle (float) – Minimum scattering angle (mask smaller angles)
max_angle (float) – Maximum scattering angle (mask larger angles)
min_radius (float) – Minimum size (mask pixels within)
max_radius (float) – Maximum size (mask pixels beyond)
Returns:
ndarray
- f2phot(beam=None)[source]¶
Returns the conversion factor needed to convert structure factors \(|F(\vec q)|^2\) to photon counts. Specifically, this function returns \(\alpha_i\) in the expression
(3)¶\[I_i = \alpha_i |F_i|^2 = J_0 r_e^2 P_i \Delta\Omega_i |F_i|^2\]where
\(I_i\) is the photon counts in pixel \(i\)
\(J_0\) is the incident photon fluence (photons per area)
\(r_e^2\) is the classical electron scattering cross section
\(P_i\) is the polarization factor for pixel \(i\)
\(\Delta\Omega_i\) is the solid angle of pixel \(i\)
- Parameters:
beam (
Beam
) – The beam properties
Returns:
ndarray
- reshape(dat)[source]¶
Re-shape a flattened array to a 2D array.
- Parameters:
dat (
ndarray
) – The flattened data array
Returns:
ndarray
- max_resolution(beam=None)[source]¶
Maximum resolution over all pixels: 2*pi/q
- Parameters:
beam – A Beam class instance.
- Returns:
float
- corner_position_vectors()[source]¶
Returns the coordinates of all four corners of the detector. The output is an
ndarray
with shape (5, 3) and the following entries [t, t+nf*f, t+nf*f+ns*s, t+ns*s] .- Returns:
The corner positions of the PAD.
- Return type:
- binned(binning=2)[source]¶
Make the pixel size bigger by an integer multiple, while keeping the array size approximately the same.
Note
This may result in loss of information. Example: with binning set to 2, a 5x7 PAD results in a 2x3 PAD with pixels twice the size. There is no way to recover the initial 5x7 shape from the binned PAD.
Note
This operation is not inplace. It does not affect the current instance of PADGeometry. It returns a new PADGeometry.
- Parameters:
binning (int) – An integer value of 1,2,3,etc. The pixel size will be increased by this factor.
- Returns:
The new, binned, PAD geometry.
- Return type:
- class reborn.detector.PADGeometryList(pad_geometry=None, filepath=None)[source]¶
Bases:
list
A subclass of list that does operations on lists of
PADGeometry
instances. Is helpful, for example. when getting q vectors for many separate PADs.- Parameters:
pad_geometry (
PADGeometry
or list of) – The PAD geometry that will form the PADGeometryList.
- do_cache = False¶
- copy()[source]¶
Same as the matching method in
PADGeometry
.
- property hash¶
Return a hash of the geometry parameters. Useful if you want to avoid re-computing things like q_mags.
- validate()[source]¶
Same as the matching method in
PADGeometry
.
- to_dict_list()[source]¶
Convert each
PADGeometry
to a dictionary, return as a list.
- add_group(pads, group_name=None)[source]¶
Extend the PADGeometryList, and create a group name for the new members. Helpful if you have multiple “detectors” that you wish to combine into a single PADGeometryList.
- get_group(group_name)[source]¶
Return a named group in the form of a
PADGeometryList
.
- get_all_groups()[source]¶
Equivalent to get_group, but sets the argument to all group names. Beware: you may have redundancies!
- get_group_names()[source]¶
Get a list of all group names. Will be empty list if there are no groups.
- get_by_name(name)[source]¶
Return a
PADGeometry
with a given name.
- assign_names()[source]¶
Make sure that all
PADGeometry
instances have unique names.
- defines_slicing()[source]¶
False if any of the
PADGeometry
instances does not have a parent_data_slice or parent_data_shape defined. True otherwise.
- property parent_data_shape¶
Return parent data shape, or None if undefined. Raise ValueError if mis-matched parent data shapes.
- change_parent_shape(shape)[source]¶
See equivalent method in
PADGeometry
.
- concat_data(data)[source]¶
Concatenate a list of
ndarray
instances into a single concatenated 1Dndarray
.
- concat_vecs(data)[source]¶
Concatenate a list of (N, 3)
ndarray
instances into a single concatenated (N, 3)ndarray
.
- property n_pixels¶
Sums the output of the matching method in
PADGeometry
- save_json(file_name)[source]¶
Same as the matching method in
PADGeometry
.
- position_vecs()[source]¶
Concatenates the output of the matching method in
PADGeometry
- pixel_corner_position_vecs()[source]¶
Concatenates the output of the matching method in
PADGeometry
- average_detector_distance(beam=None, beam_vec=None)[source]¶
Same as the matching method in
PADGeometry
, but averaged over all PADs.
- set_average_detector_distance(distance, beam=None, beam_vec=None)[source]¶
Same as the matching method in
PADGeometry
.
- s_vecs()[source]¶
Concatenates the output of the matching method in
PADGeometry
- ds_vecs(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- q_vecs(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- q_mags(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- solid_angles()[source]¶
Concatenates the output of the matching method in
PADGeometry
- solid_angles1()[source]¶
Concatenates the output of the matching method in
PADGeometry
- solid_angles2()[source]¶
Concatenates the output of the matching method in
PADGeometry
- polarization_factors(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- scattering_angles(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- f2phot(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- azimuthal_angles(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- beamstop_mask(beam=None, q_min=None, q_max=None, min_angle=None, max_angle=None, min_radius=None, max_radius=None)[source]¶
Concatenates the output of the matching method in
PADGeometry
- edge_mask(*args, **kwargs)[source]¶
Concatenates the output of the matching method in
PADGeometry
- streak_mask(*args, **kwargs)[source]¶
Concatenates the output of the matching method in
PADGeometry
- zeros(*args, **kwargs)[source]¶
Concatenates the output of the matching method in
PADGeometry
- ones(*args, **kwargs)[source]¶
Concatenates the output of the matching method in
PADGeometry
- random(*args, **kwargs)[source]¶
Concatenates the output of the matching method in
PADGeometry
- poisson(lam=1.0)[source]¶
Concatenates the output of the matching method in
PADGeometry
- max_resolution(beam)[source]¶
Concatenates the output of the matching method in
PADGeometry
- binned(binning=2)[source]¶
See corresponding method in
PADGeometry
.
- translate(vec)[source]¶
See corresponding method in
PADGeometry
.
- rotate(matrix)[source]¶
See corresponding method in
PADGeometry
.
- reborn.detector.f2_to_photon_counts(f_squared, beam=None, pad_geometry=None)[source]¶
Convert computed scattering factors \(F(\vec{q})^2\) into photon counts. This multiplies \(F(\vec{q})^2\) by the incident beam fluence, the classical electron area, the pixel solid angles, and the beam polarization factor.
- Parameters:
f_squared
beam
pad_geometry
Returns:
- reborn.detector.save_pad_geometry_list(file_name, geom_list)[source]¶
Save a list of PADGeometry instances as a json file.
- reborn.detector.load_pad_geometry_list(file_name)[source]¶
Load a list of PADGeometry instances stored in json format.
- reborn.detector.tiled_pad_geometry_list(pad_shape=(512, 1024), pixel_size=0.0001, distance=0.1, tiling_shape=(4, 2), pad_gap=0)[source]¶
Make a list of PADGeometry instances with identical panel sizes, tiled in a regular grid.
- Parameters:
Returns:
PADGeometryList
- reborn.detector.concat_pad_data(data)[source]¶
Given a list of numpy arrays, concatenate them into a single 1D array. This is a very simple command:
return np.concatenate([d.ravel() for d in data])
This should exist in numpy but I couldn’t find it.
- Parameters:
data (list or
ndarray
) – A list of 2Dndarray
s. If data is anndarray
, then data.ravel() is returned
Returns: 1D
ndarray
- reborn.detector.split_pad_data(pad_list, data)[source]¶
Given a contiguous block of data produced by the function
concat_pad_data
, split the data into individual 2D PAD panels.- Parameters:
pad_list – A list of PADGeometry instances
data – A contiguous array with data values (total pixels to add up to sum of pixels in all PADs)
- Returns:
A list of 2D
ndarray
s
- reborn.detector.edge_mask(data, n_edge)[source]¶
Make an “edge mask”; an array of ones with zeros around the edges. The mask will be the same type as the data (e.g. double).
- Parameters:
data (2D numpy array) – a data array (for shape reference)
n_edge (int) – number of pixels to mask around edges
Returns:
ndarray
- reborn.detector.subtract_pad_friedel_mate(data, mask, geom)[source]¶
Subtract the intensities related by Fridel symmetry
- class reborn.detector.PADAssembler(pad_geometry=None, centered=True, shape=None, **kwargs)[source]¶
Bases:
object
Assemble PAD data into a fake single-panel PAD. Take the average of pixel values that fall within the re-mapped PAD. This assumes you want to project in the “x-y” plane.
- Parameters:
pad_geometry (
PADGeometryList
) – PAD Geometrycentered (bool) – If set to False, the resulting re-mapped PAD will not be centered. it will be a “snug fit” to the PAD
shape (bool) – The desired shape of the re-mapped PAD. Optional. Use the pixel size to determine binning/shape if shape not set (or set to None).
- class reborn.detector.IcosphereGeometry(n_subdivisions=1, radius=1)[source]¶
Bases:
object
Experimental class for a spherical detector that follows the “icosphere” geometry. The Icosphere is generated by subdividing the vertices of an icosahedron. The following blog was helpful: http://sinestesia.co/blog/tutorials/python-icospheres/
The code is quite slow; needs to be vectorized with numpy. There are definitely better spherical detectors - the solid angles of these pixels are not very uniform.
- n_subdivisions = 1¶
- radius = 1¶
- reborn.detector.save_pad_masks(file_name, mask_list, packbits=True)[source]¶
Save list of 2D mask arrays in a compressed format. It is assumed that masks consist of values of zero or one. We presently use the
numpy.packbits
function along withnumpy.savez_compressed
function.Note
The file name extension will be ‘.mask’. If you provide a name without an extension, or with a different extension, the extension will be changed. It is recommended that you explicitly provide the extension.
- Parameters:
file_name (str) – Path to file that will be saved.
mask_list (list) – A list of
ndarray
masks. Will be converted to bool type before saving.packbits (bool) – Specify if
numpy.packbits
should be used to reduce file size. (Default: True).
Returns: str: File name.
- reborn.detector.load_pad_masks(file_name)[source]¶
Load a mask created using the save_pad_masks function.
- Parameters:
file_name (str) – The path to the file you want to open.
Returns: List of
ndarray
objects with int type.
- reborn.detector.pnccd_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the pnCCD detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.cspad_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the CSPAD detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.cspad_2x2_pad_geometry_list(detector_distance=2.4, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the CSPAD detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.jungfrau4m_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the Jungfrau 4M detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.epix10k_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the epix10k detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.epix100_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the epix100 detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.mpccd_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by SACLA’s MPCCD detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.agipd_pad_geometry_list(detector_distance=0.1, binning=None)[source]¶
Generate a list of
PADGeometry
instances that are inspired by EuXFEL’s AGIPD detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.rayonix_mx340_xfel_pad_geometry_list(detector_distance=0.1, binning=None, return_mask=False)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the Rayonix MX340-XFEL detector.- Parameters:
Returns:
PADGeometryList
- reborn.detector.eiger4M_pad_geometry_list(detector_distance=0.1, binning=None, return_mask=False)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the Eiger 4M detector at CXLS.- Parameters:
detector_distance (float) – Detector distance in SI units.
Returns:
PADGeometryList
- reborn.detector.pilatus100k_pad_geometry_list(detector_distance=0.1, binning=None, return_mask=False)[source]¶
Generate a list of
PADGeometry
instances that are inspired by the Eiger 4M detector at CXLS.- Parameters:
detector_distance (float) – Detector distance in SI units.
Returns:
PADGeometryList
reborn.source module¶
Classes related to x-ray sources.
- class reborn.source.Beam(file_name=None, beam_vec=array([0, 0, 1]), photon_energy=1.602e-15, wavelength=None, polarization_vec=array([1, 0, 0]), polarization_weight=1, pulse_energy=0.001, diameter_fwhm=1e-06)[source]¶
Bases:
object
A minimal container to gather x-ray beam properties.
- Parameters:
beam_vec (
ndarray
) – Direction of incident beam.photon_energy (float) – Photon energy in SI units.
wavelength (float) – Wavelength in SI units (an alternative to photon energy).
polarization_vec (
ndarray
) – Direction of the first component of the electric field. Must be orthogonal to the beam vector. Second component is E2 = E1 x B .pulse_energy (float) – Total energy of x-ray pulse.
diameter_fwhm (float) – Beam diameter. Default is a tophat beam profile, so this is the tophat diameter.
- photon_energy_fwhm = 0¶
- divergence_fwhm = 0¶
- pulse_energy_fwhm = 0¶
- photon_energy = None¶
- diameter_fwhm = None¶
- validate()[source]¶
Validate this Beam instance. Presently, this method only checks that there is a wavelength.
- property hash¶
Hash the
Beam
instance in order to determine if the beam properties have changed.- Returns:
int
- property beam_profile¶
In the future this will be a means of specifying the profile of the incident x-rays. The only option is ‘tophat’ for the time being. Possibly in the future we could allow for complex wavefronts.
- property beam_vec¶
The nominal direction of the incident x-ray beam.
- property k_in¶
Incident wavevector.
- property polarization_vec¶
The principle polarization vector \(\hat{E}_1\). This should be orthogonal to the incident beam direction. The complementary polarization vector is \(\hat{E}_2 = \hat{b} \times \hat{E}_1\)
- property e1_vec¶
The principle polarization vector \(\hat{E}_1\).
- property e2_vec¶
The secondary polarization vector \(\hat{E}_2 = \hat{k}_0 \times \hat{E}_1\).
- property polarization_weight¶
The fraction of f of energy that goes into the principle polarization vector specified by the polarization_vec attribute. The fraction of the energy in the complementary polarization is of course (1-f).
- property wavelength¶
Photon wavelength in meters.
- property pulse_energy¶
Pulse energy in J.
- property n_photons¶
Number of photons per pulse.
- property fluence¶
Same as energy_fluence. Don’t use this method.
- property photon_number_fluence¶
Pulse fluence in photons/m^2.
- property energy_fluence¶
Pulse fluence in J/m^2.
- reborn.source.load_beam(file_path)[source]¶
Load a beam from a json file (loaded with
Beam.load_json()
method)- Parameters:
file_path (str) – Path to beam json file
Returns:
Beam
- reborn.source.save_beam(beam, file_path)[source]¶
Save a Beam to a json file (saved with
Beam.save_json()
method)
reborn.utils module¶
Some utility functions that might be useful throughout reborn. Don’t put highly specialized functions here.
- reborn.utils.log_to_terminal(level: (<class 'int'>, <class 'str'>) = 10)[source]¶
For convenience, create a logger that prints to the terminal.
- reborn.utils.resource_path(path=None)[source]¶
Fetch the path to a resource file in reborn.
- Parameters:
path (str or path) – Path to resource, relative to the reborn package base directory (NOT the base directory of
repo!). (the git)
- reborn.utils.ensure_list(obj)[source]¶
Make sure that some object is a list. This is helpful because, for example, we frequently write code around the assumption that detector geometry comes in the form of a list of
PADGeometry
instances. However, it is also not so uncommon to have a singlePADGeometry
.This function does the following simple task:
def ensure_list(obj): if isinstance(obj, list): return obj if isinstance(obj, tuple): return list(obj) return [obj]
- Parameters:
obj (object) – The object that we want to ensure is a list.
Returns: list
- reborn.utils.vec_shape(vec)[source]¶
Ensure that an array has the proper shape that is expected of 3-vector arrays. They should always be 2-dimensional, with shape (N, 3).
- reborn.utils.random_rotation()[source]¶
Create a random rotation matrix.
from scipy.spatial.transform import Rotation rotmat = Rotation.random().as_matrix()'
- reborn.utils.rotation_about_axis(theta, vec)[source]¶
This needs to be tested. It was taken from https://stackoverflow.com/questions/17763655/rotation-of-a-point-in-3d-about-an-arbitrary-axis-using-python
- Parameters:
theta (float) – Rotation angle
vec (numpy array) – 3D vector specifying rotation axis
Returns (numpy array): The shape (3, 3) rotation matrix
- reborn.utils.random_beam_vector(div_fwhm)[source]¶
A random vector for emulating beam divergence. Generates a random normal vector that is nominally along the [0,0,1] direction but with a random rotation along the [1,0,0] axis with given FWHM (Gaussian distributed and centered about zero) followed by a random rotation about the [0,0,1] axis with uniform distribution in the interval [0,2*pi).
- Parameters:
div_fwhm (float) – FWHM of divergence angle. Assuming Gaussian, where sigma = FWHM / 2.3548
- Returns:
(numpy array) of length 3
- reborn.utils.triangle_solid_angle(r1, r2, r3)[source]¶
Compute solid angle of a triangle whose vertices are r1,r2,r3, using the method of Van Oosterom, A. & Strackee, J. Biomed. Eng., IEEE Transactions on BME-30, 125-126 (1983).
- reborn.utils.memoize(function)[source]¶
This is a function decorator for caching results from a function. It is used, for example, to avoid re-loading data files containing scattering factors. We assume that your computer has enough RAM to handle this, and we assume that the developers will not abuse this feature. FIXME: This needs to be tested. It was blindly copied from the internet… FIXME: Consider adding a configuration to reborn that disallows the use of memoize.
- reborn.utils.max_pair_distance(*args, **kwargs)[source]¶
Depreciated. Use reborn.utils.vectors.max_pair_distance
- reborn.utils.make_label_radial_shell(r_bin_vec, n_vec)[source]¶
For fast radial statistics calculations - done through a precomputed label array.
Produce a 3D volume with concentric shells of thickness specified by r_bin_vec. Each shell is labelled incrementally by integers starting with 1 at the centre. (the label zero is reserved for masked values in the volume).
Voxels outside the maximum radius is given a label of zero.
- Parameters:
units (r_bin_vec - Radii of the shells - in voxel)
volume (n_vec - Shape of the desired)
- Returns:
labels_radial
- reborn.utils.radial_stats(f, labels_radial, n_radials, mode)[source]¶
Calculate the statistics of the voxels in each shell.
- Input:
f - The input 3D array of numbers labels_radial - The labels n_radials - Maximum label value mode - The desired statistics that we wish to calculate
- Output:
radial_stats_vec
- reborn.utils.get_FSC(f1, f2, labels_radial, n_radials)[source]¶
Calculate the Fourier shell correlation (FSC) between two 3D numpy arrays.
- reborn.utils.atleast_1d(x)[source]¶
Expand dimensions of
ndarray
. Add dimensions to the left-most index.
- reborn.utils.atleast_2d(x)[source]¶
Expand dimensions of
ndarray
. Add dimensions to the left-most index.
- reborn.utils.atleast_3d(x)[source]¶
Expand dimensions of
ndarray
. Add dimensions to the left-most index.
- reborn.utils.atleast_4d(x)[source]¶
Expand dimensions of
ndarray
. Add dimensions to the left-most index.
- reborn.utils.binned_statistic(x, y, func, n_bins, bin_edges, fill_value=0)[source]¶
Similar to
binned_statistic
but faster because regular bin spacing is assumed, and sparse matrix algorithms are used. Speedups of ~30-fold have been observed.Based on the discussion found here: https://stackoverflow.com/questions/26783719/efficiently-get-indices-of-histogram-bins-in-python
- Parameters:
x (
ndarray
) – The coordinates that correspond to values y below. Bin indices derive from x.y (
ndarray
) – The values that enter into the statistic.func (function) – The function that will be applied to values in each bin
n_bins (int) – Desired number of bins
bin_edges (tuple of floats) – The min and max edges of bins (edges, not the centers, of the bins)
fill_value (float) – Initialize output array with these values.
- Returns:
- reborn.utils.check_file_md5(file_path, md5_path=None)[source]¶
Utility for checking if a file has been modified from a previous version.
Given a file path, check for a file with “.md5” appended to the path. If it exists, check if the md5 hash saved in the file matches the md5 hash of the current file and return True. Otherwise, return False.
- reborn.utils.write_file_md5(file_path, md5_path=None)[source]¶
Save the md5 hash of a file. The output will be the same as the original file but with a ‘.md5’ extension appended.
- reborn.utils.git_sha()[source]¶
Return the SHA of the git repo is in the current directory. Return None if the repo is not totally clean. Useful if you wish to keep track of the git version that produced your results.
Returns: str
- reborn.utils.google_docstring_test()[source]¶
This is an example docstring for developers. This function does nothing.
You might link to other reborn docs, such as
reborn.detector.PADGeometry
. Linking also works for some external packages, for examplenp.median
.There are various shortcuts in
doc/conf.py
, such asPADGeometry
and Henke et al. (1993).You can put an equation inline like this \(f(q)\), or on a separate line like this:
(4)¶\[a_i = \sum_n f_n \exp(-i \vec{q}_i \cdot (\mathbf{R} \vec{r} + \vec{U}))\]Note
This is a note to emphasize something important.
- Parameters:
data (
ndarray
or list ofndarray
) – Data to get profiles from.beam (
Beam
) – Beam info.pad_geometry (
PADGeometryList
) – PAD geometry info.mask (
ndarray
or list ofndarray
) – Mask (one is good, zero is bad).n_bins (int) – Number of radial bins.
q_range (tuple of floats) – Centers of the min and max q bins.
statistic (function) – The function you want to apply to each bin (default:
np.mean
).
- Returns:
- Return type:
(tuple)
Module contents¶
reborn python package for simulation and analysis of x-ray diffraction.