FTIR
FTIRBlock
¶
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
¶
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
¶
Any default values that should be set if they are not supplied during block init.
description
¶
description = 'This block can plot FTIR data from .asp files generated by an Agilent Spectrometer'
A longer description outlining the purpose and capability of the block.
name
¶
name = 'FTIR'
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
|
null_event
¶
null_event(**kwargs)
A null debug event that does nothing but logs its kwargs and overwrites the data dict with the args.
parse_ftir_asp
¶
parse_ftir_asp(filename: Path) -> DataFrame
Parses .asp FTIR data generated by an Agilent Spectrometer
The file consists of a header with the number of points, the start and end wavenumber, a few lines of metadata, and then the absorbance data. This function reads the file, extracts the absorbance data, and returns it as a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path
|
Path to the .asp file |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
FTIR dataframe with columns "Wavenumber (cm⁻¹)" and "Absorbance (%)". |
parse_ftir_txt
¶
parse_ftir_txt(filename: Path) -> DataFrame
Parses .txt FTIR data generated by a Shimadzu IR Tracer-100 FT-IR spectrophotometer
The file consists of a header with metadata: a title, data type, x units and y units, and then the IR data This function reads the file and extracts the data as a pandas DataFrame, and the x units and y units as strings. This function does not read the original .ispd file generated by the spectrometer
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path
|
Path to the .txt file |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
FTIR dataframe with columns "Wavenumber (cm⁻¹)" and "Absorbance (%)". |
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
|