Data Structures Module

class beautifuljason.data.CustomData(h5_group)

Bases: IDedObject

Represents a custom data object at /JasonDocument/CustomData/<N>.

Custom data is typically written by plugins to store additional data in the document.

class List(h5_group)

Bases: GroupList

Represents a list of custom data objects

as_type(cls)

Cast this custom data object to the specified CustomData subclass.

Parameters:

cls – CustomData subclass.

Returns:

Instance of the specified subclass.

Raises:
  • TypeError – If cls is not a CustomData subclass.

  • ValueError – If the data_type_id does not match the subclass.

property data_type_id: str
Returns:

The UUID of the custom data type.

Return type:

str

class beautifuljason.data.Image(h5_group)

Bases: IDedObject

Represents an image data object /JasonDocument/General/Pixmaps/<N>

The image is stored in HDF5 format and can be accessed as a numpy array.

class List(h5_group)

Bases: GroupList

Represents a list of image data objects

property class_: bytes
Returns:

The image class attribute.

Return type:

bytes

property depth: int
Returns:

The image depth. 24 for RGB and 32 for RGBA

Return type:

int

property height: int
Returns:

The image height.

Return type:

int

property interlace_mode: bytes
Returns:

The image interlace mode attribute.

Return type:

bytes

property min_max_range: ndarray[uint8]
Returns:

The image min max range attribute.

Return type:

np.ndarray of np.uint8

property pixmap: ndarray[uint8]

Added in version 1.1.0.

The image data.

Returns:

The image data as a numpy array.

Return type:

np.ndarray of np.uint8

property subclass: bytes
Returns:

The image subclass attribute.

Return type:

bytes

property version: bytes
Returns:

The image version attribute.

Return type:

bytes

property width: int
Returns:

The image width.

Return type:

int

class beautifuljason.data.MSEntry(h5_group)

Bases: IDedObject, H5Group

Added in version 1.2.0.

Represents a mass spectrometry entry (experiment or dataset) stored within an HDF5 group.

Parameters:

h5_group – The actual HDF5 group object.

class List(h5_group)

Bases: GroupList

Represents a list of mass spectra.

Parameters:

h5_group – The actual HDF5 group object.

class MSSpectrum(h5_group)

Bases: H5Group

Represents a mass spectrum stored within an HDF5 group.

Parameters:

h5_group – The actual HDF5 group object.

class CentroidSpectrum(h5_group)

Bases: H5Group

Represents a centroid spectrum stored within an HDF5 group.

Parameters:

h5_group – The actual HDF5 group object.

property area: ndarray[float64]
Returns:

The area values of the centroid spectrum.

Return type:

numpy.ndarray with dtype numpy.float64

property fwhm: ndarray[float64]
Returns:

The full width at half maximum (FWHM m/z) values of the centroid spectrum.

Return type:

numpy.ndarray with dtype numpy.float64

property height: ndarray[float64]
Returns:

The height values of the centroid spectrum.

Return type:

numpy.ndarray with dtype numpy.float64

property mz: ndarray[float64]
Returns:

The m/z values of the centroid spectrum.

Return type:

numpy.ndarray with dtype numpy.float64

class List(h5_group)

Bases: GroupList

Represents a list of mass spectra.

Parameters:

h5_group – The actual HDF5 group object.

class PeakList(h5_group)

Bases: H5Group

Represents a list of peaks within a mass spectrum.

Parameters:

h5_group – The actual HDF5 group object.

property intensity: ndarray[float64]
Returns:

The intensity values of the peaks.

Return type:

numpy.ndarray with dtype numpy.float64

property mz: ndarray[float64]
Returns:

The m/z values of the peaks.

Return type:

numpy.ndarray with dtype numpy.float64

property centroid_spectrum: CentroidSpectrum
Returns:

The centroid spectrum of the mass spectrum.

Return type:

MSEntry.CentroidSpectrum

property intensities: Iterable[ndarray[float64]]
Returns:

The intensity values of the mass spectrum.

Return type:

base.DatasetList of numpy.ndarray with dtype numpy.float64

property mz: ndarray[float64]
Returns:

The m/z values of the mass spectrum.

Return type:

numpy.ndarray with dtype numpy.float64

property peak_list: PeakList
Returns:

The list of peaks within the mass spectrum.

Return type:

MSEntry.MSSpectrum.PeakList

property scans: List
Returns:

The associated list of mass spectra.

Return type:

MSEntry.MSSpectrum.List of MSEntry.MSSpectrum.

class beautifuljason.data.MSSpecInfo(h5_group)

Bases: SpecInfo

Added in version 1.2.0.

Represents spectral information for a mass spectrometry dataset encapsulated within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

class beautifuljason.data.Molecule(h5_group)

Bases: IDedObject

Represents a molecule data object from /JasonDocument/Molecules/Molecules/<N> groups.

class Atom(h5_group)

Bases: H5Group

Represents an atom.

class List(h5_group)

Bases: GroupList

Represents a list of atoms.

class NuclType(*values)

Bases: IntEnum

Nuclide types enumeration.

Ag107 = 60
Ag109 = 61
Al27 = 18
As75 = 43
Au197 = 111
B10 = 8
B11 = 9
Ba135 = 77
Ba137 = 78
Be9 = 7
Bi209 = 117
Br79 = 45
Br81 = 46
C13 = 10
Ca43 = 26
Cd111 = 62
Cd113 = 63
Cl35 = 22
Cl37 = 23
Co59 = 35
Cr53 = 32
Cs133 = 76
Cu63 = 37
Cu65 = 38
Dy161 = 91
Dy163 = 92
Er167 = 94
Eu151 = 86
Eu153 = 87
F19 = 14
Fe57 = 34
Ga69 = 40
Ga71 = 41
Gd155 = 88
Gd157 = 89
Ge73 = 42
H1 = 1
H2 = 2
H3 = 3
He3 = 4
Hf177 = 100
Hf179 = 101
Hg199 = 112
Hg201 = 113
Ho165 = 93
I127 = 73
In113 = 64
In115 = 65
Ir191 = 108
Ir193 = 109
K39 = 24
K41 = 25
Kr83 = 47
La138 = 79
La139 = 80
Li6 = 5
Li7 = 6
Lu175 = 98
Lu176 = 99
Mg25 = 17
Mn55 = 33
Mo95 = 54
Mo97 = 55
N14 = 11
N15 = 12
Na23 = 16
Nb93 = 53
Nd143 = 82
Nd145 = 83
Ne21 = 15
Ni61 = 36
O17 = 13
Os187 = 106
Os189 = 107
P31 = 20
Pb207 = 116
Pd105 = 59
Pr141 = 81
Pt195 = 110
Rb85 = 48
Rb87 = 49
Re185 = 104
Re187 = 105
Rh103 = 58
Ru101 = 57
Ru99 = 56
S33 = 21
Sb121 = 69
Sb123 = 70
Sc45 = 27
Se77 = 44
Si29 = 19
Sm147 = 84
Sm149 = 85
Sn115 = 66
Sn117 = 67
Sn119 = 68
Sr87 = 50
Ta181 = 102
Tb159 = 90
Te123 = 71
Te125 = 72
Ti47 = 28
Ti49 = 29
Tl203 = 114
Tl205 = 115
Tm169 = 95
U235 = 118
Undef = 0
V50 = 30
V51 = 31
W183 = 103
Xe129 = 74
Xe131 = 75
Y89 = 51
Yb171 = 96
Yb173 = 97
Zn67 = 39
Zr91 = 52
class Type(*values)

Bases: IntEnum

Atom elements enumeration.

A = 152
Ac = 89
Ag = 47
Al = 13
Am = 95
Ar = 18
As = 33
At = 85
Au = 79
B = 5
Ba = 56
Be = 4
Bh = 107
Bi = 83
Bk = 97
Br = 35
C = 6
Ca = 20
Cd = 48
Ce = 58
Cf = 98
Cl = 17
Cm = 96
Cn = 112
Co = 27
Cr = 24
Cs = 55
Cu = 29
Db = 105
Ds = 110
Dy = 66
El119 = 119
El120 = 120
El121 = 121
El122 = 122
El123 = 123
El124 = 124
El125 = 125
El126 = 126
El127 = 127
El128 = 128
El129 = 129
El130 = 130
El131 = 131
El132 = 132
El133 = 133
El134 = 134
El135 = 135
El136 = 136
El137 = 137
El138 = 138
El139 = 139
El140 = 140
El141 = 141
El142 = 142
El143 = 143
El144 = 144
El145 = 145
El146 = 146
El147 = 147
El148 = 148
El149 = 149
El150 = 150
Er = 68
Es = 99
Eu = 63
F = 9
FV = 151
Fe = 26
Fl = 114
Fm = 100
Fr = 87
Ga = 31
Gd = 64
Ge = 32
H = 1
He = 2
Hf = 72
Hg = 80
Ho = 67
Hs = 108
I = 53
In = 49
Ir = 77
K = 19
Kr = 36
L = 154
La = 57
Li = 3
Lr = 103
Lu = 71
Lv = 116
Mc = 115
Md = 101
Mg = 12
Mn = 25
Mo = 42
Mt = 109
N = 7
NL = 155
NONE = 0
Na = 11
Nb = 41
Nd = 60
Ne = 10
Nh = 113
Ni = 28
No = 102
Np = 93
O = 8
Og = 118
Os = 76
P = 15
Pa = 91
Pb = 82
Pd = 46
Pm = 61
Po = 84
Pr = 59
Pt = 78
Pu = 94
Q = 153
Ra = 88
Rb = 37
Re = 75
Rf = 104
Rg = 111
Rh = 45
Rn = 86
Ru = 44
S = 16
Sb = 51
Sc = 21
Se = 34
Sg = 106
Si = 14
Sm = 62
Sn = 50
Sr = 38
Ta = 73
Tb = 65
Tc = 43
Te = 52
Th = 90
Ti = 22
Tl = 81
Tm = 69
Ts = 117
U = 92
V = 23
W = 74
Xe = 54
Y = 39
Yb = 70
Zn = 30
Zr = 40
property bonded_atom_numbers: ndarray[uint32]
Returns:

The bonded atom numbers of the atom.

Return type:

np.ndarray of np.uint32

property bonded_atoms: list[Atom]
Returns:

The bonded atoms of the atom.

Return type:

list of Molecule.Atom

property bonds: ndarray[uint32]
Returns:

The bonds of the atom.

Return type:

np.ndarray of np.uint32

property charge: int | None
Returns:

The charge of the atom.

Return type:

int | None

property isotope: int | None
Returns:

The isotope of the atom.

Return type:

int | None

property nh: int
Returns:

The number of hydrogen atoms attached to the atom.

Return type:

int

property type: Type
Returns:

The type of the atom.

Return type:

Type

property valence: int | None
Returns:

The valence of the atom.

Return type:

int | None

property x: float
Returns:

The X coordinate of the atom.

Return type:

float

property y: float
Returns:

The Y coordinate of the atom.

Return type:

float

property z: float | None
Returns:

The Z coordinate of the atom if present.

Return type:

float | None

class CalcMethod(*values)

Bases: IntEnum

Chemical shift and J-coupling calculation methods enumeration.

Best = 5
Experimental = 1
Increment = 2
NeuralNetwork = 3
SphericCodes = 4
Undefined = 0
class Coupling(h5_group)

Bases: H5Group

Represents a j-coupling.

class List(h5_group)

Bases: GroupList

Represents a list of j-couplings.

property acount1: int
Returns:

The number of identical atoms of the first coupling partner.

Return type:

int

property acount2: int
Returns:

The number of identical atoms of the second coupling partner.

Return type:

int

property error_spheres: int
Returns:

The error spheres of the coupling.

Return type:

int

get_value_error_pair(method: CalcMethod) tuple[float | None, float | None]

Returns the J value and its error for the specified calculation method.

Parameters:

method (CalcMethod) – The calculation method to look for.

Returns:

Tuple of (value, error) corresponding to the method, or (None, None) if not found.

Return type:

tuple[float | None, float | None]

property ignored_auto: bool
Returns:

Whether the coupling is ignored automatically.

Return type:

bool

property ignored_user: bool
Returns:

Whether the coupling is ignored by the user.

Return type:

bool

property is_exchangeable1: bool
Returns:

Whether the first coupling partner is exchangeable.

Return type:

bool

property is_exchangeable2: bool
Returns:

Whether the second coupling partner is exchangeable.

Return type:

bool

property jvalue: int
Returns:

Number of bonds between the coupling partners.

Return type:

int

property mark1: str | None
Returns:

The mark of the first coupling partner if present.

Return type:

str | None

property mark2: str | None
Returns:

The mark of the second coupling partner if present.

Return type:

str | None

property n1: uint32
Returns:

The first atom number of the coupling.

Return type:

np.uint32

property n2: uint32
Returns:

The second atom number of the coupling.

Return type:

np.uint32

property nucl1: NuclType
Returns:

The nuclide type of the first coupling partner.

Return type:

Molecule.Atom.NuclType

property nucl2: NuclType
Returns:

The nuclide type of the second coupling partner.

Return type:

Molecule.Atom.NuclType

property value: ndarray[float64]
Returns:

array of experimental and calculated J values of the coupling.

Return type:

np.ndarray of np.float64

property value_error: ndarray[float64]
Returns:

array of calculated J value errors of the coupling.

Return type:

np.ndarray of np.float64

property value_method: Iterable[CalcMethod]
Returns:

array of value calculation methods of the coupling.

Return type:

Iterable of Molecule.CalcMethod

property value_spheres: int
Returns:

The value spheres of the coupling.

Return type:

int

class List(h5_group)

Bases: GroupList

Added in version 1.1.0.

Represents a list of molecules.

class Ring(h5_group)

Bases: H5Group

Represents a ring.

class List(h5_group)

Bases: GroupList

Represents a list of rings.

Parameters:

h5_group (h5py.Group) – The H5 group.

property atoms: ndarray[uint32]
Returns:

The atoms of the ring.

Return type:

np.ndarray of np.uint32

property is_aromatic: bool
Returns:

Whether the ring is aromatic.

Return type:

bool

class Spectrum(h5_group)

Bases: H5Group

Represents a prediction spectrum.

class List(h5_group)

Bases: GroupList

Represents a list of prediction spectra.

class Shift(h5_group)

Bases: H5Group

Represents a chemical shift.

class List(h5_group)

Bases: GroupList

Represents a list of chemical shifts.

property acount: int
Returns:

The number of identical atoms of the chemical shift.

Return type:

int

property error_spheres: int
Returns:

The error spheres of the chemical shift.

Return type:

int

get_value_error_pair(method: CalcMethod) tuple[float | None, float | None]

Returns the chemical shift value and its error for the specified calculation method.

Parameters:

method (CalcMethod) – The calculation method to look for.

Returns:

Tuple of (value, error) corresponding to the method, or (None, None) if not found.

Return type:

tuple[float | None, float | None]

property ignored_auto: bool
Returns:

Whether the chemical shift is ignored automatically.

Return type:

bool

property ignored_user: bool
Returns:

Whether the chemical shift is ignored by the user.

Return type:

bool

property is_exchangeable: bool
Returns:

Whether the chemical shift is exchangeable.

Return type:

bool

property mark: str | None
Returns:

The mark of the chemical shift if present.

Return type:

str | None

property nh: int
Returns:

The number of hydrogen atoms attached to the atom.

Return type:

int

property nums: ndarray[uint32]
Returns:

The atom numbers of the chemical shift.

Return type:

np.ndarray of np.uint32

property value: ndarray[float64]

The experimental and calculated chemical shift values.

Each value corresponds to a different calculation method. See value_method for the calculation methods.

Returns:

The experimental and calculated chemical shift values. Each value corresponds to a different calculation method.

Return type:

np.ndarray of np.float64

property value_error: ndarray[float64]
Returns:

The calculated chemical shift errors. The value at index 0, corresponding to the experimental chemical shift, is -1.

Return type:

np.ndarray of np.float64

property value_method: Iterable[CalcMethod]
Returns:

The calculation methods for the chemical shift values.

Return type:

Iterable of CalcMethod

property value_spheres: int
Returns:

The value spheres of the chemical shift.

Return type:

int

class Type(*values)

Bases: IntEnum

Spectrum types enumeration.

ADEQUATE = 16
APT = 4
All = 28
C13 = 27
COLOC = 14
COSY = 5
Chrom = 23
DEPT135 = 3
DEPT45 = 24
DEPT90 = 2
H1 = 26
H2BC = 15
HETCOR = 12
HMBC = 13
HMQC = 10
HSQC = 9
HSQC_DEPT135 = 25
HSQC_TOCSY = 11
INADEQUATE = 17
IR = 21
Long_2D = 19
Mass = 20
NOESY = 7
Near_2D = 18
ROESY = 8
STD = 1
TOCSY = 6
UV = 22
Undef = 0
property nucleus: NuclType
Returns:

The nucleus of the spectrum.

Return type:

Molecule.Atom.NuclType

property origin: int
Returns:

The origin of the spectrum.

Return type:

int

property shifts: List
Returns:

The chemical shifts of the spectrum.

Return type:

Shift.List of Molecule.Spectrum.Shift

Example Usage:

import beautifuljason as bjason

# It is assumed that the 'example.jjh5' document contains a molecule.
with bjason.Document('example.jjh5', mode='r') as doc:
    for pred_spec in doc.mol_data[0].spectra:
        print(f'Nucleus: {pred_spec.nucleus.name}')
        for shift in pred_spec.shifts:
            print(f'  Atoms: {shift.nums}, Shift: {shift.value[0]} ppm')
property spec_type: Type
Returns:

The type of the spectrum.

Return type:

Type

class Symmetry(h5_group)

Bases: H5Group

Represents atom symmetry.

property items: Iterable[int]
Returns:

The symmetry items.

Return type:

Iterable of int

property atoms: List
Returns:

The atoms of the molecule.

Return type:

Atom.List of Molecule.Atom

property couplings: List
Returns:

The j-couplings of the molecule.

Return type:

Coupling.List of Molecule.Coupling

property rings: List
Returns:

The rings of the molecule.

Return type:

Ring.List of Molecule.Ring

property spectra: List
Returns:

The prediction spectra of the molecule.

Return type:

Spectrum.List of Molecule.Spectrum

Example Usage:

import beautifuljason as bjason

# It is assumed that the 'example.jjh5' document contains a molecule.
with bjason.Document('example.jjh5', mode='r') as doc:
    for pred_spec in doc.mol_data[0].spectra:
        print(f'Nucleus: {pred_spec.nucleus.name}')
        for shift in pred_spec.shifts:
            print(f'  Atoms: {shift.nums}, Shift: {shift.value[0]} ppm')
property symmetry: Symmetry
Returns:

The symmetry of the molecule.

Return type:

Symmetry

class beautifuljason.data.NMRBasePeak(h5_group)

Bases: IDedObject

Represents an NMR base peak stored within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

property height: float64
Returns:

The height of the peak.

Return type:

numpy.float64

property pos: ndarray[float64]
Returns:

The position of the peak.

Return type:

numpy.ndarray of shape (3,) with dtype numpy.float64

property width: ndarray[float64]
Returns:

The width of the peak.

Return type:

numpy.ndarray of shape (3,) with dtype numpy.float64

class beautifuljason.data.NMRBin(h5_group)

Bases: IDedObject

Added in version 1.2.0.

Represents an NMR bin stored within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

class List(h5_group)

Bases: IDedObject, GroupList

Added in version 1.2.0.

Represents a list of NMR bins.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

class AutoBinOptions(h5_group)

Bases: H5Group

Added in version 1.2.0.

Represents automatic binning options.

class Method(*values)

Bases: IntEnum

ADAPTIVE = 1
EQUAL = 0
property bin_width: float64
Returns:

The bin width.

Return type:

numpy.float64

property method: Method
Returns:

The auto-binning method.

Return type:

Method

property unit: Units
Returns:

The unit used for bin width.

Return type:

base.Units

property auto_bin_options: AutoBinOptions | None
Returns:

Automatic binning options, or None if not present.

Return type:

AutoBinOptions or None

property max_dimension: int
Returns:

The maximum dimension supported by the bins.

Return type:

int

property pos_units: tuple[Units, Units, Units]
Returns:

A tuple of position units.

Return type:

tuple of base.Units

bin_pos(dim: int = 0) float
Parameters:

dim (int) – The dimension index.

Returns:

The center position of the bin in the selected dimension.

Return type:

float

property bin_scope: int8
Returns:

The scope associated with the bin.

Return type:

numpy.int8

property range: tuple[ndarray, ndarray, ndarray]
Returns:

The bin range as a tuple of np.array objects.

Return type:

tuple of shape (3,) of numpy.ndarray with dtype numpy.float64

property value_average: float64
Returns:

The average value in the bin.

Return type:

numpy.float64

property value_sum: float64
Returns:

The sum of values in the bin.

Return type:

numpy.float64

class beautifuljason.data.NMRDosyPeak(h5_group)

Bases: NMRBasePeak

Represents a DOSY peak stored within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

class List(h5_group)

Bases: IDedObject, GroupList

Represents a list of DOSY peaks.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

property pos_units: tuple[Units, Units, Units]

Returns the position units of the DOSY peaks.

Returns:

A tuple of position units.

Return type:

tuple of base.Units

class beautifuljason.data.NMREntry(h5_group)

Bases: H5Group

Represents an NMR entry encapsulated within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

create_unit_converter(dim: int = 0) NMRUnitConverter

Added in version 1.2.0.

Create a unit converter for the selected spectral dimension.

The spectral dimension order follows JASON’s SpecInfo convention, while the numpy array shape is reversed for multidimensional spectra.

Parameters:

dim (int) – Spectral dimension index.

Returns:

Unit converter for the selected dimension.

Return type:

NMRUnitConverter

property ndim

Retrieve the number of dimensions for the NMR data. Provided for convenience, as the value is not directly available in the HDF5 group.

Returns:

Number of dimensions for the NMR data.

Return type:

int

points_count(dim: int = 0) int

Added in version 1.2.0.

Return the number of stored data points for the selected spectral dimension.

The spectral dimension order follows JASON’s SpecInfo convention, while the numpy array shape is reversed for multidimensional spectra.

Parameters:

dim (int) – Spectral dimension index.

Returns:

Number of stored data points along the selected dimension.

Return type:

int

class beautifuljason.data.NMRMultiplet(h5_group)

Bases: IDedObject

Represents an NMR multiplet stored within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

class List(h5_group)

Bases: IDedObject, GroupList

Represents a list of NMR multiplets.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

property auto_baseline
Returns:

True if the baseline is automatically calculated, otherwise False.

Return type:

bool

property integral_lvl
Returns:

integral level of the multiplets.

Return type:

float

property integral_scale
Returns:

integral scale of the multiplets.

Return type:

float

property integral_scale_scoped
Returns:

array of scoped integral scales of the multiplets.

Return type:

numpy.ndarray of numpy.float64 or None

property integral_tlt
Returns:

integral tilt of the multiplets.

Return type:

float

property integral_total
Returns:

total integral of the multiplets.

Return type:

float

property integral_vscale
Returns:

integral vertical scale of the multiplets.

Return type:

float

property integral_vshift
Returns:

integral vertical shift of the multiplets.

Return type:

float

property pos_units
Returns:

A tuple of position units.

Return type:

tuple of Units

class ShowType(*values)

Bases: IntEnum

Enumeration representing the types of display for the multiplet.

Integral = 1
Multiplet = 0
_get_peaks(attr_name) list[NMRPeak]
Parameters:

attr_name (str) – The name of the attribute to retrieve the peaks from.

Returns:

The peaks associated with the attribute.

Return type:

list of NMRPeak

property all_peaks: list[NMRPeak]
Returns:

All peaks found within the multiplet region, including those not associated with the multiplet.

Return type:

list of NMRPeak

property curve: ndarray[float64]
Returns:

The curve data for the multiplet.

Return type:

numpy.ndarray with dtype numpy.float64

property flags: int32
Returns:

The flags associated with the multiplet.

Return type:

int

property integral_scope: int32
Returns:

The scope for the integral. Defaults to 0 if not specified in the HDF5 group.

Return type:

numpy.int32

property js: ndarray[float64]
Returns:

The J values for the multiplet. If not present, returns an empty array.

Return type:

numpy.ndarray with dtype numpy.float64

property jtree
Returns:

The J coupling tree data, represented as a list of dictionaries with ‘groups’ and ‘positions’ as keys.

Return type:

list of dict with keys ‘groups’ and ‘positions’

property moments: ndarray[float64]
Returns:

The moments associated with the multiplet.

Return type:

numpy.ndarray with dtype numpy.float64

property multiplets
Returns:

The associated list of multiplets.

Return type:

NMRMultiplet.List or None if not present.

property multiplicities: ndarray[int32]
Returns:

The multiplicities for the multiplet. If not present, returns an empty array.

Return type:

numpy.ndarray with dtype numpy.int32

property multiplicities_str: str | None
Returns:

The multiplicities for the multiplet as a string.

Return type:

str or None if not present.

property normalized_value
Returns:

The normalized value of the multiplet.

Return type:

numpy.float64

property peaks: list[NMRPeak]
Returns:

The peaks associated with the multiplet.

Return type:

list of NMRPeak

Example Usage:

import beautifuljason as bjason

# It is assumed that the 'example.jjh5' document contains a spectrum with multiplets.
with bjason.Document('example.jjh5', mode='r') as doc:
    for multiplet in doc.nmr_data[0].multiplets:
        print(f'Pos: {multiplet.pos[0]}, Sum Integral: {multiplet.value_hz}')
        for peak in multiplet.peaks:
            print(f'  Peak Pos: {peak.pos[0]}, Area: {peak.area}')
property pos: ndarray[float64]
Returns:

The position of the multiplet.

Return type:

numpy.ndarray of shape (3,) with dtype numpy.float64

property range: tuple[ndarray, ndarray, ndarray]
Returns:

The multiplet range as a tuple of np.array objects.

Return type:

tuple of shape (3,) of numpy.ndarray with dtype numpy.float64

property show_type: ShowType
Returns:

The display type of the multiplet.

Return type:

ShowType

property value
Returns:

The value of the multiplet.

Return type:

numpy.float64

property value_hz
Returns:

The value in Hertz (Hz) of the multiplet.

Return type:

numpy.float64

property value_hz_factor
Returns:

The factor to convert the value to Hertz (Hz). Defaults to 1.0 if not specified in the HDF5 group.

Return type:

numpy.float64

class beautifuljason.data.NMRPeak(h5_group)

Bases: NMRBasePeak

Represents an NMR peak stored within an HDF5 group.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

class List(h5_group)

Bases: IDedObject, GroupList

Represents a list of NMR peaks.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

property pos_units: tuple[Units, Units, Units]

Returns the position units of the peaks.

Returns:

A tuple of position units.

Return type:

tuple of base.Units

class PeakClassification(*values)

Bases: IntEnum

Enumeration representing the classifications of peaks.

C13Satellite = 4
Compound = 0
Contaminant = 1
NMRSolvent = 2
ReactionSolvent = 3
SSSideband = 5
class PeakType(*values)

Bases: IntEnum

Enumeration representing the types of peaks.

GenLorentz = 1
PseudoVoigt = 0
property area: float64

Added in version 1.0.4.

Returns:

The area of the peak.

Return type:

numpy.float64

Note

Requires JASON 4.1 or later.

property area_sigma: float64

Added in version 1.0.4.

Returns:

The area sigma of the peak.

Return type:

numpy.float64

Note

Requires JASON 4.1 or later.

property classification: PeakClassification

The classification of the peak.

Getter:

Returns the classification of the peak.

Return type:

PeakClassification

Setter:

Sets the classification of the peak.

Parameters:

new_classification (PeakClassification) – The new classification of the peak.

property label

The label of the peak.

Getter:

Returns the label of the peak.

Return type:

str

Setter:

Sets the label of the peak.

Parameters:

new_label (str) – The new label of the peak.

property offset: float64
Returns:

The offset of the peak.

Return type:

numpy.float64

property shape_par: ndarray[float64]
Returns:

The shape parameter of the peak.

Return type:

numpy.ndarray of shape (3,) with dtype numpy.float64

property type
Returns:

The type of the peak.

Return type:

PeakType

class beautifuljason.data.NMRProcessing(h5_group)

Bases: IDedObject

Represents an NMR processing step stored within an HDF5 group.

Parameters:

h5_group – The actual HDF5 group object.

class List(h5_group)

Bases: GroupList

Represents a list of NMR processing steps.

Parameters:

h5_group – The actual HDF5 group object.

class EndType(*values)

Bases: IntEnum

Enumeration representing the types of endpoints.

Full = 0
Orig = 1
postFT = 3
preFT = 2
property end_point_dim: int32
Returns:

The dimension of the endpoint.

Return type:

numpy.int32

property end_point_type: EndType
Returns:

The type of endpoint.

Return type:

EndType

class Parameter(h5_group)

Bases: H5Group

Represents a parameter for an NMR processing step.

class List(h5_group)

Bases: GroupList

Represents a list of parameters for an NMR processing step.

property current_index: int32 | None
Returns:

The current index for the parameter.

Return type:

numpy.int32 or None if not present.

property decimals: int32 | None
Returns:

The number of decimals for the parameter.

Return type:

numpy.int32 or None if not present.

property max_value: Any | None
Returns:

The maximum value for the parameter.

Return type:

Any or None if not present.

property min_value: Any | None
Returns:

The minimum value for the parameter.

Return type:

Any or None if not present.

property name: str
Returns:

The name of the parameter.

Return type:

str

property step: float64 | None
Returns:

The step size for the parameter.

Return type:

numpy.float64 or None if not present.

property tip: str
Returns:

The tip for the parameter.

Return type:

str

property units: Units
Returns:

The units for the parameter.

Return type:

base.Units

property value: Any
Returns:

The value of the parameter.

Return type:

Any

property value_type: QMetaType_Type
Returns:

The type of the parameter.

Return type:

base.QMetaType_Type

class Type(*values)

Bases: IntEnum

Enumeration representing the types of processing steps.

ATD = 33
Abs = 8
Apodize = 2
CSSF = 19
Compress = 37
Cov = 41
Custom = 39
DC = 26
DOSY = 24
DTA = 25
DcFID = 40
DownSample = 45
External = 14
FT = 4
Fiddle = 38
Filter = 32
Flatten = 12
Lp = 3
NUS = 15
NextDim = 9
NoiseGen = 34
Normalize = 42
PeakRef = 29
Phase = 6
PhaseFID = 23
PolyBC = 11
PrepIndir = 5
ROSY = 36
ReSample = 35
Real = 13
Reverse = 7
Rot = 21
Round = 44
SGFilter2D = 18
SGSmooth = 10
Scale = 27
Shear = 46
Sim = 20
Sub = 17
Sum = 28
Sym = 16
T1Sup = 30
Tilt = 47
Unknown = 0
ZF = 1
bLP = 43
fLP = 31
iFT = 22
property active: bool
Returns:

True if the processing step is active, otherwise False.

Return type:

bool

property name: str
Returns:

The name of the processing step.

Return type:

str

property parameters: List

Added in version 1.1.0.

Returns:

The list of parameters for the processing step.

Return type:

Parameter.List

property type: Type
Returns:

The type of the processing step.

Return type:

Type

class beautifuljason.data.NMRSpecInfo(h5_group, ndim)

Bases: SpecInfo

Represents spectral information for an NMR dataset encapsulated within an HDF5 group.

Parameters:
  • h5_group (h5py.Group) – The actual HDF5 group object.

  • ndim (int) – The number of dimensions for the NMR data.

create_unit_converter(points_count: int, dim: int = 0) NMRUnitConverter

Added in version 1.2.0.

Create a unit converter for the selected spectral dimension.

The converter follows the same PPM/FPTS mapping as JASON and can be used to convert between ppm values, floating-point spectral positions, and integer array indices.

Parameters:
  • points_count (int) – Number of data points along the selected dimension.

  • dim (int) – Spectral dimension index.

Returns:

Unit converter for the selected dimension.

Return type:

NMRUnitConverter

property nuclides

Retrieve the nuclide information for each dimension of the NMR data. Provided for convenience, as the value is not readily accessible in the HDF5 group.

Returns:

A tuple of nuclide strings for each dimension.

Return type:

tuple

class beautifuljason.data.NMRSpectrum(h5_group)

Bases: NMREntry, IDedObject

Represents an NMR spectrum stored within an HDF5 group.

Parameters:

h5_group – The actual HDF5 group object.

class List(h5_group)

Bases: GroupList

Represents a list of NMR spectra.

Parameters:

h5_group – The actual HDF5 group object.

property bins: List

Added in version 1.2.0.

Returns:

The associated list of bins, or None if not present.

Return type:

NMRBin.List or None.

property dosy_peaks: List

Added in version 1.2.0.

Returns:

The associated list of DOSY peaks, or None if not present.

Return type:

NMRDosyPeak.List or None.

Example Usage:

import beautifuljason as bjason

with bjason.Document('example.jjh5', mode='r') as doc:
    dosy_peaks = doc.nmr_data[0].dosy_peaks
    if dosy_peaks is not None:
        for peak in dosy_peaks:
            print(f'Pos: {peak.pos[0]}, D: {peak.pos[1]}')
property multiplets: List
Returns:

The associated list of multiplets.

Return type:

NMRMultiplet.List of NMRMultiplet.

Example Usage:

import beautifuljason as bjason

# It is assumed that the 'example.jjh5' document contains a spectrum with multiplets.
with bjason.Document('example.jjh5', mode='r') as doc:
    for multiplet in doc.nmr_data[0].multiplets:
        print(f'Pos: {multiplet.pos[0]}, Sum Integral: {multiplet.value_hz}')
property peaks: List
Returns:

The associated list of peaks.

Return type:

NMRPeak.List of NMRPeak.

Example Usage:

import beautifuljason as bjason

# It is assumed that the 'example.jjh5' document contains a spectrum with peaks.
with bjason.Document('example.jjh5', mode='r') as doc:
    for peak in doc.nmr_data[0].peaks:
        print(f'Pos: {peak.pos[0]}, Area: {peak.area}')
property proc_list: List
Returns:

The associated list of processing steps.

Return type:

NMRProcessing.List of NMRProcessing.

Example Usage:

import beautifuljason as bjason

# It is assumed that the 'example.jjh5' document contains a spectrum.
with bjason.Document('example.jjh5', mode='r') as doc:
    for proc in doc.nmr_data[0].proc_list:
        print(f'Name: {proc.name}')
        for param in proc.parameters:
            print(f'  {param.name}({param.tip}): {param.value}')
class beautifuljason.data.NMRUnitConverter(spectral_width: float, spectrum_ref: float, spectrometer_frequency: float, points_count: int)

Bases: object

Added in version 1.2.0.

Convert between NMR units for a selected spectrum dimension.

The implementation follows the same formulas used by JASON. It supports frequency-domain conversions between HZ, KHZ, MHZ, PPM, and FPTS, as well as time-domain conversions between S, MS, US, NS, TPTS, and TVIRT.

Parameters:
  • spectral_width (float) – Spectral width in Hz.

  • spectrum_ref (float) – Spectrum reference in Hz.

  • spectrometer_frequency (float) – Spectrometer frequency in MHz.

  • points_count (int) – Number of points along the dimension.

_from_base_units(value: float | ndarray, units: Units) float | ndarray
static _points_units(units: Units) Units
_ppm_factor() float
_to_base_units(value: float | ndarray, units: Units) float | ndarray
static _unit_type(units: Units) str
convert(value: float | ndarray, from_units: Units, to_units: Units) float | ndarray

Convert a value between supported NMR units.

The conversion follows the same “convert to base unit, then convert from base unit” logic as JASON. Only conversions within the same unit type are allowed.

Parameters:
  • value (float or numpy.ndarray) – Value or values to convert.

  • from_units (base.Units) – Source units.

  • to_units (base.Units) – Target units.

Returns:

Converted value or values.

Return type:

float or numpy.ndarray

hz_to_point(hz: float | ndarray) float | ndarray

Convert a value in Hz to a floating-point spectral position.

Parameters:

hz (float or numpy.ndarray) – Position in Hz.

Returns:

Position converted to FPTS.

Return type:

float or numpy.ndarray

index_to(index: int | ndarray, to_units: Units) float | ndarray

Convert an array index to the requested units.

The point units are inferred from the target unit type: FPTS for frequency-domain units and TPTS for time-domain units.

Parameters:
  • index (int or numpy.ndarray) – Array index or indices.

  • to_units (base.Units) – Target units.

Returns:

Converted value or values.

Return type:

float or numpy.ndarray

index_to_ppm(index: int | ndarray) float | ndarray

Convert an integer array index to ppm.

Parameters:

index (int or numpy.ndarray) – Array index or indices.

Returns:

Position converted to ppm.

Return type:

float or numpy.ndarray

point_to_hz(point: float | ndarray) float | ndarray

Convert a floating-point spectral position to Hz.

Parameters:

point (float or numpy.ndarray) – Spectral position in FPTS.

Returns:

Position converted to Hz.

Return type:

float or numpy.ndarray

point_to_ppm(point: float | ndarray) float | ndarray

Convert a floating-point spectral position to ppm.

Parameters:

point (float or numpy.ndarray) – Spectral position in FPTS.

Returns:

Position converted to ppm.

Return type:

float or numpy.ndarray

property ppm_scale: ndarray[float64]

Return the ppm value corresponding to each array index.

Returns:

ppm scale for all array indices.

Return type:

numpy.ndarray with dtype numpy.float64

ppm_to_index(ppm: float | ndarray) int | ndarray

Convert ppm to the nearest valid array index.

Values outside the spectral range are clipped to the nearest valid index.

Parameters:

ppm (float or numpy.ndarray) – Position in ppm.

Returns:

Closest valid array index or indices.

Return type:

int or numpy.ndarray

ppm_to_point(ppm: float | ndarray) float | ndarray

Convert a value in ppm to a floating-point spectral position.

Parameters:

ppm (float or numpy.ndarray) – Position in ppm.

Returns:

Position converted to FPTS.

Return type:

float or numpy.ndarray

to_index(value: float | ndarray, from_units: Units) int | ndarray

Convert a value to the nearest valid array index.

The point units are inferred from the source unit type: FPTS for frequency-domain units and TPTS for time-domain units.

Parameters:
  • value (float or numpy.ndarray) – Value or values to convert.

  • from_units (base.Units) – Source units.

Returns:

Closest valid array index or indices.

Return type:

int or numpy.ndarray

class beautifuljason.data.SMILEQData(h5_group)

Bases: CustomData

class AnalyticalOption(*values)

Bases: IntEnum

PEAK = 1
SUM = 0
DATA_TYPE_ID = '{23ff9615-fd08-4a8f-bb31-d68f6b51e26d}'
class EntryType(*values)

Bases: IntEnum

ANALYTE_AND_REFERENCE = 0
ANALYTE_ONLY = 1
REFERENCE_ONLY = 2
class ExternalReferenceOption(*values)

Bases: IntEnum

AVERAGE = 0
EACH = 1
class ParameterMode(*values)

Bases: IntEnum

MOLARITY_AND_PURITY = 0
MOLARITY_ONLY = 1
PURITY_ONLY = 2
class Quantities(h5_group)

Bases: GroupList

Represents a list of quantities and SMILEQ calculation parameters.

property analyte_mol_mass
property analyte_type
Returns:

1 for mixture, 0 otherwise

property analyte_volume
property analyte_weight
property analytical_option: AnalyticalOption
property external_factor
property is_apply_solcor: bool
property is_external_standard: bool
property is_mixture: bool
property parameter_mode: ParameterMode
property pulcon_parameters: tuple[int, int, int, int]
property reference_mol_mass
property reference_purity
property reference_variance: tuple[float, ...]
property reference_volume: tuple[float, ...]
property reference_weight: tuple[float, ...]
property smileq_id: str
class Quantity(h5_group)

Bases: H5Group

Represents a quantity in SMILEQ data.

class CalcResult(attrs)

Bases: object

Represents the calculation result for a quantity.

ZERO_UUID = '{00000000-0000-0000-0000-000000000000}'
property average
property average_sd
property reference_ids
Returns:

List of reference IDs.

Return type:

list[str]

reference_sd(reference_id: str)
Parameters:

reference_id – The reference ID to look for.

Returns:

Calculation result standard deviation corresponding to the reference ID, or None if not found.

reference_value(reference_id: str)
Parameters:

reference_id – The reference ID to look for.

Returns:

Calculation result value corresponding to the reference ID, or None if not found.

property references
Returns:

Mapping reference_id -> (value, sd)

Return type:

dict[str, tuple[float | None, float | None]]

property analyte_name: str
property integral_id: str
property is_used_in_calculation: bool
property molar_weight
property molarity: CalcResult
property protons
property purity: CalcResult
class ReferenceRange(h5_group)

Bases: H5Group

Represents a reference range entry in SMILEQ data.

class List(h5_group)

Bases: GroupList

Represents a list of SMILEQ reference ranges.

property integral_id: str
property molar_mass: float | None
property molarity: float | None
property nmr_entry_id: str | None
property nuclides: int
property purity: float | None
property range: tuple[float, float] | None
property volume: float | None
property weight: float | None
static _first_float_or_none(value) float | None
property analysis_file: str
property analytical_option: AnalyticalOption
property ccf_value
property dccf_value
property entry_type: EntryType
property external_factor
property external_reference_option: ExternalReferenceOption
property is_apply_solcor: bool
property is_external_standard: bool
property is_use_ccf: bool
property mixed_analytes: dict[str, float]
property noise_region: tuple[float, float]
property noise_region_unit: Units
property parameter_mode: ParameterMode
property processing_file: str
property pulcon_parameters: tuple[int, int, int, int]
property quantities: Quantities
property ref_nmr_entry_ids: list[str]
property reference_mol_mass: float
property reference_molary
property reference_name: str
property reference_purity: float
property reference_ranges: List
property reference_volume: float
property reference_weight: float
property result_digit
property sample_mol_mass: float
property sample_name: str
property sample_volume: float
property sample_weight: float
property smileq_version
property sort_column
property sort_order
class beautifuljason.data.SpecInfo(h5_group)

Bases: H5Group

Added in version 1.2.0.

Represents spectral information for a dataset encapsulated within an HDF5 group. This class is common to various types of spectral data, including NMR, MS, EDS and others.

Parameters:

h5_group (h5py.Group) – The actual HDF5 group object.

get_orig_param(group_name, param_name)

Retrieve an original parameter value from a specified group within the OriginalParameters section of the HDF5 group. Original parameters are values imported directly from the original dataset without modification. For some vendors, parameters may include attributes written using the syntax param_name.attr_name. For example, the JEOL Delta X_FREQ parameter also includes X_FREQ.unts and X_FREQ.unts.str attributes.

Parameters:
  • group_name (str) – Name of the group under ‘OriginalParameters’ to search in.

  • param_name (str) – Name of the parameter to retrieve.

Returns:

Value of the specified parameter if found; None otherwise.

Return type:

Any or None

Example Usage

import beautifuljason as bjason

def extract_metadata(jdf_file: str) -> dict:
    jason = bjason.JASON()
    with jason.create_document(jdf_file) as doc:
        raw_spec_info = doc.nmr_data[0].raw_data.spec_info

        # Extract example metadata
        metadata = {
            "X_SWEEP": raw_spec_info.get_orig_param("parameters", "X_SWEEP"),
            "X_FREQ": raw_spec_info.get_orig_param("parameters", "X_FREQ")
        }

    return metadata
get_param(param_name)

Retrieve a parameter value from the HDF5 group.

Unlike original parameters (see get_orig_param()), these parameters are part of a predefined set that is populated using vendor data.

Parameters:

param_name (str) – Name of the parameter to retrieve.

Returns:

Value of the specified parameter if found; None otherwise.

Return type:

Any or None

Example Usage

import beautifuljason as bjason

def extract_metadata(jdf_file: str) -> dict:
    jason = bjason.JASON()
    with jason.create_document(jdf_file) as doc:
        raw_spec_info = doc.nmr_data[0].raw_data.spec_info

        # Extract example metadata
        metadata = {
            "Title": bjason.utils.ensure_str(raw_spec_info.get_param("Title")),
            "Solvent": bjason.utils.ensure_str(raw_spec_info.get_param("Solvent")),
            "Temperature": raw_spec_info.get_param("Temperature")
        }

    return metadata
class beautifuljason.data.Text(h5_group)

Bases: IDedObject

Represents a text data object located at /JasonDocument/General/TextDocuments/<N>.

The text is stored as an HTML string.

class List(h5_group)

Bases: GroupList

Represents a list of text data objects

property html: str

The HTML text.

Getter:

Returns the HTML text.

Return type:

str

Setter:

Sets the HTML text.

Parameters:

new_html (str) – The new HTML text.