nmraspecds.analysis module
analysis module of the nmraspecds package.
- class nmraspecds.analysis.ChemicalShiftCalibration
Bases:
SingleAnalysisStep
Calculate offset between transmitter and current spectrometer frequency.
As ssNMR is seldom referenced internally, external referencing is necessary to determine the correct frequency of the spectrometer. This is done on a standard sample whose chemical shift is known and can be set manually. From this, the offset from the spectrometer’s frequency is determined (this step) and has to be transferred to the sample of interest (see
nmraspecds.processing.ExternalReferencing
). Of course, the sample has to get measured shortly before or after the reference compound to avoid drift of the magnetic field that occurs over time.Currently, the following standards are supported:
Substance
Name
Nucleus
chemical shift / ppm
Reference
Adamantane
adamantane
1H
1.8
[0]
Adamantane
adamantane
13C
37.77 (low field)
[0]
Ammoniumophosphate
NH4H2PO3
31P
1.33
[0]
Alanine
alanine
13C
176.8 (high field)
[0]
Q8M8
Q8M8
29Si
11.66
[1]
Al(H2O)3+
Aluminum
27Al
0
[0]
Q8M8 = Octakis(trimethylsiloxy)silsesquioxane
The column “name” here refers to the value the parameter
standard
can take (see below). These names are case-insensitive. If multiple peaks are present, the one indicated in the table above will be considered.Eventually, the offset is returned which corresponds to the “SR” value in Bruker’s TopSpin software.
References
[1] Solid State Nucl. Magn. Res. 1992, 1, 41 - 44
- parameters
All parameters necessary for this step.
- chemical_shift
float
Chemical shift the largest peaks should be shifted to.
- standard
str
Standard substance to take chemical shift from. Either the parameter “chemical_shift” or “standard” need to be provided.
- return_type
str
Defines, type of output, can be “value” or “dict”. The latter contains additional information e.g. type of nucleus.
Default: value
- Type:
- chemical_shift
- Returns:
Can be a single number or a dict. The dict additionally contains the nucleus that is given in the dataset. With this, in the next step, the offset is automatically converted if the dataset is acquired on another nucleus.
- Return type:
offset
- Raises:
ValueError – Either Standard sample or chemical shift to reference to needs to be provided.
Examples
- kind: singleanalysis type: ChemicalShiftCalibration properties: parameters: standard: adamantane nucleus: 1H result: offset
- add_preprocessing_step(processingstep=None)
Add a preprocessing step to the internal list.
Some analyses need some preprocessing of the data. These preprocessing steps are contained in the
preprocessing
attribute.- Parameters:
processingstep (
aspecd.processing.ProcessingStep
) – processing step to be added to the list of preprocessing steps
- analyse(dataset=None, from_dataset=False)
Perform the actual analysis step on the given dataset.
If no dataset is provided at method call, but is set as property in the SingleAnalysisStep object, the analyse method of the dataset will be called and thus the analysis added to the list of analyses of the dataset.
If no dataset is provided at method call nor as property in the object, the method will raise a respective exception.
The
aspecd.dataset.Dataset
object always call this method with the respective dataset as argument. Therefore, in this case setting the dataset property within theaspecd.analysis.SingleAnalysisStep
object is not necessary.The actual analysis step should be implemented within the non-public method
_perform_task()
. Besides that, the applicability of the analysis step to the given dataset will be checked automatically and the parameters will be sanitised by calling the non-public method_sanitise_parameters()
.Additionally, each dataset will be automatically checked for applicability, using the
aspecd.analysis.AnalysisStep.applicable()
method. Make sure to override this method according to your needs.- Parameters:
dataset (
aspecd.dataset.Dataset
) – dataset to perform analysis forfrom_dataset (boolean) –
whether we are called from within a dataset
Defaults to “False” and shall never be set manually.
- Returns:
dataset – dataset analysis has been performed for
- Return type:
- Raises:
aspecd.exceptions.NotApplicableToDatasetError – Raised when analysis step is not applicable to dataset
aspecd.exceptions.MissingDatasetError – Raised when no dataset exists to act on
- analyze(dataset=None, from_dataset=False)
Perform the actual analysis step on the given dataset.
Same method as self.analyse, but for those preferring AE over BE
- static applicable(dataset)
Check whether analysis step is applicable to the given dataset.
Returns True by default and needs to be implemented in classes inheriting from SingleAnalysisStep according to their needs.
This is a static method that gets called automatically by each class inheriting from
aspecd.analysis.AnalysisStep
. Hence, if you need to override it in your own class, make the method static as well. An example of an implementation testing for two-dimensional data is given below:@staticmethod def applicable(dataset): return len(dataset.data.axes) == 3
- Parameters:
dataset (
aspecd.dataset.Dataset
) – dataset to check- Returns:
applicable – True if successful, False otherwise.
- Return type:
- create_dataset()
Create calculated dataset containing minimal metadata.
The following metadata are set:
Metadata
Value
calculation.type
name
calculation.parameters
- Returns:
dataset – (Calculated) dataset containing minimal metadata.
- Return type:
Added in version 0.2.
- create_history_record()
Create history record to be added to the dataset.
Usually, this method gets called from within the
aspecd.dataset.analyse()
method of theaspecd.dataset.Dataset
class and ensures the history of each analysis step to get written properly.- Returns:
history_record – history record for analysis step
- Return type:
- to_dict(remove_empty=False)
Create dictionary containing public attributes of an object.
- Parameters:
remove_empty (
bool
) –Whether to remove keys with empty values
Default: False
- Returns:
public_attributes – Ordered dictionary containing the public attributes of the object
The order of attribute definition is preserved
- Return type:
Changed in version 0.6: New parameter remove_empty
Changed in version 0.9: Settings for properties to exclude and include are not traversed
Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables
__dict__
and__0dict__
are modified, what may result in strange behaviour.Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.