<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Steve,
<div class="">I have updated nexusformat package to v0.4.8, which should be available on both PyPI and Anaconda (conda update -c nexpy nexusformat). I have checked that it reads your target attributes correctly.</div>
<div class=""><br class="">
</div>
<div class="">Although Pete says that your file is technically valid (and I trust him to be right on such things), I think it would cause fewer problems if you could write the attributes as scalar strings. For example, if I open your file in h5py and read your
‘target’ attribute, I get:</div>
<div class=""><br class="">
</div>
<div class="">>>> target = h5_file['/entry1/default/Time'].attrs['target'][()]</div>
<div class="">>>> target<br class="">
array(['/entry1/instrument/Waittime/Time'],<br class="">
dtype='|S33’)</div>
<div class=""><br class="">
</div>
<div class="">I can only use this as a string within my Python shell either by converting it to a scalar, which is what nexusformat now does, or accessing the first element of the array:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">>>> np.asscalar(target)</div>
<div class="">'/entry1/instrument/Waittime/Time'</div>
<div class="">>>> target[0]</div>
<div class="">'/entry1/instrument/Waittime/Time’</div>
</div>
<div class=""><br class="">
</div>
<div class="">I’m not sure how other languages would handle this, so perhaps this is just a Python issue. </div>
<div class=""><br class="">
</div>
<div class="">By the way, NeXus (and the nexusformat package) do allow attributes to contain arrays. If you look at the chopper example, the ‘axes’ attribute of ‘chopper.entry.data' is an array of variable length strings (with a special h5py object dtype),
which can be used in list comprehensions, etc:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">>>> chopper.entry.data.axes</div>
<div class="">array(['polar_angle', 'time_of_flight'], dtype=object)</div>
</div>
<div class=""><br class="">
</div>
<div class="">However, size 1 arrays are now interpreted as scalars.</div>
<div class=""><br class="">
</div>
<div class="">With best regards,</div>
<div class="">Ray</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Jun 15, 2017, at 11:50 AM, <a href="mailto:steve.collins@diamond.ac.uk" class="">
steve.collins@diamond.ac.uk</a> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Great – thanks People,<o:p class=""></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">I’ve tried to follow the thread…<o:p class=""></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">I understand that (a) my nxs file is valid and (b) the new version of nexusformat will solve the problem.<o:p class=""></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Cheers!<o:p class=""></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Steve<o:p class=""></o:p></span></div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div>
<div class="">
<div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<b class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="Apple-converted-space"> </span>NeXus [<a href="mailto:nexus-bounces@nexusformat.org" class="">mailto:nexus-bounces@nexusformat.org</a>]<span class="Apple-converted-space"> </span><b class="">On
Behalf Of<span class="Apple-converted-space"> </span></b>Osborn, Raymond<br class="">
<b class="">Sent:</b><span class="Apple-converted-space"> </span>15 June 2017 13:25<br class="">
<b class="">To:</b><span class="Apple-converted-space"> </span>V. Armando Solé <<a href="mailto:sole@esrf.fr" class="">sole@esrf.fr</a>><br class="">
<b class="">Cc:</b><span class="Apple-converted-space"> </span>Mita, Charles (DLSLtd,RAL,LSCI) <<a href="mailto:charles.mita@diamond.ac.uk" class="">charles.mita@diamond.ac.uk</a>>; Discussion forum for the NeXus data format <<a href="mailto:nexus@nexusformat.org" class="">nexus@nexusformat.org</a>>;
Sharpe, Chris (DLSLtd,RAL,LSCI) <<a href="mailto:chris.sharpe@diamond.ac.uk" class="">chris.sharpe@diamond.ac.uk</a>><br class="">
<b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [Nexus] Nexpy<o:p class=""></o:p></span></div>
</div>
</div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
Thanks, Armando,<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
That is exactly the aim of the nexusformat package - to give scientists a convenient and, hopefully, reliable tool for reading and writing NeXus files that just works. Speaking as a scientist, we don’t want to worry about whether they should be using variable-length
strings or byte arrays - we just want to have variables we can manipulate in Python and store in our data files when required. We don’t want to worry about whether we have obeyed the standard, but would be delighted if the program sorted that out for us. That
is what nexusformat tries to do, and NeXpy adds other conveniences, like showing visually what items are linked in a file tree. <o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
Those who spend a lot of time developing software, on the other hand, are welcome to do their own thing. If you are happy writing your own read/write modules using, e.g., h5py, then that’s fine. But please don’t expect scientists to have to learn h5py, then
study all the NeXus rules for writing NXdata groups (not forgetting to add an ’NX_class’ attribute, a signal attribute, axes, …), and then worry about whether they should be using byte arrays or strings. <o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
This is a philosophical issue that I have brought up many times at NIAC meetings. The original goal of NeXus was to be a convenience tool for scientists, but it is now largely maintained by developers who are willing to read manuals. I was a little reluctant
about deprecating the NAPI for this reason, but it started to become a barrier to using the more advanced features of HDF5 and few scientists write in C anyway. Python is different - scientists will use it if we give them the right modules - I have a student
with little programming experience who writes standard-conforming NeXus files every day. My suggestion that more people use the nexusformat package, rather than just h5py, is that, as this thread shows, it is helpful to have a wide range of people helping
to debug it so that it doesn’t trip scientists up when they do use it. <o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
With best regards,<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
Ray<o:p class=""></o:p></div>
</div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class="">
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
On Jun 15, 2017, at 3:21 AM, V. Armando Solé <<a href="mailto:sole@esrf.fr" style="color: purple; text-decoration: underline;" class="">sole@esrf.fr</a>> wrote:<o:p class=""></o:p></div>
</div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
Hello,<br class="">
<br class="">
On 15/06/2017 09:17, Carlos Pascual wrote:<br class="">
<br class="">
<o:p class=""></o:p></div>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
And, on the other hand, if the NIAC does bless nexusformat as the preferred<span class="Apple-converted-space"> </span><br class="">
access method for python, I think it should be stated unambiguously in the<span class="Apple-converted-space"> </span><br class="">
manual.<o:p class=""></o:p></div>
</blockquote>
<p class="MsoNormal" style="margin: 0cm 0cm 12pt; font-size: 12pt; font-family: 'Times New Roman', serif;">
<br class="">
Well, at the ESRF Python programmers are using h5py.<br class="">
<br class="">
However we recommend scientists to use nexusformat as a simpler tool<br class="">
because they often work with interactive sessions.<br class="">
As you see our point of view is that nexusformat is just a convenience<br class="">
tool on top of h5py being the later the standard (Python) tool to access<br class="">
HDF5 files.<br class="">
<br class="">
What we do not recommend at all is to use the NeXus library from Python<br class="">
(or from anywhere else).<br class="">
<br class="">
The use of NAPI was unambiguously discouraged by the NIAC in past NIAC<br class="">
meetings in favour of standard tools. However I never understood why<br class="">
trainings were kept going on around an API that was considered obsolete.<br class="">
<br class="">
Best,<br class="">
<br class="">
Armando<o:p class=""></o:p></p>
</div>
</div>
</blockquote>
</div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<div class="">
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<span style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">-- <br class="">
Ray Osborn, Senior Scientist<br class="">
Materials Science Division<br class="">
Argonne National Laboratory<br class="">
Argonne, IL 60439, USA<br class="">
Phone: +1 (630) 252-9011<br class="">
Email: <a href="mailto:ROsborn@anl.gov" style="color: purple; text-decoration: underline;" class="">ROsborn@anl.gov</a><o:p class=""></o:p></span></div>
</div>
</div>
<div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<br class="webkit-block-placeholder">
</div>
<p align="justify" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
-- </p>
<p align="justify" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt
by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.<br class="">
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.<span class="Apple-converted-space"> </span><br class="">
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.<br class="">
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom<br class="">
</p>
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">NeXus
mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="mailto:NeXus@nexusformat.org" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">NeXus@nexusformat.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<a href="http://lists.nexusformat.org/mailman/listinfo/nexus" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://lists.nexusformat.org/mailman/listinfo/nexus</a></div>
</blockquote>
</div>
<br class="">
<div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">
-- <br class="">
Ray Osborn, Senior Scientist<br class="">
Materials Science Division<br class="">
Argonne National Laboratory<br class="">
Argonne, IL 60439, USA<br class="">
Phone: +1 (630) 252-9011<br class="">
Email: <a href="mailto:ROsborn@anl.gov" class="">ROsborn@anl.gov</a></div>
</div>
<br class="">
</div>
</body>
</html>