[Nexus] Extending NeXus for pixelated scanning transmission electron microscopy

Dieter Weber d.weber at fz-juelich.de
Wed May 2 12:35:36 BST 2018

Dear all,

appended you find a very simple first draft for a script to create a
pixelated STEM NeXus file from a raw data file.

As next steps I'd propose to organize a Hangout session to discuss and
add more fields and structures together so that we can combine our
know-how. I've created a Doodle poll to help coordinate the time:
https://doodle.com/poll/zxvsimgw94fx4m3s Please let me know if I should
add more time options.

I'd like to choose a time by Friday 4th, if that is possible. Many
thanks in advance for your help! Looking forward to work together on this!

With best regards,

Am 18.04.2018 um 10:10 schrieb d.weber at fz-juelich.de:
> Dear Tobias,
> thank you for your help! I can work on building such a file next week.
> We've been tied up with other issues in the last weeks, that's why this
> had to wait a bit.
> Best regards,
> Dieter
> --
> Dr. Dieter WEBER
> Peter Grünberg Institute PGI-5 for Microstructure Research
> Ernst Ruska-Centre ER-C for Microscopy and Spectroscopy with Electrons
> Research Centre Jülich
> D-52425 Jülich, Germany
> Email: d.weber at fz-juelich.de
> Phone: +49 2461 61 85118
> On Apr 3, 2018 17:54, Tobias Richter <Tobias.Richter at esss.se> wrote:
>     Dear Dieter et al,
>     We very much agree on the goals in your drafts.
>     It looks like we need to get to the technical detail pretty soon.
>     In order to understand what data you have to deal with an example
>     file would go a long way.
>     Could you maybe produce something in HDF5 that roughly follows your
>     proposed structure?
>     Then it's a less abstract problem and we can follow up with more
>     informed comments and questions.
>     To keep the community here in the loop, I would prefer to keep the
>     discussion on this list for the time being.
>     Best wishes,
>     Tobias

Dr. Dieter WEBER

Peter Grünberg Institute, Microstructure Research (PGI-5)
Ernst Ruska-Centre for Microscopy and Spectroscopy with Electrons (ER-C)
Forschungszentrum Jülich
52425 Jülich, Germany

Email: d.weber at fz-juelich.de
Phone: +49 2461 61 85118

Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt

-------------- next part --------------
import nexusformat.nexus as nx
import numpy as np

rawfile = 'C:\\Users\\weber\\Nextcloud\\EMPAD\\scan_11_x256_y256.raw'
targetfile = 'C:\\Users\\weber\\Nextcloud\\Projects\\Open Pixelated STEM framework\\LiberTEM.nxs'
def build_detector():
	pixel_size = nx.NXfield(value=150e-6, units='m') # EMPAD https://arxiv.org/ftp/arxiv/papers/1511/1511.03539.pdf
	beam_center_x = nx.NXfield(value=0, units='m')
	beam_center_y = nx.NXfield(value=0, units='m')
	camera_length = nx.NXfield(value=0.7, units='m')
	with open(rawfile) as f:
		shape_in = (65536, 130, 128)
		rawdata = np.fromfile(f, dtype=np.float32).reshape(shape_in)[:, :128, :128]
	return nx.NXdetector(
def build_scan():
	scan = np.linspace(-10e-9, 10e-9, 256)
	x_coordinates = np.repeat(scan, 256)
	y_coordinates = np.concatenate(list((np.repeat(x, 256) for x in scan)))
	return nx.NXbeam(scan_x=x_coordinates, scan_y=y_coordinates)
root = nx.NXroot()
root.insert(nx.NXentry(), name='entry')

e = root.entries['entry']

e.insert(nx.NXinstrument(), 'instrument')
i = e.entries['instrument']
i.insert(build_scan(), 'scan')
i.insert(build_detector(), 'detector')

e.insert(nx.NXdata(nx.NXlink(root.entry.instrument.detector.data), ('index', 'sensor_x', 'sensor_y')), 'data')

More information about the NeXus mailing list