XRD
XRDBlock
¶
Bases: DataBlock
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str | None
|
The item to which the block is attached. |
None
|
init_data
|
dict | None
|
A dictionary of data to initialise the block with. |
None
|
unique_id
|
str | None
|
A unique id for the block, used in the DOM and database. |
None
|
accepted_file_extensions
¶
accepted_file_extensions = ('.xrdml', '.xy', '.dat', '.xye', '.rasx', '.cif', '.raw', '.brml')
A list of file extensions that the block will attempt to read.
data
¶
data = {'item_id': item_id, 'blocktype': self.blocktype, 'block_id': self.block_id, None: self.defaults}
defaults
¶
defaults = {'wavelength': 1.5406}
Any default values that should be set if they are not supplied during block init.
description
¶
description = 'Visualize XRD patterns and perform simple baseline corrections.'
A longer description outlining the purpose and capability of the block.
name
¶
name = 'Powder XRD'
The human-readable block name specifying which technique or file format it pertains to.
events_by_name
¶
Returns a dict of registered events for this block.
from_web
¶
Initialise the block state from data passed via web request with a given item and block ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The block data to initialiaze the block with. |
required |
stored_data
|
dict | None
|
The stored database state of the block, if any, used to preserve server-authoritative fields that cannot be set from the web. |
None
|
generate_xrd_plot
¶
Generate a Bokeh plot potentially containing multiple XRD patterns.
If no filenames are passed directly, the files to plot are taken from
the file_ids set in the block data, falling back to the legacy
single file_id if present.
load_pattern
¶
load_pattern(location: str | Path, wavelength: float | None = None) -> tuple[DataFrame, list[str], dict]
Load the XRD pattern at the given file location, returning a DataFrame with the pattern data, a list of y-axis options for plotting and a dictionary of peak metadata, if present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str | Path
|
The file location of the XRD pattern. |
required |
wavelength
|
float | None
|
The wavelength of the X-ray source. Defaults to CuKa. |
None
|
null_event
¶
null_event(**kwargs)
A null debug event that does nothing but logs its kwargs and overwrites the data dict with the args.
process_events
¶
Handle any supported events passed to the block.
to_db
¶
to_db() -> dict
returns a dictionary with the data for this block, ready to be input into mongodb
to_web
¶
Returns a JSON serializable dictionary to render the data block on the web.
update_from_web
¶
Update the block with validated data received from a web request. Will strip any fields that are "computed" or otherwise not controllable by the user, restoring their stored database values where available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary of data to update the block with. |
required |
stored_data
|
dict | None
|
The stored database state of the block, if any. |
None
|