Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions brukerapi/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
UnsuportedDatasetType,
)
from .jcampdx import JCAMPDX
from .schemas import Schema2dseq, SchemaFid, SchemaRawdata, SchemaSer, SchemaTraj
from .schemas import Schema2dseq, SchemaFid, SchemaRawdata, SchemaTraj

LOAD_STAGES = {
"empty": 0,
Expand Down Expand Up @@ -60,12 +60,6 @@
"load": LOAD_STAGES["all"],
"mmap": False,
},
"ser": {
"parameter_files": ["acqp", "method"],
"property_files": [Path(__file__).parents[0] / "config/properties_ser_core.json", Path(__file__).parents[0] / "config/properties_ser_custom.json"],
"load": LOAD_STAGES["all"],
"mmap": False,
},
"rawdata": {
"parameter_files": ["acqp", "method"],
"property_files": [Path(__file__).parents[0] / "config/properties_rawdata_core.json", Path(__file__).parents[0] / "config/properties_rawdata_custom.json"],
Expand Down Expand Up @@ -144,7 +138,6 @@ class Dataset:
- **schema**:
- :py:class:`~brukerapi.schemas.SchemaFid`
- :py:class:`~brukerapi.schemas.Schema2dseq`
- :py:class:`~brukerapi.schemas.SchemaSer`
- :py:class:`~brukerapi.schemas.SchemaRawdata`

An object encapsulating all functionality dependent on metadata. It provides method to reshape data.
Expand Down Expand Up @@ -197,6 +190,9 @@ def __init__(self, path, **state):
self.subtype = self.subtype[1:] # remove the dot from the suffix
self._properties = []

if self.type not in DEFAULT_STATES:
raise UnsuportedDatasetType(self.type)

# set
self._set_state(state)

Expand Down Expand Up @@ -512,8 +508,6 @@ def load_schema(self):
self._schema = Schema2dseq(self)
elif self.type == "rawdata":
self._schema = SchemaRawdata(self)
elif self.type == "ser":
self._schema = SchemaSer(self)
elif self.type == "traj":
self._schema = SchemaTraj(self)

Expand All @@ -531,7 +525,7 @@ def load_data(self):
deserialized into a data array. The process of deserialization is different for each data set type and is
implemented in the individual subclasses of the :class:`brukerapi.schemas.Schema`,
i.e. :class:`brukerapi.schemas.SchemaFid`, :class:`brukerapi.schemas.Schema2dseq`,
:class:`brukerapi.schemas.SchemaRawdata`, :class:`brukerapi.schemas.SchemaSer`.
:class:`brukerapi.schemas.SchemaRawdata`.

If the object was created with random_access=True, the data is not read,
instead it can be accessed using sub-arrays.
Expand Down
22 changes: 0 additions & 22 deletions brukerapi/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,28 +462,6 @@ def serialize(self, data, layouts):
SchemaRawdata.seralize = SchemaRawdata.serialize


class SchemaSer(Schema):
@property
def layouts(self):
if self._layouts is not None:
return self._layouts

PVM_SpecMatrix = self._dataset.get_value("PVM_SpecMatrix")
PVM_Matrix = self._dataset.get_value("PVM_Matrix")
PVM_EncNReceivers = self._dataset.get_value("PVM_EncNReceivers")
layouts = {}
layouts["raw"] = (PVM_SpecMatrix, PVM_EncNReceivers, PVM_Matrix[0], PVM_Matrix[1])
return layouts

def deserialize(self, data):
data = data[0::2] + 1j * data[1::2]
data = np.reshape(data, self.layouts["raw"], order="F")
return data

def serialize(self, data):
raise NotImplementedError


class Schema2dseq(Schema):
"""
Schema2dseq class
Expand Down
9 changes: 9 additions & 0 deletions test/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@
import pytest

from brukerapi.dataset import Dataset
from brukerapi.exceptions import UnsuportedDatasetType

data = 0


def test_unsupported_dataset_type(tmp_path):
path = tmp_path / "unsupported"
path.touch()

with pytest.raises(UnsuportedDatasetType, match="Dataset type: unsupported is not supported"):
Dataset(path)


@pytest.mark.skip(reason="in progress")
def test_parameters(test_parameters):
dataset = Dataset(test_parameters[0], load=False)
Expand Down
3 changes: 1 addition & 2 deletions test/test_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from brukerapi.folders import Folder, Processing


def test_folder_traversal_skips_ser_and_processed_spectra(tmp_path):
def test_folder_traversal_skips_processed_spectra(tmp_path):
experiment_path = tmp_path / "1"
processing_path = experiment_path / "pdata" / "1"
processing_path.mkdir(parents=True)
Expand All @@ -11,7 +11,6 @@ def test_folder_traversal_skips_ser_and_processed_spectra(tmp_path):
experiment_path / "acqp",
experiment_path / "method",
experiment_path / "fid",
experiment_path / "ser",
processing_path / "visu_pars",
processing_path / "reco",
processing_path / "2dseq",
Expand Down