Skip to content

Commit

Permalink
Merge pull request #99 from h2020charisma/brukeropusreader
Browse files Browse the repository at this point in the history
Replace opusFC with brukeropusreader
  • Loading branch information
kerberizer authored Dec 1, 2023
2 parents 29bbd85 + 346107d commit 19cfacb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
asteval==0.9.29
brukeropusreader==1.3.4
contourpy==1.0.7
cycler==0.11.0
fonttools==4.39.0
Expand All @@ -9,7 +10,6 @@ kiwisolver==1.4.4
lmfit==1.1.0
matplotlib==3.7.1
numpy==1.24.2
opusFC==1.3.0
packaging==23.0
pandas==1.5.3
patsy==0.5.3
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@
DATA_FILES = []

INSTALL_REQUIRES = [
"brukeropusreader", # rc1-parser
"h5py",
"lmfit",
"matplotlib",
"numpy",
"pandas",
"pydantic==1.*",
"pyhht",
"renishawWiRE", # rc1-parser
"scikit-learn",
"scipy>=1.8.0",
"spc-io~=0.0.2", # rc1-parser
"statsmodels",
"uncertainties",
"renishawWiRE", # rc1-parser
"opusFC", # rc1-parser
"spc-io~=0.0.2", # rc1-parser
]

CLASSIFIERS = [
Expand Down
18 changes: 14 additions & 4 deletions src/ramanchada2/io/experimental/rc1_parser/third_party_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from renishawWiRE import WDFReader
from spc_io import SPC
import opusFC
from brukeropusreader import read_file


def readWDF(file):
Expand Down Expand Up @@ -34,6 +34,16 @@ def readSPC(file):


def readOPUS(file, obj_no=0):
c = opusFC.listContents(file)
data = opusFC.getOpusData(file, c[obj_no])
return data.x, data.y, data.parameters
opus_data = read_file(file)
x = opus_data.get_range("AB")
y = opus_data["AB"]
meta = {}
for key in opus_data:
if key == "AB":
continue
if isinstance(opus_data[key], dict):
for subkey in opus_data[key]:
meta["{}.{}".format(key, subkey)] = opus_data[key][subkey]
else:
meta[key] = opus_data[key]
return x, y, meta
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ def crystal_simulation_raw_dat_file():
def vasp_simulation_dat_file():
with open(test_data_dir + '/data/simulations/vasp/snCAL_vasp_raman_ALL.dat') as f:
yield f


@pytest.fixture
def opus_experimental_file():
return test_data_dir + '/data/experimental/test_opus.0'
Binary file added tests/data/experimental/test_opus.0
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/io/experimental/test_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from ramanchada2.io.experimental.rc1_parser.third_party_readers import readOPUS


def test_opus(opus_experimental_file):
x, y, meta = readOPUS(opus_experimental_file)
assert 4096 == len(x)
assert 4096 == len(y)
assert 96 == len(meta)
if "NPT" in meta:
assert 4096 == meta["NPT"]
elif "AB Data Parameter.NPT" in meta:
assert 4096 == meta["AB Data Parameter.NPT"]

0 comments on commit 19cfacb

Please sign in to comment.