Skip to content

Commit

Permalink
Merge pull request #180 from prjemian/2021.1.0rc1
Browse files Browse the repository at this point in the history
prep for release 2021.1.0
  • Loading branch information
prjemian committed Jul 16, 2019
2 parents f471f7e + 3f914d2 commit e8fcd02
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 21 deletions.
8 changes: 7 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ Change History
Production
**********

:2021.1.0: expected *2019.08*, handle #UXML control lines
:2021.1.0: *2019.07.15*, new features

**NEW**

* support for ``#UXML`` metadata
* support for ``hklscan`` scans
* improved support for ``mesh`` and ``hklmesh`` scans

* `#159 <https://github.com/prjemian/spec2nexus/issues/159>`_
handle #UXML metadata control lines
Expand Down
21 changes: 10 additions & 11 deletions src/spec2nexus/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,16 @@ def save_data(self, nxdata, scan):
signal, axes = self.mesh(nxdata, scan)
elif scan_type in ('hscan', 'kscan', 'lscan', 'hklscan'):
# hklscan 1.00133 1.00133 1.00133 1.00133 2.85 3.05 200 -400000
# FIXME:
# h_0, h_N, k_0, k_N, l_0, l_N = scan.scanCmd.split()[1:7]
# TODO: why bother defining axes here? Not used. issue #155
# if h_0 != h_N:
# axes = ['H',]
# elif k_0 != k_N:
# axes = ['K',]
# elif l_0 != l_N:
# axes = ['L',]
# FIXME: signal, axes = self.oneD(nxdata, scan)
raise NotImplementedError("hklscan save_data() not yet implemented")
signal = self.oneD(nxdata, scan)[0]
axes = []
h_0, h_N, k_0, k_N, l_0, l_N = scan.scanCmd.split()[1:7]
if h_0 != h_N:
axes.append('H')
if k_0 != k_N:
axes.append('K')
if l_0 != l_N:
axes.append('L')
axes = ":".join(axes)
else:
signal, axes = self.oneD(nxdata, scan)

Expand Down
61 changes: 52 additions & 9 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,62 @@ def test_save_data_hklmesh(self):
self.assertEqual(axes[0], b"H")
self.assertEqual(axes[1], b"K")

def test_save_data_hklscan(self):
#S 104 hklscan -0.0500048 -0.0500048 0.05 0.2 12.0002 12.0002 30 2
fname = os.path.join(_path, "spec2nexus", 'data', '33id_spec.dat')
def test_save_data_hscan(self):
# hklscan moving H
test_file = 'lmn40.spe'
scan_number = 74

fname = os.path.join(_path, "spec2nexus", 'data', test_file)
hname = "test.h5"
spec_data = spec.SpecDataFile(fname)
out = writer.Writer(spec_data)
out.save(hname, [scan_number])

with h5py.File(hname, "r") as hp:
root = hp["/"]
nxdata = root["/S%d/data" % scan_number]
signal = nxdata.attrs["signal"]
axes = nxdata.attrs["axes"]
self.assertEqual(signal, "NaI")
self.assertEqual(axes, "H")

def test_save_data_kscan(self):
# hklscan moving K
test_file = '33id_spec.dat'
scan_number = 104

fname = os.path.join(_path, "spec2nexus", 'data', test_file)
hname = "test.h5"
spec_data = spec.SpecDataFile(fname)
out = writer.Writer(spec_data)
out.save(hname, [scan_number])

with h5py.File(hname, "r") as hp:
root = hp["/"]
nxdata = root["/S%d/data" % scan_number]
signal = nxdata.attrs["signal"]
axes = nxdata.attrs["axes"]
self.assertEqual(signal, "I0")
self.assertEqual(axes, "K")

with self.assertRaises(NotImplementedError) as context:
out.save(hname, [104])
received = str(context.exception)
expected = "hklscan save_data() not yet implemented"
self.assertTrue(received.startswith(expected))
# FIXME:
def test_save_data_lscan(self):
# hklscan moving L
test_file = '33bm_spec.dat'
scan_number = 14

fname = os.path.join(_path, "spec2nexus", 'data', test_file)
hname = "test.h5"
spec_data = spec.SpecDataFile(fname)
out = writer.Writer(spec_data)
out.save(hname, [scan_number])

with h5py.File(hname, "r") as hp:
root = hp["/"]
nxdata = root["/S%d/data" % scan_number]
signal = nxdata.attrs["signal"]
axes = nxdata.attrs["axes"]
self.assertEqual(signal, "signal")
self.assertEqual(axes, "L")


def suite(*args, **kw):
Expand Down

0 comments on commit e8fcd02

Please sign in to comment.