XRD
XRDBlock
¶
XRDBlock(item_id: str | None = None, collection_id: str | None = None, init_data: dict | None = None, unique_id: str | None = None)
Bases: DataBlock
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str | None
|
The item to which the block is attached, or |
None
|
collection_id
|
str | None
|
The collection 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
|
Attributes:
| Name | Type | Description |
|---|---|---|
accepted_file_extensions |
|
|
block_db_model |
|
|
block_id |
|
|
blocktype |
|
|
data |
|
|
defaults |
|
|
description |
|
|
multi_file |
bool
|
Whether this block can accept multiple files as input. |
name |
|
|
plot_functions |
|
|
version |
str
|
The implementation version of this particular block. |
accepted_file_extensions
¶
accepted_file_extensions = ('.xrdml', '.xy', '.dat', '.xye', '.rasx', '.cif', '.raw', '.brml')
data
¶
data = {'item_id': item_id, 'collection_id': collection_id, 'blocktype': blocktype, 'block_id': block_id, None: defaults}
events_by_name
¶
Returns a dict of registered events for this block.
from_web
¶
from_web(data: dict)
Initialise the block state from data passed via web request with a given item, collection and block ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The block data to initialiaze the block with. |
required |
generate_xrd_plot
¶
Generate a Bokeh plot potentially containing multiple XRD patterns.
This function will first check whether a file_id is set in the block data.
If not, it will interpret this as the "all compatible files" option, and will
look into the item data to find all attached files, and attempt to read them as
XRD patterns.
Otherwise, the file_id will be used to load a single file.
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_from_web(data: dict)
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary of data to update the block with. |
required |