[Nexus] nexus question

Watts Benjamin benjamin.watts at psi.ch
Thu Nov 28 12:27:58 GMT 2024


Hi Uwe,
  Thanks for the question. NeXus doesn't get into specifying how a plot is to be formatted, but I think that you can get what you want while staying within the NeXus rules by setting the @units attribute on your time axis dataset to "seconds since 1970-01-01T00:00:00Z". This is because we go by the rule that any unit that is recognised by UDunits<https://docs.unidata.ucar.edu/udunits/current/> is acceptable, and "seconds since 1970-01-01T00:00:00Z" seems to be recognised. For your plotting routine, you could then just look at the @units attribute to decide if special date-time formatting is required. However, I don't know of anyone else using this units string , so I have CC'ed the nexus mailing list to invite further comments.

Another option is to store the time axis values in the dataset as a list of date-time strings, but this feels rather cumbersome to me and I don't recommend it.

Cheers,
Ben

________________________________
From: Flechsig Uwe <uwe.flechsig at psi.ch>
Sent: Thursday, November 28, 2024 08:54
To: Watts Benjamin <benjamin.watts at psi.ch>
Subject: nexus question

Dear Ben,
I want to store and plot data y(t) where t is a time (actually: unix
seconds, i.e. it needs special formatting to be shown in a reasonable way

Question: which nexus attributes should I put in my hdf5 file and later
check in my plot routine to apply the special formatting for my time axis?

example how I typically do such time plots in python:
timeformat = "%H"
xfmt= mdates.DateFormatter(timeformat)
ax1= plt.subplot(1, 1, 1)
ax1.xaxis.set_major_formatter(xfmt)
plt.plot(long2dt(self.xdata), self.data)
plt.xlabel('date time')
plt.ylabel(self.unit)
plt.title(self.desc)

Uwe
--
Paul Scherrer Institut     Tel: +41 56 310 4535
Uwe Flechsig
WSLA 124
5232 Villigen PSI       mailto:uwe.flechsig at psi.ch
SWITZERLAND             URL: https://www.psi.ch

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.nexusformat.org/pipermail/nexus/attachments/20241128/2ebcf384/attachment.htm>


More information about the NeXus mailing list