Skip to content

Commit 4b0dce4

Browse files
committed
Add a nxinterpretation property to NXfields
1 parent 92df860 commit 4b0dce4

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/nexusformat/nexus/tree.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
from pathlib import PurePosixPath as PurePath
218218

219219
import h5py as h5
220+
from matplotlib.rcsetup import validate_color_or_auto
220221
import numpy as np
221222

222223
from .. import __version__ as nxversion
@@ -4033,7 +4034,8 @@ def nxunits(self, value):
40334034

40344035
@property
40354036
def mask(self):
4036-
"""NXfield's mask as an array.
4037+
"""
4038+
NXfield's mask as an array.
40374039
40384040
Only works if the NXfield is in a group and has the 'mask'
40394041
attribute set or if the NXfield array is defined as a masked
@@ -4074,6 +4076,25 @@ def mask(self, value):
40744076
else:
40754077
self._value = np.ma.array(self._value, mask=value)
40764078

4079+
@property
4080+
def nxinterpretation(self):
4081+
"""
4082+
Interpretation attribute
4083+
4084+
This attribute provides guidance on how to plot the field.
4085+
"""
4086+
if 'interpretation' in self.attrs:
4087+
return self.attrs['interpretation']
4088+
else:
4089+
return None
4090+
4091+
@nxinterpretation.setter
4092+
def nxinterpretation(self, value):
4093+
if is_text(value):
4094+
self.attrs['interpretation'] = value
4095+
else:
4096+
raise NeXusError('Invalid value for the interpretation attribute')
4097+
40774098
def valid_attributes(self, group=None, definitions=None, deprecated=False):
40784099
"""
40794100
Return a list of valid attribute names for the NeXus field.

0 commit comments

Comments
 (0)